क्रॉडल का सुपरट्रेंड

लेखक:चाओझांग, दिनांकः 2022-05-13 17:38:34
टैगःएसएमएईएमएएसएमएमएडब्ल्यूएमएवीडब्ल्यूएमए

यह सूचक पुष्टि के रूप में 3 विभिन्न इनपुट के साथ सुपरट्रेंड का उपयोग कर रहा है और साथ ही 200 ईएमए जो हमें ऊपर या नीचे की प्रवृत्ति के लिए डेटा देगा। तो यह स्टॉक संकेतक की तलाश कर रहा है कि यह पुष्टि करने के लिए कि क्या लंबी के लिए 30 से नीचे और छोटी के लिए 70 से ऊपर का क्रॉस है।

बैकटेस्ट

img


/*backtest
start: 2022-05-05 00:00:00
end: 2022-05-11 23:59:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// Visit Crodl.com for our Premium Indicators
// https://tradingbot.crodl.com to use our free tradingview bot to automate any indicator.
//@version=5
indicator("Crodl's Supertrend", overlay=true, timeframe="", timeframe_gaps=true)

atrPeriod1 = input(12, "ATR1 Length")
factor1 = input.float(3.0, "Factor1", step = 0.01)

[supertrend1, direction1] = ta.supertrend(factor1, atrPeriod1)

bodyMiddle1 = plot((open + close) / 2, display=display.none)
upTrend1 = plot(direction1 < 0 ? supertrend1 : na, "Up1 Trend", color = color.green, style=plot.style_linebr)
downTrend1 = plot(direction1 < 0? na : supertrend1, "Down1 Trend", color = color.red, style=plot.style_linebr)

atrPeriod2 = input(11, "ATR2 Length")
factor2 = input.float(2.0, "Factor2", step = 0.01)

[supertrend2, direction2] = ta.supertrend(factor2, atrPeriod2)

bodyMiddle2 = plot((open + close) / 2, display=display.none)
upTrend2 = plot(direction2 < 0 ? supertrend2 : na, "Up2 Trend", color = color.green, style=plot.style_linebr)
downTrend2 = plot(direction2 < 0? na : supertrend2, "Down2 Trend", color = color.red, style=plot.style_linebr)

atrPeriod3 = input(10, "ATR3 Length")
factor3 = input.float(1.0, "Factor3", step = 0.01)

[supertrend3, direction3] = ta.supertrend(factor3, atrPeriod3)

bodyMiddle3 = plot((open + close) / 2, display=display.none)
upTrend3 = plot(direction3 < 0 ? supertrend3 : na, "Up3 Trend", color = color.green, style=plot.style_linebr)
downTrend3 = plot(direction3 < 0? na : supertrend3, "Down3 Trend", color = color.red, style=plot.style_linebr)

len = input.int(200, minval=1, title="Length")
src = input(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out = ta.ema(src, len)
plot(out, title="EMA", color=color.white,linewidth=2, offset=offset)

ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing")
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing")

smoothingLine = ma(out, smoothingLength, typeMA)
plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=offset, display=display.none)
//////
l = input(13, title='Length')
l_ma = input(7, title='MA Length')
t = math.sum(close > close[1] ? volume * (close - close[1]) : close < close[1] ? volume * (close - close[1]) : 0, l)
m = ta.sma(t, l_ma)


//////
periodK = input.int(14, title="%K Length", minval=1)
smoothK = input.int(1, title="%K Smoothing", minval=1)
periodD = input.int(3, title="%D Smoothing", minval=1)
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)

stochbuy= float(k) < 30  and ta.crossover(k,d)
stochsell=float(k) > 70  and ta.crossover(d,k) 

long =(( ((direction1 < 0 and direction2 < 0 ) or (direction2 < 0  and direction3 < 0 ) and (direction1 < 0 or direction3 < 0 ) )and open > out) and t > 0) and stochbuy 
short=(( ((direction1 > 0 and direction2 > 0 ) or (direction2 > 0  and direction3 > 0 ) and (direction1 > 0 or direction3 > 0 ) )and open < out) and t < 0) and stochsell

plotshape(long, title = "Long Signal", location=location.belowbar, style=shape.labelup, color=color.green, textcolor=color.white, size=size.small, text="Long")
plotshape(short, title = "Short Signal", location=location.abovebar, style=shape.labeldown, color=color.red, textcolor=color.white, size=size.small, text="Short")

alertcondition(long, title='Long Signal', message=' Buy')
alertcondition(short, title='Short Signal', message=' Sell')

if long
    strategy.entry("Enter Long", strategy.long)
else if short
    strategy.entry("Enter Short", strategy.short)

संबंधित

अधिक