Hi, I have a trading system which appears not to want to EXITSHORT. Which is clearly very strange. what am i missing here?
Am certain the exitdn condition is triggered as other variables in the if statement are being correctly affected (position is reset to its initial value) and the exitdn boolean is true at the expected time. however the EXITSHORT is not executing: the position size is unaffected and so the position’s losses are unusually large.
I may have read the outcome incorrectly and it is in actual fact executing, but then why is the positionsize not zero?
For BUY, SELL and SELL SHORT the system behaves as expected: overall position size adjusted, new position entry size decreased (the system takes a large initial stake and then decreases new stake position size each time until 1 or the exit is tirggered and so a reset to initial)
On the screenshot we see EURCAD 5min on Friday 22nd Jan at 16:15. At 16:10 the CCI crossed over the 100 line which is an exit short condition in this system. At 16:20 the Positions should have gone down to zero. on the user variables chart the blue variable Position (new entry size) is reset to initial value 5. The variable Xdn is set to 1 indicating an exit down criteria has been met, so the contents of the if condition should all be executed.
I tried with EXITSHORT and with BUY, same inaction both times.
Will keep looking and any suggestions questions welcome 🙂
Thank you.
myCCI=CCI[20]
CCIMA=Average[20](myCCI)
initialposition = 5
if onmarket then
ccimaup = ccima > 70
ccimadn = ccima < -70
else
ccimaup = ccima > 10
ccimadn = ccima < -10
position = initialposition
endif
Vup = mycci>mycci[1] and mycci[1] < mycci[2] and mycci>0// \/
Vdn= mycci<mycci[1] and mycci[1] > mycci[2]and mycci<0// /\
entryup= ccimaup and Vup
entrydn= ccimadn and Vdn
exitup = myCCI crosses under -100 and longonmarket
exitdn = myCCI crosses over 100 and shortonmarket
if entryup then
buy position contract at market
SET STOP TRAILING SAR[0.02,0.02,0.09]
if position >1 then
position = position -1
endif
endif
if entrydn then
SELLSHORT position contract at market
SET STOP TRAILING SAR[0.02,0.02,0.09]
if position >1 then
position = position -1
endif
endif
GRAPH exitup*-1 coloured (255,0,0) as "Xup"
GRAPH exitdn coloured (155,0,0) as "Xdn"
GRAPH entryup coloured (0,255,0) as "UP"
GRAPH entrydn*-1 coloured (0,200,0)as "DN"
GRAPH position coloured (0,0,200) as "Position"
if exitup then
SELL COUNTOFPOSITION contract at market
position = initialposition
endif
if exitdn then
EXITSHORT COUNTOFPOSITION contract at market
//BUY COUNTOFPOSITION contract at market
position = initialposition
endif