Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 931

 
TarasBY:

I've made an example, and you can work out the terms more or less on your own:


Good morning! My price doesn't move and I can't find the error myself. Can you check and correct the code?
 
silachara:

Here's made a completely primitive code.

Good morning! The point is that if we add the condition if(Ask>Price1)Price1=Ask, it won't work anymore. For every tick all the numbers will become the same and it won't save.

   double Price1, Price2, Price3, Price4;

void OnTick()
  {
Price4=Price3;
Price3=Price2;
Price2=Price1;

if(Ask>Price1)
Price1=Ask;
Comment(Price1, "\n", Price2, "\n", Price3, "\n", Price4);
  }
 
abeiks:

Good morning! The point is that if we add the condition if(Ask>Price1)Price1=Ask, it won't work anymore. For every tick all figures will become the same and will not save.

Let me remind you the condition you posed: "Hello, how can we make the new price be displayed first and the previous one be displayed second and so on? In the example, you have given me the function of changing the price by tick. Therefore, I have created a simple code that will solve your task. There was no additional condition in your question: one must compare something.

Now you are voicing the second condition. Please correctly describe the problem conditions. For example: 1) I want Comment() to create 4 lines for each new tick (the price of the most recent tick is at the top, the price of the previous tick is below it, etc.). 2) I also want it to make comparison (describe what with what), and then the next calculation, or action, or something else would be performed.

 
silachara:

Let me remind you the condition of the problem you set "Good afternoon! How can I make the new price be displayed first and the previous price be lowered and so on". In the example, you have given me the function of changing the price by tick. Therefore, I have created a simple code that will solve your task. There was no additional condition in your question: one must compare something.

Now you are voicing the second condition. Please correctly describe the problem conditions. For example: 1) I want Comment() to create 4 lines for each new tick (the price of the most recent tick is at the top, the price of the previous tick is below it, etc.). 2) I also want it to make a comparison (describe what with what), and then the next calculation, or action, or something else would be performed.


I apologize, I have not correctly described the problem condition. That's why I added an example to make the problem condition clearer.
 
abeiks:
I apologize, I did not describe the problem condition correctly. That is why I added an example to make the problem condition clearer.

I understand that for the first item of the problem (the price of the freshest tick at the top), there is a solution.

Please formulate, in words, the second point of the problem. Or don't you need the solution?

 
silachara:

I understand that for the first point of the problem (price of the freshest tick above), there is a solution.

Such a task didn't exist. I wrote about the price, not the tick.


I want every new price that differs from the first price and matches the Ask>Price1 condition to show the new price first and the previous price going down.

 
abeiks:
Such a task didn't exist. I was writing about the price, not the tick.


I want to see that at each new price that differs from the first one and meets the Ask>Price1 condition, the new price is displayed first and the previous price is moved down.

The first condition has been defined. If Ask>Price1, then the top line should be the Ask price. What price values should Price2-Price4 be?

What about the second condition? If Ask<=Price1, what should the program do?

 

Hi, how to change the name - object Fibo.

 for(int i=0;i<obj_total;i++)
    {
     index=ObjectName(i);
     string substr = StringSubstr(index, 0, 4);
   if (substr == "Fib1")
     { 
  NameFibs=index;   
  ObjectSetString(0,NameFibs,OBJPROP_NAME,"изменить на это имя");
}}
 
silachara:

The first condition has been defined. If Ask>Price1, then the top line should be the Ask price. What should the values of Price2-Price4 be?

And what about the second condition? If Ask<=Price1, what should the program do?

What values should the Price2-Price4 prices be?
If a new price arrives that matches the condition, then Price1 becomes Ask price, Price2 becomes Price1 price, Price3 becomes Price2 price, Price4 becomes Price3 price.

If Ask<=Price1, what should the program do?
Then nothing happens.
 
Top2n:

Hi, how to change the name - object Fibo.

As far as I know, the name of the object does not change. A new object with a new name is created.

The old object is deleted if necessary (at first it is enough to know the old MT4).

Reason: