[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 249

 
artmedia70:
Don't ask, check with a tester... :)
After compilation the Expert Advisor works the same way it did before changes. I.e. it draws one line.
 
globad:
the expert draws one line.
if the code says "draw line 1 if it is not drawn; draw line 2 if it is not drawn" - they cannot not be drawn:)
 
eddy: artmedia70:
if the code says "draw line 1 if it's not drawn; draw line 2 if it's not drawn" - they can't not be drawn:)
All guys, figured it out! It works!
 

Can you tell me why all the percentages are 0 in the test report? I.e. relative drawdown, maximum drawdown, etc.?

 
artmedia70:

For example, like this:

Call like this:

I hope you can turn minutes into hours ... :)





I tried to write it the way you said, but it works... it still opens positions at the close of the previous one...((

maybe you don't understand what i mean, i want it to open a position no earlier than 1 hour after the previous one was closed ... and in your case, it excludes the possibility of re-opening, but as soon as it closes, it immediately opens the next one

 if (SecondsAfterOpenLastPos(NULL, OP_SELL, MAGIC)>=(Period()*Interval)*60) {
        OpenSell();  
           } 
 
guys help: we need a trade to be opened if a certain amount of time has passed after the previous one was closed....help
 
Vovo4ka:
guys help: I need a deal to be opened if a certain amount of time has passed after the previous one was closed....help


for (int i=0; i<OrdersTotal(); i++)
{ if(OrderSelect(i, SELECT_BY_POS)==true)
{
TC = TimeCurrent();
OM = OrderMagicNumber();
if (TC-OM>86400 && (OrderType()==OP_SELL)){
CLOSEORDER("Sell");
}
if (TC-OM>86400 && (OrderType()==OP_BUY)){
CLOSEORDER("Buy");
}
}
}

In OrderMagicNumber() when opening an order it writes: Magic = TimeCurrent();

 
ILL:


for (int i=0; i<OrdersTotal(); i++)
{ if (OrderSelect(i, SELECT_BY_POS)==true)
{
TC = TimeCurrent();
OM = OrderMagicNumber();
if (TC-OM>86400 && (OrderType()==OP_SELL)){
CLOSEORDER("Sell");
}
if (TC-OM>86400 && (OrderType()==OP_BUY)){
CLOSEORDER("Buy");
}
}
}

In OrderMagicNumber(), when opening an order, it's written: Magic = TimeCurrent();


I forgot =) 86400 - this is the number of seconds after which the position is closed
 
ILL:

Can you tell me why all the percentages are 0 in the test report? I.e. relative drawdown, maximum drawdown, etc.?


All figured out - the deposit was too big)
 
Vovo4ka:


I tried to write it the way you said, it works... it still opens a position at the close of the previous one...(

Maybe you don't understand what I mean, it needs to open a trade not earlier than 1 hour after the previous one was closed...and in your case, it excludes the possibility of opening a repeat trade, but as soon as it is closed, the next one is opened immediately

And think about the function code? Find four differences :) :

//+----------------------------------------------------------------------------+
datetime SecondsAfterCloseLastPos(string sy, int op, int mn) 
{
   datetime t;
   int      i, k=OrdersHistoryTotal();

   if (sy=="0") sy=Symbol();
   for (i=0; i<k; i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
         if (OrderSymbol()!=sy)        continue;
         if (OrderType()!=op)          continue; 
         if (OrderMagicNumber()!=mn)   continue; 
         if (t<OrderCloseTime()) t=OrderCloseTime();
         }
      }
  return(TimeCurrent()-t);
}
//+----------------------------------------------------------------------------+