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

 

Can you give me a code example, I can't think of anything normal.

How to force price comparison ( for example: MarketInfo(Symbol(),MODE_BID ) by how much the price has risen above/lower since the price comparison started.

If I use Variables "A" and "B" with Bid, how can I force to update only Variable "B" and compare them further - otherwise they both will always have the same values.

Or maybe there are simpler built-in ways?

 
culler:

Can you give me a code example, I can't think of anything normal.

How to force price comparison ( for example: MarketInfo(Symbol(),MODE_BID ) by how much the price has risen above/lower since the price comparison started.

If I use Variables "A" and "B" with Bid, how can I force to update only Variable "B" and compare them further - otherwise they both will always have the same values.

Or maybe there are simpler built-in ways?


Time should be taken into account. Remember the time when the first Bid value was written and then compare it with the actual Bid value after a certain interval:


1. t=0; A=Bid; B=Bid; C=MathAbs(B-A);

2. t=10; B=Bid; C=MathAbs(B-A); A=Bid;

3. t=20; B=Bid; C=MathAbs(B-A); A=Bid;

...

B variable C will thus be the absolute value of the difference in Bid over the past 10 seconds.

 

Please advise - while debugging the program - in the debugger in the window "Expression values tracking" in the expressions writes "Expression could not be evaluated" while the values of

these expressions calmly pop up in the window called by the Alert function. The program works, the variables are assigned values and in the debugger they are not displayed as they can not be evaluated. How this can be?

 
evillive:

The time has to be taken into account. Remember the time when the first Bid value was recorded, and then compare at a given interval with the actual Bid at that time:


1. t=0; A=Bid; B=Bid; C=MathAbs(B-A);

2. t=10; B=Bid; C=MathAbs(B-A); A=Bid;

3. t=20; B=Bid; C=MathAbs(B-A); A=Bid;

...

B variable C will thus be the absolute value of the difference of Bid in the past 10 seconds.


There is no reference to time. Time is the enemy here.

How without time?

 
culler:


There is no time reference. Time is the enemy here.

How without time?


You put a variable with the price value into OnInit, and it will be bound to the price during Expert Advisor start, then you can compare it with what you need
 
culler:


There is no time reference. Time is the enemy here.

How can you do without time?


You can't do without time on the tailrace, it's an inseparable part of the system, alas. Even in the question posed, time appears:

How to make price comparison ( for example: MarketInfo(Symbol(),MODE_BID ) how much higher/lower from the moment of price comparison.

The "moment" is time there, the initial reference point.

 
culler:

Can you give me a code example, I can't think of anything normal.

How to force price comparison ( for example: MarketInfo(Symbol(),MODE_BID ) by how much the price has risen above/lower since the price comparison started.

If I use Variables "A" and "B" with Bid, how can I force to update only Variable "B" and compare them further - otherwise they both will always have the same values.

Or maybe there are simpler built-in ways?

LastPrice=0;

NewPrise=0;

if(условие записи  LastPrice &&  NewPrise==0){LastPrice = MarketInfo(Symbol(),MODE_BID);}

if(LastPrice > 0) { NewPrise = MarketInfo(Symbol(),MODE_BID);} 


 
evillive:

On the tailrace there is no time without time, it is an inseparable part of the system, alas. Even in this question time is present:

the "moment" there is the time, the starting point.


there is no time in forex.... there is a continuous series of expected states... (predictions)

But for a trader, between two expected states one hour may pass, another month, another seconds, or even a year... :-)))

it is his problem... the whole point of successful trading is to minimize the waiting period.... ( depending on what one is aiming for...)

 

Hi all. Question about IndicatorCounted():

#property indicator_separate_window
datetime LastBarTime=0;
int start() 
{
   // каждый свежий бар считаем только 1 раз (сразу после закрытия)
   if (Time[0]!=LastBarTime)               // если идёт расчёт всей истории или начался свежий бар
   {
      LastBarTime=Time[0];
      
      int counted=IndicatorCounted(); if(counted<0) return(-1);
   // if (counted>0) counted--;   <<< зачем оно???
   
                 int i=Bars-counted;  // варианты: считаем историю(i=кол-во баров), сформирован свежий бара (i=2) ПОЧЕМУ?
      if (counted<2) i=Bars-2;        // для корректного начала расчёта (иначе i и тем более i+1 заглядывают в бездну)

      Print("!!!!!!TEST Bars-counted=",i);  // ПОЧЕМУ =2 ???
                     
      for (; i>0; i--) // открытый бар не считаем
      {
      // варианты:
      // 1) в истории недостаточно баров (меньше трёх): итераций цикла не будет
      // 2) произошла переинициализация переменных и тогда надо считать историю с нуля (i указывает на 2-й бар слева)
      // 3) историю уже расчитали, а сейчас сформирован свежий бара: i должна указывать на закрытый бар (i=1)
      }
   }
   
return (0);
}


Can I expect only two states in the loop:

1) initialization (static variables are reset and i points to the 2nd bar on the left);

2) the whole story is calculated (i=2);


And, actually, why i=2? I would understand i=1 or i=0, but why 2? Can I rely on that 2? =)

If not, what is the right way to do it. I have a chain calculation, so the same bar cannot be processed repeatedly.

...

Ok, I'll put the question another way. Straight to the point. Can I use a variable instead of IndicatorCounted()?

That is, is the primary initialization of stats and globals always the same as 0 from IndicatorCounted()?

 
I need to change the magic number of a pending order, but I am coming to the conclusion that there is no such possibility. Can you tell me if the magic number cannot be modified or did I miss something in my life?
Reason: