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

 
How do I open an indicator subwindow from an EA?
 

Hello!

I've seen a bar-counting function somewhere, but I can't find it now. I need some number of bars to pass between opening a position and closing it (with or without condition). Please, send me the link if you know it. Thanks

 
rapid_minus:

Hello!

I've seen a bar-counting function somewhere, but I can't find it now. I need some number of bars to pass between opening a position and closing it (with or without condition). If you know this, please send me the link. Thanks

static datetime time_close = время_открытия + (через_сколько_баров_закрывать * Period()); // расчитываем время когда закрывать.

if(TimeCurrent()>=time_close)Func_Закрыть();   // Проверяем не наступило ли время закрыть позицию.
 
AlexeyVik:


The second variant: If only 3 orders are provided for, we can declare, for example, int tick_buy_1, tick_buy_2, tick_buy_3 at the level of global variables and record the tickets in these variables when opening the order. Then we can select the order by ticket, check its type, whether the order is closed or not, and only then, without the loop.


This doesn't work. not enough qualification....
 

Hello all !

What optimisable parameter should be chosen to get the minimum number of uninterrupted losing trades ? In restrictions I myself specify the desired amount, but if you set the "Balance", then it will be more profit-oriented. If I'm using Custom, what should I add in OnTester ? I found an article on custom optimizing criteria in MQL5 but it was not of much help.

 
vadimvborisov:
It doesn't work. not enough qualifications....
you can also mark orders in the description - and then use the description to find them ....
 
elmucon:
And you can also mark orders in the description - and then use the description to find them ....
Good idea. This is the "comment" parameter, if I'm not mistaken. I am going to try it now.
 
vadimvborisov:
Good idea. It's the 'comment' parameter, if I'm not mistaken. I'll give it a try.
you're not wrong ... try it - it worked for me ...
 
vadimvborisov:
It's not working. lacking qualifications....

It goes something like this.

// это уровень глобальных переменных.
int gTicket_1, gTicket_2, gTicket_3;

int OnInit()
{
  return(INIT_SUCCEEDED);
}

void OnTick()
{
// При каком-то условии
gTicket_1 = OrderSend(соответствующие параметры);
gTicket_2 = OrderSend(соответствующие параметры);
gTicket_3 = OrderSend(соответствующие параметры);

// При каком-то условии, проверив что ордера не закрыты, не удалены и не модифицировались до того

bool Mod = OrderModify(gTicket_1, и остальные параметры);
     Mod = OrderModify(gTicket_2, и остальные параметры);
     Mod = OrderModify(gTicket_3, и остальные параметры);
}
 

Hi all....

Can you give me a hint here's the thing.... why the formula only works up to a certain limit.

     if (N!=0)  Sortino=pow ((ProfitFactor-LastPF)-((Sortino+(ProfitFactor-LastPF))/N),2);

It works like this, but as soon as I add an accumulation, it stops counting at once.... And the main thing is that it does not give out any errors.....

But it stops working like this...

     if (N!=0)  Sortino=Sortino+(pow ((ProfitFactor-LastPF)-((Sortino+(ProfitFactor-LastPF))/N),2));
Reason: