- How to open new order right after the trailing stop is closed on same direction.
- need help with codes
- trade at time
I try to writes a beginner EA and I wish the EA able to close out the opened order after 6 hours, if any one can help me out I very appreciated, Thanks.
I try to writes a beginner EA and I wish the EA able to close out the opened order after 6 hours, if any one can help me out I very appreciated, Thanks.
What is your concrete issue???. Put your attempt and maybe anybody help you. Otherwise, you could consider this section:
Regards.
What have you tried ?
This is what I tried;
//| Check for close profits conditions |
//+------------------------------------------------------------------+
void Trade_Close()
{
int res;
int CloseHour=6;
int CloseMM=30;
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderMagicNumber()!=Magic || OrderSymbol()!=Symbol()) continue;
//---- check order type
if(OrderType()==OP_BUY)//exit buy.
{
if(OrderOpenTime()>TimeCurrent() && Hour()>CloseHour && Minute()>CloseMM)
res=OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)//exit sell.
{
if(OrderOpenTime()<TimeCurrent() && Hour()>CloseHour && Minute()>CloseMM)
res=OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
break;
}
}
}
Always count down when working with orders, mandatory if you want to close.
No need to break, continue.
Completely unneeded. Use OrderClosePrice() instead of Bid/Ask, it will be the right close price.
Here I am not sure what you want to do, but this condition will never be true. An order can't be opened after the current time, unless you found a way to travel in time. (Nota: please gurus don't start to argue about that :-D).
Always count down when working with orders, mandatory if you want to close.
No need to break, continue.
Completely unneeded. Use OrderClosePrice() instead of Bid/Ask, it will be the right close price.
Here I am not sure what you want to do, but this condition will never be true. An order can't be opened after the current time, unless you found a way to travel in time. (Nota: please gurus don't start to argue about that :-D).
Always count down when working with orders, mandatory if you want to close.
No need to break, continue.
Completely unneeded. Use OrderClosePrice() instead of Bid/Ask, it will be the right close price.
Here I am not sure what you want to do, but this condition will never be true. An order can't be opened after the current time, unless you found a way to travel in time. (Nota: please gurus don't start to argue about that :-D).
I see what you mean, Thanks
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use