Forums › ProRealTime English forum › ProOrder support › MTF – one trade per bar › Reply To: MTF – one trade per bar
04/10/2019 at 8:36 AM
#95908
On which TF, 10-minute or 1-second?
On 1-second TF it is impossible to acrivate more than one order each bar, since strategies are executed when a bar closes, so another trade could only be opened the next bar, not the same one.
On a 10-minute TF you should add, at the very beginning of that code (provided UPDATEONCLOSE is used):
|
1 2 3 4 5 |
IF Not OnMarket THEN BarCount = 0 ELSE BarCount = BarCount + 1 ENDIF |
Next, at the very beginning of the code on your 1-second TF, add:
|
1 2 3 4 5 6 7 8 |
ONCE TradeON = 1 IF IntraDayBarIndex = 0 THEN TradeON = 1 ENDIF TradeBar = BarCount IF Not OnMarket AND TradeBar <> TradeBar[1] THEN TradeON = 1 ENDIF |
Then add TradeON to your conditions to enter a trade and clear it to avoid further trading until the next 10-minute bar:
|
1 2 3 4 |
IF MyConditions AND Not OnMarket AND TradeON THEN BUY/SELLSHORT... TradeON = 0 ENDIF |
edited on May 5th, 2021:
lines
|
1 2 3 4 5 |
IF Not OnMarket THEN BarCount = 0 ELSE BarCount = BarCount + 1 ENDIF |
do not work properly and should be replaced by this single line:
|
1 |
BarCount = BarIndex |