Hi to all programmer guru's here i am a newbie in mql4 programming and i stuck on a problem,
so it is the following :
i have 2 EMA 5 and 20 PERIOD_15 and respectivly 5 and 20 EMA on PERIOD_H1.
So when i am entering a posision with the first cross PERIOD_M15, the advisor close the position immediatly in the same bar if the prise move the other way and made a reverse cross. This is programmatically correct, but my acctual problem is to wait for the next 1-2 or more bars and then close the position if cross found.
So can you help me to do that ? if some related topic with the same problem is here, can you send me a link
and the Moderators can remove the post .
thx in advance!!
--if you allready have an open position
-- if too much crosses occurs
-- wait a little bit before exit of this position
--this should solve the repeated crosses in one bar
if(firstCross == 1)
{
---------------------------//Close, check if next several bar's printed after OpenOrderPrise()-----------------------------------
if(openbar <= closebar)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3,Red); // close position
return(0); // exit
}else
return(0);
}
well i found some creepy solution

i've allready attached
If you have some optimizing ideas for time shifting or optimizing ideas in the code at all, i will appreciate any suggestions thx in advance
