If you want maximum one trade per bar, can I suggest having a “stoptime”?
In the fapturbo longterm settings, you can set the stoptime, which is the amount of time the robot rests after the first trade before it makes another trade. And it’s in minutes. So if you want your robot to trade on an M15 chart, you might want to put 15 (15 minutes) for the stoptime. I hope this helps.
thx for replying…
but i don’t want to using stop time, because i want it 's automatic based of timeframe that we choose… example if we choose 1 hour, so the ea automatic open 1 trade / 1 hour, if choose 15 minutes, so 1 trade per 15 minutes…
i see many forum using code like :
tetime Timestamp = 0;
if (barsPrev != Bars) {
// trade
barsPrev = Bars;
} else {
// no trade
}
or like
bool opened_on_current_bar = false;
for (int i = OrdersTotal() - 1; i >=0; i-- ) {
if ( ! OrderSelect( i, SELECT_BY_POS ) )
continue;
if ( OrderOpenTime() >= Time[ 0 ] ) {
opened_on_current_bar = true;
break;
}
}
// Here the variable opened_on_current_bar is set appropriately
but all of that can not work… still display many position per bar…
i don’t know where is wrong…
But the stoptime would work, you just have to change it in the settings every time to switch to another time frame. 1 hour would just be stoptime = 60.
Sorry, I actually can’t. I’m a total noober at coding. Really sorry. I wish I took time into learning.
New_Bar function is a pretty standard function used to detect a new bar on the charts.
Also you should normalise your doubles and I have also included code to make provision for 2/3/4/5 digit brokers/instruments, which should become standard in all your coding efforts.