How do I make it such that only one order can be made in one particular time frame?
i do not understand what you mean,
do you have 2 ea's in different timeframes or one ea with multiple idicators?
daywatch:
How do I make it such that only one order can be made in one particular time frame?
How do I make it such that only one order can be made in one particular time frame?
Use orderSelect loop. You need a different magic number per time frame or one magic number plus comment.
init(){ ...
/*++++ Adjust for the current chart timeframe */{ static
int tf[] = { PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30,
PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1,
PERIOD_MN1 }; static
string TFtext[] = { "M1", "M5", "M15", "M30",
"H1", "H4", "D1", "W1",
"MN1" };
for(int index=0; tf[index] < Period(); index++){}
Period.text = TFtext[index];
magic.number = Magic.Number.Base + index;
magic.number.max = Magic.Number.Base + ArraySize(tf)-1;
/*---- Adjust for the current chart timeframe */}
...
}
for(int pos = OrdersTotal() - 1; pos >= 0; pos--) if (
OrderSelect(pos, SELECT_BY_POS) // Only my orders w/
&& OrderMagicNumber() == Magic.Number // my magic number
&& OrderSymbol() == Symbol() ){ // and period and symbol
return; // Only allow one per time frame.
}
daywatch:
This rule should be enforced even when an order made in the same time frame is closed.
Huh? If the order is closed, there are zero orders in the time frame.
This rule should be enforced even when an order made in the same time frame is closed.
How do I make it such that only one order can be made in one particular time frame?
This rule should be enforced even when an order made in the same time frame is closed.