Backtest with Ichimoku, Maximum 36 periods, ADX, MACD and stop with Ichimoku, MACD and %Williams
DEFPARAM CumulateOrders=False
DEFPARAM NOCASHUPDATE = False
REM Comprar/Comprare/Acheter/Buy
myKijun, myTenkan, myChikou, mySpanA, mySpanB = CALL "Ign Ichimoku 1"[0](close)
c1 = (Close > myTenkan)
c2 = (Close > myKijun)
c3 = (Close > mySpanA)
c4 = (Close > mySpanB)
c5 = (Close > Close[26])
c6 = (MACDline[12,26,9](close) > 0)
c61 = (MACDline[12,26,9](close) > MACDSignal[12,26,9](close))
c7 = (Close = highest[n] (close))
c8 = (ADX[14] > ADX[14][1])
c9 = (ADX[14] > DIminus[14](close))
c10 = (DIplus[14](close) > DIminus[14](close))
IF c1 and c2 and c3 and c4 and c5 and c6 and c61 and c7 and c8 and c9 and c10 THEN
BUY 1000 cash AT MARKET
ENDIF
coste = tradeprice
REM Vender/Vendere/Vendre/Sell
if (coste > myKijun) then
myStop = myTenkan
elsif (coste < myKijun) and (coste > mySpanB) then
myStop = myKijun
elsif (coste < mySpanB) then
myStop = mySpanB
endif
IF close < myStop or Williams[14](close) < -80 or MACDline[12,26,9](close) < 0 THEN
sell at market
//SELL AT myStop STOP
ENDIF
Hi! Thanks for sharing your trading strategy idea. Would you mind to tell us more about it please? What is the timeframe to be used? And for what instrument? It seems to work well on major trend, by looking at the picture you provide! 🙂
Line 13 is incorrect, MACDSignal is not a PRT recognised Indicator (it should be … it would make our lives easier!?)
Surely it can only work if coded as …
c61 = (MACDline[12,26,9](close)) > ExponentialAverage[9](MACDline[12,26,9](close))
MACDSIGNAL is now an instruction in PRTv11.
MACDsignal
I think we might be reaching the time where it would be useful if people mentioned the version number if they coded it on v11.
Dear Nicolas,
Only for Weekly, confirmed with monthly.
I send you a indicator than can help you for decissions.
I work only with sotcks and I select only the best stocks for financials, growth and moat.
If you need something else write me.
I apologize for my bad english. I’m spanish 😉
I backtested more and I changed a few things.
Now the code is enhanced.
I work on weekly, but I compare each signal with monthly for confirmation.
Anybody else tried this on v10.3?
Trying with the latest codes above, I get the attached errors. (The original code on the original post had similar errors also).
Even if I include below then more errors messages show … e.g. cc is not used.
If MyChikou or my0 OR Mybs or mybi or mycoste Then
Endif
@inavsan does the above code work perfectly fine on your Platform??
Update:
I’ve got it working now after making a few changes here and there.
I will post the amended code shortly … results looks good!!
ZigoParticipant
Master
Ichimoku is a very good indicator on its own. I think it doesn’t need any other indicator.
Therfore I have tested it without Macd and ADX (green) (c1, c2, c3, c4 and c5)
and also with Macd and ADX (bleu) (c1, c2, c3, c4, c5, c6, c61, c7, c8, c9 and c10)
DEFPARAM CumulateOrders=False
DEFPARAM NOCASHUPDATE = False
once n= 9
once m= 3*n-1
REM Comprar/Comprare/Acheter/Buy
myTenkan=(highest[n](high)+lowest[n](low))/2
myKijun=(highest[m](high)+lowest[m](low))/2
myspanA=(myTenkan+myKijun)/2
mySpanB=(highest[2*m](high)+lowest[2*m](low))/2
c1 = (Close > myTenkan)
c2 = (Close > myKijun)
c3 = (Close > mySpanA)
c4 = (Close > mySpanB)
c5 = (Close > Close[26])
IF c1 and c2 and c3 and c4 and c5 THEN
BUY 1 contract AT MARKET
ENDIF
coste = tradeprice
REM Vender/Vendere/Vendre/Sell
if (coste > myKijun) then
myStop = myTenkan
elsif (coste < myKijun) and (coste > mySpanB) then
myStop = myKijun
elsif (coste < mySpanB) then
myStop = mySpanB
endif
IF close < myStop or Williams[14](close) < -80 or MACDline[12,26,9](close) < 0 THEN
sell at market
//SELL AT myStop STOP
ENDIF
Thank You inavsan for sharing your code with us all … jolly decent of you! 🙂
Results attached with spread = 7.
If you make improvements, please post here.
How long term … you don’t show bottom line so we cant see how many years? 🙂
Do you mean 200k bars and what is the TF – 3 uren … is that 3 hours?
ZigoParticipant
Master
DEFPARAM CumulateOrders=False
DEFPARAM NOCASHUPDATE = False
once n= 9
once m= 3*n-1
REM Comprar/Comprare/Acheter/Buy
myTenkan=(highest[n](high)+lowest[n](low))/2
myKijun=(highest[m](high)+lowest[m](low))/2
myspanA=(myTenkan+myKijun)/2
mySpanB=(highest[2*m](high)+lowest[2*m](low))/2
c1 = (Close > myTenkan)
c2 = (Close > myKijun)
c3 = (Close > mySpanA)
c4 = (Close > mySpanB)
c5 = (Close > Close[26])
c6 = Close < mytenkan
c7 = close < myKijun
c8 = close < mySpanA
c9 = close < mySpanB
c10= close < close[26]
IF c1 and c2 and c3 and c4 and c5 THEN
BUY 1 contract AT MARKET
ENDIF
coste = tradeprice
REM Vender/Vendere/Vendre/Sell
if (coste > myKijun) then
myStop = myTenkan
elsif (coste < myKijun) and (coste > mySpanB) then
myStop = myKijun
elsif (coste < mySpanB) then
myStop = mySpanB
endif
IF close < myStop or Williams[14](close) < -80 or MACDline[12,26,9](close) < 0 THEN
sell at market
//SELL AT myStop STOP
ENDIF
If c6 and c7 and c8 and c9 and c10 then
sellshort 1 contract at market
endif
//Kost Verkoop is KV
KV = Tradeprice
if (KV < myKijun) then
myStop = myTenkan
elsif (KV > myKijun) and (KV < mySpanB) then
myStop = myKijun
elsif (KV > mySpanB) then
myStop = mySpanB
endif
IF close < myStop or Williams[14](close) < -80 or MACDline[12,26,9](close) < 0 THEN
sell at market
//SELL AT myStop STOP
ENDIF
Dear Grahal,
I only work weekly.
My backtests are made from the begin of data (about 1995) from the last dat available.
I only work with V11.