Hi, I have a Strategy which i find behaves differently from expected and I can’t figure it out.
its based on CCI crossings for entry points and appears to be entering a more often than I think it should.
SO I’ve attached the code and the chart with the problematic area. In the red rectangle is the area of interest, the purple circle shows two entry positions which have triggered whereas the variables I am drawing (entryup, entrydn, exit up, exit dn) in this case entry down do not appear to trigger. But I can’t see why or how a buy signal can be created without the necessary entrydn condition being met.
What am I doing wrong, it can’t be a PRC error. Thanks.
myCCI=CCI[20]
CCIMA=Average[20](myCCI)
crossCCIup = myCCI > CCIMA
crossCCIdn= myCCI < CCIMA
if longonmarket then
ccimaup = ccima > 70
ccimadn = ccima < -70
else
ccimaup = ccima > 10
ccimadn = ccima < -10
endif
Vup = mycci>mycci[1] and mycci[1] < mycci[2]
Vdn= mycci<mycci[1] and mycci[1] > mycci[2]
entryup= ccimaup and Vup
entrydn= ccimadn and Vdn
exitup = myCCI crosses under -100
exitdn = myCCI crosses over 100
if entryup then
buy 1 contract at market
SET STOP TRAILING SAR[0.02,0.02,0.09]
endif
if entrydn then
SELLSHORT 1 contract at market
SET STOP TRAILING SAR[0.02,0.02,0.09]
endif
GRAPH exitup coloured (255,0,0) as "Xup"
GRAPH exitdn*-1 coloured (155,0,0) as "Xdn"
GRAPH entryup coloured (0,255,0) as "UP"
GRAPH entrydn*-1 coloured (0,155,0,0)as "DN"
if exitup then
sell COUNTOFPOSITION contracts at market
endif
if exitdn then
EXITSHORT COUNTOFPOSITION contracts at market
endif
myCCI=CCI[20]
CCIMA=Average[20](myCCI)
Your strategy is based on CCI crossings for exits only.
It enters when there’s just a CCI peak.
Hi Roberto, that’s correct. Can you help explain why, in the purple circle in the image attached, there are two new down positions opened but in the chart “Backtest Variables” (where Entry up, Entry Down, Exit Up and Exit Down are displayed) there is zero value for Entry Down.
I would expect each new entry position to be triggered by the Entry Down or Entry Up variable which is zero in the two cases identified on the chart attached, There should be no entries as far as I can see, but the system enters down on two consecutive occasions with no apparent reason.
There must be either different price data or another trigger as yet unclear..
Thanks 🙂
Tell me what istrument, TF, date and time it is.
okay my bad…Only three of the variables were showing, for some reason I set the EntryDn variable to transparent. Often it helps just to explain to someone 😀 thanks.