[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 444

 
Elena56:

During the optimization process, I check the visualization item and press start, after which the strategy tester fades, the visualization mark disappears and the test proceeds at a very slow pace. What does it mean? I was loading quotes and updating. (MT4)

This is optimisation, not testing.
 

Gentlemen, help plz. I have a problem - does not want to write text at the close of the order, tell me why plz

   OrderSelect(otbH,SELECT_BY_TICKET);
   if(OrderSelect(otbH,SELECT_BY_TICKET)==true)
   { 
      Print("1");
      if(OrderCloseTime()>0)
      {
         Print("2");
         ObjectCreate("ndp"+OrderTicket(),OBJ_TEXT,0,0,0);
         ObjectSet("ndp"+OrderTicket(),OBJPROP_TIME1,TimeCurrent());
         ObjectSet("ndp"+OrderTicket(),OBJPROP_PRICE1,OrderClosePrice());
         ObjectSetText("ndp"+OrderTicket(),OrderProfit(),5,"Arial",Aqua);
      } 
   }    
   
   

otbH - this is the ticket number. The interesting thing is that the number "1" it prints, but the number "2" refuses... I can't figure out the reason... ...because it selects the order... explain to me...

 
CLAIN:

Gentlemen, help plz. I have a problem - does not want to write text at the close of the order, tell me why plz

otbH - this is the ticket number. The interesting thing is that the number "1" it prints, but the number "2" refuses... I can't figure out the reason... ...because it selects the order... explain to me...


Is the order closed or not?
 

The order opens first, then it closes.

This script runs on every tick, so at one point it will definitely be closed...

I select the order by the ticket first - OrderSelect(otbH,SELECT_BY_TICKET); - it will select it, no matter where it is, right?

And then it should determine whether it's closed or open... but for some reason it doesn't...

 
CLAIN:

The order opens first, then it closes.

This script runs on every tick, so at one point it will definitely be closed...

I select the order by the ticket first - OrderSelect(otbH,SELECT_BY_TICKET); - it will select it, no matter where it is, right?

And then it should determine whether it's closed or open... but for some reason it doesn't...


Try selecting a closed order
 
Tell me how, I don't know how.
 
CLAIN:
Tell me how, I don't know how.

   int total=OrdersHistoryTotal();
   for (int i=total-1;i>=0;i--) 
   {
      if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
      {
         if (OrderSymbol()==Symbol())
         {
            if(OrderMagicNumber()==MagicNumber )
            {
               // Ваши действия с ордером
            }
         }
      }
   }
 

The question is - the opening price is calculated at crossing two moving (exaggerated), in the test - everything is OK, but when you put it on the demo, the openings are false (because during the formation of a bar price inside jumping from min to max), therefore the idea to take into account the crossing only when the bar is formed, ie bar is formed (saw the crossing) and then the next market entry, taking into account the crossing.

 
DOCTORS:

The question is this: the opening price is calculated by crossing two sliders (exaggerated), in the test everything is OK, but when you put it on the demo, the openings are false (because during the creation of one bar the price inside jumps from min to max), therefore the idea is to consider the crossing only after the bar is formed, ie bar is formed (we saw the crossing) and then the next market entry is made with the crossing.

It is strange why it is OK in the tester - in the tester the zero bar is also not formed and there will be false crossovers as well.

Look for crossovers on the 1st and 2nd bars. If on the second МА1 <= МА2, while on the first МА1 > МА2, it means that МА1 has crossed МА2 from bottom to top. For top-down, it is the other way round.

Only do the comparison by subtraction:

   double MA1=iMA(Symbol(),Period(),ma_period,ma_shift,ma_method,applied_price,1);
   double MA2=iMA(Symbol(),Period(),ma_period,ma_shift,ma_method,applied_price,2);
   if (NormalizeDouble(MA1-MA2,Digits)<=0)
   if (NormalizeDouble(MA1-MA2,Digits)>0) {
      // MA1 пересекла MA2 снизу-вверх
      }

For top-down, vice versa.

You can compare it not to zero, but to some minimum value, e.g. 0.1*Point

 
artmedia70:

It's strange why it's OK in the tester - in the tester the zero bar is also not formed and there will be false crossovers as well.

Look for crossovers on the 1st and 2nd bars. If on the second MA1 <= MA2 and on the first MA1 > MA2, then MA1 has crossed MA2 from bottom to top. For top-down, it is the other way round.

Only do the comparison by subtraction:

For top-down, vice versa.

You can compare it not to zero, but to some minimum value, e.g. 0.1*Point


Thank you so much!

Reason: