synapticEx

ThreeDoves Strategy Long/Short Term - synapticex

I was trying to test the GalloBias indicator so I decided to create a basic strategy for it. Maybe it is a bit naive, because there is no proper risk management and explicit costs implemented in it. So keep in mind the probably won't work on a real account.
http://synapticex.com/

Notes:
DirectionGalloLength: it is the period input for GalloBias
DirectionGalloTF: it should be greater than the current Time Frame but not too much
EntryKamaLength and ConfirmationKamaLength are the period inputs for the relative kama MAs that function as a filter for the shorter term trend.
ROClength for the Rate of Change indicator used for entry, so a greater input will lead to less trades and viceversa.

Once the GalloBias finds the general trend the bot is allowed to take trades only in that direction and when kama confirms the same as soon as the roc cross the zero line.
Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Rumah. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?
//@version=2
//synapticex.com
DirectionGalloLength = input(15, minval=1) 
DirectionGalloTF = input(title="DirectionGalloTF", type=resolution, defval = "D")
EntryKamaLength = input(9, minval=1) 
ConfirmationKamaLength=input(4, minval=1) 
ROCLength=input(7, minval=1) 

gallo(length)=>
    volatility = sum(abs(close-close[1]), length)
    change = abs(close-close[length-1])
    er = iff(volatility != 0, change/volatility, 0)
    sc = pow((er*(0.666666-0.064516))+0.064516, 2)
    k = nz(k[1])+(sc*(hl2-nz(k[1])))
    
galloDir = security(tickerid,DirectionGalloTF, gallo(DirectionGalloLength))
galloA = sma(galloDir, 5)
kamaEn = security(tickerid,period,gallo(EntryKamaLength))
kamaConf = security(tickerid,period,gallo(ConfirmationKamaLength))

fillcolor = galloDir>galloA ? lime : galloDir==galloA ? gray : red
fill(plot(galloDir, color=fillcolor, title="GalloBias",transp=0, trackprice=false, style=line),plot(galloA, color=fillcolor, title="GalloBiasAverage",transp=0, trackprice=false, style=line), gray, transp=0)
plot(kamaEn, color=gray, title="EntryKama",transp=0, trackprice=false, style=line)
plot(kamaConf, color=red, title="kamaConfirmation",transp=0, trackprice=false, style=line)
roc = roc(close, ROCLength)

strategy("ThreeDoves", overlay=true, pyramiding=0, calc_on_every_tick=true, calc_on_order_fills=true)

buyEntry =  galloDir>galloA and roc[1]<0 and roc >0 and kamaConf > kamaEn
sellEntry = galloDir<galloA and roc[1]>0 and roc <0 and kamaConf < kamaEn

buyExit = galloDir<galloA or (roc[1]>0 and roc<0)
sellExit =  galloDir>galloA or (roc[1]<0 and roc>0)

if (buyEntry)
    strategy.entry("GALLOL", strategy.long, 5, comment="GALLO LONG")
else
    strategy.close("GALLOL", when=buyExit)

if (sellEntry)
    strategy.entry("GALLOS", strategy.short, 5, comment="GALLO SHORT")
else
    strategy.close("GALLOS", when=sellExit)