Opening one trade per candle or until a certain time passed

 
In an EA, the only problem is that it enters multiple trades on a single candle. I tried figuring out how to make it only take one trade per candle or give it some sort of time delay before making another trade, but with no avail.

can you help me to have only trade once per candle? It would really be appreciated.


Thank you in advance for your reply and help, any help is greatly apriciated.

Mike

 

M

See this thread https://www.mql5.com/en/forum/109887

Good Luck

-BB-

 

I add this code before conditions for trade, but this is not correct, can you help me,

if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)==true)
if(OrderCloseTime()>0)
if(OrderCloseTime()<iTime(NULL,0,0))
{ bool trade = True;}

 

i will tell you how i do this. I use variable Bars that returns number of bars in the current chart. I find it very handy here as it changes it's value everytime with new bar

1. create variable (for example) int currBars

2. use such expression:

if (currBars!=Bars)

{

//insert here anything you want to run only once per each candle, it will be executed at the begging of each candle, at the first tick


currBars=Bars;

}


hope it helps. If you need additional explanations let me know.

oromek

 
oromek wrote >>

i will tell you how i do this. I use variable Bars that returns number of bars in the current chart. I find it very handy here as it changes it's value everytime with new bar

1. create variable (for example) int currBars

2. use such expression:

if (currBars!=Bars)

{

//insert here anything you want to run only once per each candle, it will be executed at the begging of each candle, at the first tick

currBars=Bars;

}

hope it helps. If you need additional explanations let me know.

oromek

Thank you for your help

Mike

Reason: