[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 248

 
Bicus:

What's that? It's going through all the orders of history, isn't it? It is clear that the body of the loop can somehow be limited by dates, etc.

What I meant in my question was, is there any trick to store only the last few closed orders in the tester's history, i.e. the way it is done in the real history?

In the real history it works the same way. All orders of the account history are searched.

The history is not corrected. It is the same for this account and can only be updated with new events.

 
artmedia70:

Seems to be boring already... It's elementary, Watson:

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int start()
{
if (ObjectFind("MyPriceLine")<0) ObjectCreate("MyPriceLine", OBJ_HLINE, 0, 0, Ask+20*Point) ;
ObjectSet("MyPriceLine", OBJPROP_PRICE1, Ask+20*Point);
return(0);
}

//+------------------------------------------------------------------+
Thanks for the long-awaited reply! I can't understand, how it will help me to solve my problem? How do I make the lines draw above and below Ask and from the same EA at the same time?
 
globad:
Thank you for the long awaited reply! I can't see how this will help me solve my problem? How do I make the lines draw above and below Ask and from the same EA at the same time?
Give the lines different names.
 
Vovo4ka:

Guys help, the condition is as follows: three bullish candles, then there is a "takeover" .... I opened a position to sell similarly to buy...here's the code where the error is?

where is the mistake?
 
sergeev:
what's the problem?

it doesn't work this way....... doesn't open positions....though I see from history it should open, but it doesn't open positions... it just keeps silent and no errors
 
How do I make a trade open no more than, say, one per hour?
 
artmedia70:
Give the lines different names.

Somehow...?

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int start()
{
if (ObjectFind("MyPriceLine1")<0) ObjectCreate("MyPriceLine1", OBJ_HLINE, 0, 0, Ask+20*Point) ;
ObjectSet("MyPriceLine1", OBJPROP_PRICE1, Ask+20*Point);
if (ObjectFind("MyPriceLine2")>0) ObjectCreate("MyPriceLine2", OBJ_HLINE, 0, 0, Ask-20*Point) ;
ObjectSet("MyPriceLine2", OBJPROP_PRICE1, Ask-20*Point);
return(0);
}
//+------------------------------------------------------------------+
 
Vovo4ka:
Guys, how do I make a trade open no more than, say, once an hour?

For example, like this:

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

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

Call like this:

if (SecondsAfterOpenLastPos(NULL, OP_SELL, Magic)>=(Period()*3)*60) {
   // --- код, если прошло три минуты и более с момента открытия ... 
   // ... последней позиции Sell  с магиком Magic  на текущем символе ---
   }
I hope you can turn minutes into hours ... :)
 
globad:

Somehow...?

Don't ask, check with a tester... :)
 
globad:

Somehow...?

if (ObjectFind("MyPriceLine1")<0) ObjectCreate("MyPriceLine1", OBJ_HLINE, 0,0, Ask+20*Point);
                                     ObjectSet("MyPriceLine1", OBJPROP_PRICE1, Ask+20*Point);
if (ObjectFind("MyPriceLine2")>0) ObjectCreate("MyPriceLine2", OBJ_HLINE, 0,0, Ask-20*Point);
                                     ObjectSet("MyPriceLine2", OBJPROP_PRICE1, Ask-20*Point); 
ObjectFind returns -1 if the line has not yet been created, i.e. you should also write ObjectFind("MyPriceLine2")<0 in the second if
Reason: