Please help, the back test working , but not working on demo trade.
When doing back test, I can graph count and checked that when count = 3 then it stop trading for whole remaining day. However, I cannot graph “count” during demo trade and check it why the trade is not stopped.
I use this function to stop whole remaining day trading if stop lost 3 times.
if IntradayBarIndex = 0 then
count = 0
endif
if strategyprofit - strategyprofit[1] = -800 then
count = count + 1
endif
IF count < 3 and ((c1 and c10 and C11) or (c1 and C20) or (c20 and c10 and c11)) THEN
BUY 1 CONTRACT AT MARKET
ENDIF
It’s very rare that a loss is exactly 800 currency units, I suggest that you replace line 5 with:
if strategyprofit - strategyprofit[1] <= -800 then
Any suggested code for counting number of stop loss? I just wanna to stop remaining day trading when stop loss up to 3 times.
As I set stop loss at -800 currency unit, it is work in the back test result.
You can use this, without any constant value:
if strategyprofit < strategyprofit[1] then
JSParticipant
Senior
Hi @jackjour,
Try this:
if IntradayBarIndex = 0 then
count = 0
endif
if TradePrice * PositionPerf < -800 then
count = count + 1
endif
IF count < 3 and ((c1 and c10 and C11) or (c1 and C20) or (c20 and c10 and c11)) THEN
BUY 1 CONTRACT AT MARKET
ENDIF