#pine-script #algorithmic-trading
#сосна-сценарий #алгоритмическая торговля
Вопрос:
Я пытаюсь создать супертренд на 3 разных таймфреймах, но я не смог добавить выбор таймфрейма к супертрендам. Случайно я добавляю, но это не сработало. Кто-нибудь может помочь ?
Есть несколько кодов «вход.разрешение» , «временные рамки.период» , «безопасность ()», но я не знаю, как их использовать.
Я пишу проблемные строки в // ПРОБЛЕМА. Код работает, но бесполезен.
Спасибо.
""// SuperTrends inputs stInputSrc = input(hl2, title="SuperTrend Source") stSlowInputRes = input(60, "Slow SuperTrend Resolution", minval=1) // PROBLEM stSlowInputLength = input(10, "Slow SuperTrend Length", minval=1) stSlowInputMult = input(3, "Slow SuperTrend Multiplier", minval=1) stMedInputRes = input(15, "Med SuperTrend Resolution", minval=1) // PROBLEM stMedInputLength = input(10, "Med SuperTrend Length", minval=1) stMedInputMult = input(3, "Med SuperTrend Multiplier", minval=1) stFastInputRes = input(1, "Fast SuperTrend Resolution", minval=1) // PROBLEM stFastInputLength = input(10, "Fast SuperTrend Length", minval=1) stFastInputMult = input(3, "Fast SuperTrend Multiplier", minval=1) stInputchangeATR= input(title="Alternate SuperTrend ATR Calculation?", type=input.bool, defval=true) // SuperTrend Function superTrend(period, src, mult, chgATR, resolutionn) =gt; // MOST PROBLEM res = input("resolutionn", type=input.resolution) // MOST PROBLEM stATRSmooth = sma(tr, period) // tr = true range stATR = chgATR ? atr(period) : stATRSmooth // select ATR to use stUP = src - (mult * stATR) // up value stUP1 = nz(stUP[1], stUP) // prev candle value if not 0 stUP := close[1] gt; stUP1 ? max(stUP,stUP1) : stUP // select the larger up value if close is higher than previous up value stDN = src (mult * stATR) stDN1 = nz(stDN[1], stDN) stDN := close[1] lt; stDN1 ? min(stDN, stDN1) : stDN stTrend = 1 stTrend := nz(stTrend[1], stTrend) stTrend := stTrend == -1 and close gt; stDN1 ? 1 : stTrend == 1 and close lt; stUP1 ? -1 : stTrend stBuySignal = stTrend == 1 and stTrend[1] == -1 stSellSignal = stTrend == -1 and stTrend[1] == 1 stChangeCond = stTrend != stTrend[1] [stUP, stDN, stTrend, stBuySignal, stSellSignal, stChangeCond] // Data Calculation // *************************************************** // SuperTrend Slow [stSlowUP, stSlowDN, stSlowTrend, stSlowBuy, stSlowSell, stSlowChanged] = superTrend(stSlowInputLength, stInputSrc, stSlowInputMult, stInputchangeATR, stSlowInputRes) // PROBLEM // SuperTrend Medium [stMedUP, stMedDN, stMedTrend, stMedBuy, stMedSell, stMedChanged] = superTrend(stMedInputLength, stInputSrc, stMedInputMult, stInputchangeATR, stMedInputRes) // PROBLEM // SuperTrend Fast [stFastUP, stFastDN, stFastTrend, stFastBuy, stFastSell, stFastChanged] = superTrend(stFastInputLength, stInputSrc, stFastInputMult, stInputchangeATR, stFastInputRes) // PROBLEM // Thanks mel0n for most of this code.
«»