Untitled

 avatar
unknown
plain_text
a year ago
2.8 kB
20
Indexable
//@version=5
strategy("BBands deneme Strategy", max_bars_back=5000, overlay=true, pyramiding=0, initial_capital=100, currency='NONE', default_qty_type=strategy.percent_of_equity, default_qty_value=1.0, commission_value=0.04, use_bar_magnifier=false)
source = close
length = input.int(20, minval=1)
mult = input.float(2.0, minval=0.001, maxval=50)
basis = ta.sma(source, length)
dev = mult * ta.stdev(source, length)
upper = basis + dev
lower = basis - dev
buyEntry = ta.crossover(source, lower)
sellEntry = ta.crossunder(source, upper)

/////////////////////////////////////////////////////////////////////////////////////
// Elliot Wave
src = input(close, title="source")
sma1length = input(5)
sma2length = input(35)
UsePercent = input.bool(true, "Show Dif as percent of current Candle") 
smadif= UsePercent ? (ta.sma(src, sma1length) - ta.sma(src, sma2length)) / src * 100 : ta.sma(src, sma1length) - ta.sma(src, sma2length)
elliotcol=smadif <= 0 ? color.red : color.green


///////////////////////////////////////////////////////////////////////////////////
// Hull MA Inputs
length_hullma = input.int(230, minval=1, title="HULLMA Length")
// Hull MA Calculation
src_hullma = close
hullma = ta.wma(2 * ta.wma(src_hullma, length_hullma / 2) - ta.wma(src_hullma, length_hullma), math.floor(math.sqrt(length_hullma)))

// Hull MA Color
hullma_color = close > hullma ? color.green : color.red
// Plotting
plot(hullma, title="Hull MA", color=hullma_color, linewidth=2)

buyCondition1 = elliotcol == color.green
buyCondition2 = sellEntry
buyCondition3 = hullma_color == color.green


sellCondition1 = elliotcol == color.red
sellCondition2 = buyEntry
sellCondition3 = hullma_color == color.red



buyConditionFinal = buyCondition1 and buyCondition2 and buyCondition3
sellConditionFinal = sellCondition1 and sellCondition2 and sellCondition3



if buyConditionFinal
    strategy.entry("BBandLE", strategy.long, stop=close, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE")
else
    strategy.cancel(id="BBandLE")

if sellConditionFinal
    strategy.entry("BBandSE", strategy.short, stop=close, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE")
else
    strategy.cancel(id="BBandSE")



//if sellConditionFinal
//	strategy.entry("BBandLE", strategy.long, stop=lower, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandLE")
//else
//	strategy.cancel(id="BBandLE")
//if buyConditionFinal
//	strategy.entry("BBandSE", strategy.short, stop=upper, oca_name="BollingerBands", oca_type=strategy.oca.cancel, comment="BBandSE")
//else
//	strategy.cancel(id="BBandSE")
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
Editor is loading...
Leave a Comment