I have created a script for trading the US TECH 100-CFD. I use SMA Daily Charts as entry and exit criteria. Is it possible to create a code that uses the opening hours of the underlying market, which are 09:30:00-22:00:00, instead of the CFD opening hours for backtesting and automatic trading?
Takk…Unknown command for “CALCULATEONLASTBARS = 200”.
That command is not available for strategies.
If you want to embed that code into your strategy then you have to use these lines, choosing your preferred settins (Periods, StartTime and EndTime):
Periods = 20
StartTime = 090000
EndTime = 180000
i = 0
TRSMA = 0
FOR j = 0 TO 3000
IF opentime[j] >= StartTime AND opentime[j] <= EndTime THEN
TRSMA = TRSMA + close[j]
i = i + 1
IF i = Periods THEN
BREAK
ENDIF
ENDIF
NEXT
TRSMA = (TRSMA / Periods)
IF TRSMA = 0 THEN
TRSMA = close
ENDIF
then use variable TRSMA to know the value.
Alternatively, you can call the indicator using the CALL statement, as follows:
TRSMA = CALL "TRSMA - Time Range SMA"[20, 90000, 240000]
changing the values 20, 90000 (it would be 090000, but leading zeros are ignored) and 240000 as you like.