Hi,
I would like to setup several trading times per day.
With the simplified creation you can only set up one time to not trade before and one time to not trade after (ie. trade between 6am – 4pm)
However, I would like to have no trading from midnight until 6am. Then trade from 6am – 11am. No trading between 11am-12pm. And then trading between 12pm – 5:30pm.
I tried to create a code but it doesn’t work. So there must be a mistake.
Any help very much appreciated.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Cancel all pending orders and close all positions at the "FLATAFTER" time
DEFPARAM FLATAFTER = 173000
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryBeforeTime = 060000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 11000
timeEnterAfter = time < noEntryAfterTime
noEntryBeforeTime2 = 120000
timeEnterBefore2 = time >= noEntryBeforeTime2
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime2 = 173000
timeEnterAfter2 = time < noEntryAfterTime2
line 11 misses a final “0”
There you go:
IF time >= 090000 AND time <= 110000 THEN //trade from 9 to 11
TradingON = 1
ELSIF time >= 130500 AND time <= 150000 THEN //trade from 13:05 to 15
TradingON = 1
ELSIF time >= 163000 AND time <= 190000 THEN //trade from 16:30 to 19
TradingON = 1
ELSE
TradingON = 0 //do not trade outside above time ranges
ENDIF
Add TradingON to your conditions to enter a trade.
Thank you very much Roberto!
Hi.
I need this Code… But i need that os operation is opened un a period It will remain open when periodo is closed.
And that can open a position un another period and accumulate with the previous one.
Thanks!
Link to above Roberto code added as Log 173 here …
Snippet Link Library