[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 576

 
Minodi >>:

Вот так?

if (OrderSelect(OrdersTotal(), SELECT_BY_POS, MODE_TRADES)) {

ot=OrdersTotal();

if (ot<1){

Nope, if only one expert is working and no more than one order should be opened, you can do this (for starters)

if(OrdersTotal()==0 && /* все остальные твои условия*/)
 
What if there is an open order? Or even more than one?
 
Minodi >>:
А если есть открытый ордер? или даже несколько? получится эксперт не сработает
First find a tactic, test it, then worry about parallel EAs and left orders.
 

A hint, there is a definition of a daily high and low time:

if (time!=Time[0]){HiTime=0;LoTime=0;time=Time[0];}

if (High[0]>HiPrice)HiTime=TimeCurrent();

if (Low[0]<LoPrice)LoTime=TimeCurrent();

We need to compare the time of high/low with the specified time of the day. For example, it should be 22.00.

Can it be written like this:

datetime TimeE;

int h=22, m=00, ot;

TimeE=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+""+h+": "+m);

 

There is a tactic, but the EA opens in a weird way.

I must not be setting the time 22.00 for the condition correctly.

If it has to be reset, how?

 

Can you please tell me what kind of turkey this is? Where can this question be moved to?

 

Help to bring the EA up to date. The idea is simple - if High is later than Low and after 22.00 - buy from the current. and also if Low is later than Low and after 22.00 - sell from the current. Opening time of orders is set. Stop and profit is fixed.

In practice it has turned out, that opens sometimes correctly, and sometimes not on condition.

Files:
 
Minodi >>:
А если есть открытый ордер? или даже несколько? получится эксперт не сработает


I make it easier. But in this case it will open a new order when the EA is reinstalled.

if(FLAG_ORDER == NO && Signal_OPEN == OPEN_SELL)
{
TICKET_SELL = OrderSend(Symbol(),OP_SELL,Lot,Bid,5,0,0,NULL,0,0,CLR_NONE);
ERROR = GetLastError();
switch(ERROR)
{
case 0 : FLAG_ORDER = YES;
Signal_OPEN = NO;
Error("Set SELL: ",ERROR);
if(Sound_ON == true) PlaySound(Name_Sound_Open);
return(0);
default: Error("Set SELL: ",ERROR); return;
}
}

 
how do you insert the code into a topic so that it is highlighted?
 

When this EA is running on a real account, error 146 is very frequent.

Is it possible to make the Expert Advisor make several attempts to open an order, say, with a pause of half a minute?

Reason: