Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © danielcantea
- //@version=5
- strategy("THE MATRIX KILLER", overlay=true, pyramiding = 0, slippage = 1, initial_capital = 100, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
- // Plot Cobra Metrics Table
- import EliCobra/CobraMetrics/4 as cobra
- disp_ind = input.string ("Equity" , title = "Display Curve" , tooltip = "Choose which data you would like to display", options=["Strategy", "Equity", "Open Profit", "Gross Profit", "Net Profit", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- pos_table = input.string("Bottom Right", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- type_table = input.string("Full", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- plot(cobra.curve(disp_ind))
- cobra.cobraTable(type_table, pos_table)
- // Time Range
- startTime = input.time(defval = timestamp("01 January 2018"), title = "Start Date")
- isInTimeRange = time >= startTime
- //////////////////////////////////////////////////////////////////////////Main indicators////////////////////////////////////////////////////////////////////////
- fastLength = input(title='MACD Fast Length', defval=9)
- slowLength = input(title='MACD Slow Length', defval=34)
- cycleLength = input(title='Cycle Length', defval=11)
- d1Length = input(title='1st %D Length', defval=1)
- d2Length = input(title='2nd %D Length', defval=4)
- src = close
- upper = 75
- lower = 25
- macd = ta.ema(src, fastLength) - ta.ema(src, slowLength)
- k = nz(fixnan(ta.stoch(macd, macd, macd, cycleLength)))
- d = ta.ema(k, d1Length)
- kd = nz(fixnan(ta.stoch(d, d, d, cycleLength)))
- stc = ta.ema(kd, d2Length)
- stc := math.max(math.min(stc, 100), 0)
- buySignal = ta.crossover(stc, lower)
- sellSignal = ta.crossunder(stc, upper)
- lensig = input.int(36, title="ADX Smoothing", minval=1, maxval=50)
- lenDmi = input.int(6, minval=1, title="DI Length")
- upD = ta.change(high)
- downD = -ta.change(low)
- plusDM = na(upD) ? na : (upD > downD and upD > 0 ? upD : 0)
- minusDM = na(downD) ? na : (downD > upD and downD > 0 ? downD : 0)
- trur = ta.rma(ta.tr, lenDmi)
- plus = fixnan(550 * ta.rma(plusDM, lenDmi) / trur)
- minus = fixnan(500 * ta.rma(minusDM, lenDmi) / trur)
- sum = plus + minus
- adx = 520 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
- long_condition = ta.cross(adx, plus)
- short_condition = ta.cross(adx, minus)
- // RTI
- trend_data_count = input.int(113, step=1, minval=10, title="Trend Length", inline = "RT", group="RTI")
- trend_sensitivity_percentage = input.int(95, step=1,minval=50, maxval=98,title='Sensitivity', inline = "RT1", group="RTI")
- upper_trend = close + ta.stdev(close, 2)
- lower_trend = close - ta.stdev(close, 2)
- upper_array = array.new<float>(0)
- lower_array = array.new<float>(0)
- for i = 0 to trend_data_count - 1
- upper_array.push(upper_trend[i])
- lower_array.push(lower_trend[i])
- upper_array.sort()
- lower_array.sort()
- upper_index = math.round(trend_sensitivity_percentage / 100 * trend_data_count) - 1
- lower_index = math.round((100 - trend_sensitivity_percentage) / 100 * trend_data_count) - 1
- UpperTrend = upper_array.get(upper_index)
- LowerTrend = lower_array.get(lower_index)
- RelativeTrendIndex = ((close - LowerTrend) / (UpperTrend - LowerTrend))*100
- //
- RTIlong = RelativeTrendIndex > 21
- RTIshort = RelativeTrendIndex < 30
- // RTIlong = ta.crossover(RelativeTrendIndex, 50)
- // RTIshort = ta.crossunder(RelativeTrendIndex, 50)
- // rsi
- rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
- rsiSourceInput = input.source(close, group="RSI Settings")
- uprsi = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
- downrsi = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
- rsi = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / downrsi))
- rsi2 = ta.rsi(close, 5)
- RSI_long = rsi2 > 50
- RSI_short = rsi2 < 50
- // RSI_long = ta.crossover(rsi2, 50)
- // RSI_short = ta.crossunder(rsi2, 50)
- // Loxx supertrend
- RMA(x, t) =>
- EMA1 = x
- EMA1 := na(EMA1[1]) ? x : (x - nz(EMA1[1])) * (1/t) + nz(EMA1[1])
- EMA1
- fdip(float srcloxx, int per, int speedin)=>
- float fmax = ta.highest(srcloxx, per)
- float fmin = ta.lowest(srcloxx, per)
- float lengthloxx = 0
- float diff = 0
- for i = 1 to per - 1
- diff := (nz(srcloxx[i]) - fmin) / (fmax - fmin)
- if i > 0
- lengthloxx += math.sqrt( math.pow(nz(diff[i]) - nz(diff[i + 1]), 2) + (1 / math.pow(per, 2)))
- float fdi = 1 + (math.log(lengthloxx) + math.log(2)) / math.log(2 * per)
- float traildim = 1 / (2 - fdi)
- float alpha = traildim / 2
- int speed = math.round(speedin * alpha)
- speed
- pine_supertrend(float srcloxx, float factor, int atrPeriod) =>
- float atr = RMA(ta.tr(true), atrPeriod)
- float upperBand = srcloxx + factor * atr
- float lowerBand = srcloxx - factor * atr
- float prevLowerBand = nz(lowerBand[1])
- float prevUpperBand = nz(upperBand[1])
- lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
- upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
- int directionloxx = na
- float superTrend = na
- float prevSuperTrend = superTrend[1]
- if na(atr[1])
- directionloxx := 1
- else if prevSuperTrend == prevUpperBand
- directionloxx := close > upperBand ? -1 : 1
- else
- directionloxx := close < lowerBand ? 1 : -1
- superTrend := directionloxx == -1 ? lowerBand : upperBand
- [superTrend, directionloxx]
- srcloxx = input.source(hl2, group = "Loxx")
- per = input.int(30, "Fractal Period Ingest", group = "Loxx")
- speed = input.int(20, "Speed", group = "Loxx")
- //Loxx input
- multloxx5 = input.float(7 , "1st Multiplier", group = "Loxx", step=1) //~using the same step as supertrend and *2 to test the robustness = 0.05*2 = 0.1
- multloxx2 = input.float(3 , "2rd Multiplier", group = "Loxx", step=1) //~
- adaptloxx = input.bool(true)
- masterdom = fdip(srcloxx, per, speed)
- int lenloxx = math.floor(masterdom) < 1 ? 1 : math.floor(masterdom)
- lenloxx := nz(lenloxx, 1)
- [supertrendloxx5, directionloxx] = pine_supertrend(srcloxx, multloxx5, adaptloxx ? lenloxx : per)
- [supertrendloxx2, directionloxx2] = pine_supertrend(srcloxx, multloxx2, adaptloxx ? lenloxx : per)
- loxx_long = close > supertrendloxx5
- loxx_short = close < supertrendloxx5
- loxx_long_2 = directionloxx2 == -1 and directionloxx2[1] == 1
- loxx_short_2 = close < supertrendloxx2
- // rough avg
- len = input.int(70, "Length", group = "Rough AVG")
- colbar = input.string("None", "Bar Coloring", ["None", "Trend", "Extremities", "Reversions"])
- revshow = input.bool(true)
- f_checkp() =>
- p = close
- count = 0
- while p > 1
- p /= 10
- count += 1
- math.pow(10, count)
- f_profile(len) =>
- l = len
- integral = 0.0
- f_x = math.abs(ta.rsi(close, len))
- for x = low / f_checkp() to high / f_checkp()
- integral := integral + f_x
- l * integral
- spacing_profile = f_profile(len)
- ra = ta.rsi(ta.ema(spacing_profile, len), len)
- roughlong = ra > 50
- roughshort = ra < 50
- // roughlong = ta.crossover(ra, 50)
- // roughshort = ta.crossunder(ra, 50)
- // {Gunzo} Trend Sniper
- float ma_source = input(title='MA Source', defval=close,group = "Trend Sniper Settings")
- int ma_length = input.int(title='MA Length', defval=28, minval=1,group = "Trend Sniper Settings")
- int smoothing_length = input.int(title='MA Smooth ', defval=10, minval=1, maxval=13,group = "Trend Sniper Settings")
- coefficient = ma_length / 3.0
- fn_calculate_wma_with_coefficient(source, length, coefficient) =>
- candle_weighted_sum = 0.0
- total_weight = 0.0
- for i = 0 to length by 1
- candle_weight = length - i
- candle_weighted_sum += (candle_weight - coefficient) * source[i]
- total_weight += candle_weight - coefficient
- total_weight
- weighted_line = candle_weighted_sum / total_weight
- [weighted_line]
- [weighted_line] = fn_calculate_wma_with_coefficient(ma_source, ma_length, coefficient)
- weighted_line_smooth = ta.ema(weighted_line, smoothing_length)
- trend_up = ta.crossover(weighted_line_smooth, weighted_line_smooth[1])
- // trend_down = ta.crossunder(weighted_line_smooth, weighted_line_smooth[1])
- // {Gunzo} Trend Sniper_2
- float ma_source2 = input(title='MA sni Source2', defval=close,group = "Trend Sniper Settings")
- int ma_length2 = input.int(title='MA sni Length2', defval=34, minval=1,group = "Trend Sniper Settings")
- int smoothing_length2 = input.int(title='MA sni Smooth2 ', defval=9, minval=1, maxval=13,group = "Trend Sniper Settings")
- coefficient2 = ma_length2 / 3.0
- fn_calculate_wma_with_coefficient2(source1, length2, coefficient2) =>
- candle_weighted_sum2 = 0.0
- total_weight2 = 0.0
- for i2 = 0 to length2 by 1
- candle_weight2 = length2 - i2
- candle_weighted_sum2 += (candle_weight2 - coefficient2) * source1[i2]
- total_weight2 += candle_weight2 - coefficient2
- total_weight2
- weighted_line2 = candle_weighted_sum2 / total_weight2
- [weighted_line2]
- [weighted_line2] = fn_calculate_wma_with_coefficient2(ma_source2, ma_length2, coefficient2)
- weighted_line_smooth2 = ta.ema(weighted_line2, smoothing_length2)
- trend_up2 = ta.crossover(weighted_line_smooth2, weighted_line_smooth2[1])
- //Hull
- // Inputs
- timeframe1=input.timeframe(defval ='1D', group = "Hull", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- modeSwitch = input.string("Thma", title="Hull Variation", options=["Thma"])
- length = input(192, title="Length(180-200 for floating S/R , 55 for swing entry)")
- lengthMult = input.float(1.0, title="Length multiplier (Used to view higher timeframes with straight band)")
- useHtf = input(false, title="Show Hull MA from X timeframe? (good for scalping)")
- htf = input("240", title="Higher timeframe")
- //FUNCTIONS
- src1 = request.security(syminfo.tickerid,timeframe1 ,close)
- //THMA
- //THMA(_src, _length) => ta.wma(ta.wma(_src,_length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length)
- THMA(_src, _length) => request.security(syminfo.tickerid,timeframe1 ,ta.wma(ta.wma(_src,_length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length))
- //SWITCH
- Mode(modeSwitch, src1, len) =>
- modeSwitch == "Thma" ? request.security(syminfo.tickerid,timeframe1,THMA(src1, len/2)) : na
- //OUT
- _hull = Mode(modeSwitch, src1, int(length * lengthMult))
- HULL = useHtf ? request.security(syminfo.tickerid, htf, _hull) : _hull
- MHULL = HULL[0]
- SHULL = HULL[2]
- HullLong = request.security(syminfo.tickerid,timeframe1 ,ta.crossover(MHULL, SHULL))
- HullShort = request.security(syminfo.tickerid,timeframe1 ,ta.crossover(SHULL, MHULL))
- //EFI
- // Inputs
- timeframeefi=input.timeframe(defval ='3D', group = "EFI", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- efilength = input.int(111, minval=1, group = "EFI")
- // Get high and low from selected timeframe instead of the one on the chart
- TFclose=request.security(syminfo.tickerid,timeframeefi , close)
- TFvolume=request.security(syminfo.tickerid,timeframeefi , volume)
- var cumVol = 0.
- cumVol += request.security(syminfo.tickerid,timeframeefi ,nz(volume))
- if barstate.islast and cumVol == 0
- runtime.error('Nope')
- efi = ta.ema(ta.change(TFclose) * TFvolume, efilength)
- efiLong = efi > 0
- efiShort = efi < 0
- // ***************************************************************************************************************************************************************
- // VR
- volatilityLower = input.float(title = "Lower Range", defval= -39, group = "VRG")
- volatilityHigher = input.float(title = "Higher Range", defval= 9)
- volatilityLength = 58
- volatilityRange = ta.sma(close - open, volatilityLength)
- //VR PARAMETERS
- VRL = volatilityRange > volatilityLower
- VRS = volatilityRange < volatilityHigher
- //VZO
- // inputs
- src0 = input.source(high, 'Source', group="VZO")
- len1 = input.float(17.25, 'VZO Length', minval=1, step=0.5, group="VZO")
- flen = input.float(3.5, 'Fisher Length', minval=1, step=0.5, group="VZO")
- ud = input.int(12, 'Updown val', group="VZO")
- var VZO_Intraday = input.bool(true, 'Smoothing', group="VZO")
- var repaint = input.bool(false, 'Allow Repainting', group="VZO")
- timeframe2=input.timeframe(defval ='4D', group="VZO", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- // Sauce
- get_close = request.security(syminfo.tickerid,timeframe2 , close[repaint ? 0 : 1])
- get_vol = request.security(syminfo.tickerid,timeframe2 , volume[repaint ? 0 : 1])
- sym = syminfo.tickerid
- VZO(length, get_close, vol) =>
- Volume_Direction = get_close > get_close[3] ? vol : -vol
- VZO_volume = request.security(syminfo.tickerid,timeframe2 , ta.linreg(Volume_Direction, int(length), 0))
- Total_volume = request.security(syminfo.tickerid,timeframe2 , ta.linreg(vol, int(length), 0))
- 100 * VZO_volume / Total_volume
- VZO_ = VZO(len, get_close, get_vol)
- if VZO_Intraday
- VZO_ := ta.ema(VZO_, 9)
- // Fish
- fsrc = VZO_
- MaxH = request.security(syminfo.tickerid,timeframe2 , ta.highest(fsrc, int(flen)))
- MinL = request.security(syminfo.tickerid,timeframe2 , ta.lowest(fsrc, int(flen)))
- var nValue1 = 0.0
- var nFish = 0.0
- nValue1 := 0.33 * 2 * ((fsrc - MinL) / (MaxH - MinL) - 0.5) + 0.67 * nz(nValue1[1])
- nValue2 = (nValue1 > 0.99 ? 0.999 : (nValue1 < -0.99 ? -0.999 : nValue1))
- nFish := 0.5 * math.log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
- f1 = nFish
- f2 = nz(nFish[1])
- stat = 0
- fzvzo_up = f1 > f2
- fzvzo_down = f1 < f2
- // Can use stat or fzvzoshort and fzvzoshort for firing buy/sell signals
- fzvzoshort = request.security(syminfo.tickerid,timeframe2 , ta.crossunder(f1, f2))
- fzvzolong = request.security(syminfo.tickerid,timeframe2 , ta.crossover(f1, f2))
- if fzvzolong
- stat := 1
- if fzvzoshort
- stat := -1
- //MACD
- // Inputs
- FastLength = input(title="MACD Fast Length", group="MACD", defval=44)
- Slowlength = input(title="MACD Slow Length", group="MACD", defval=95)
- MACDLength = input(title="MACD Signal Length", group="MACD", defval=31)
- timeframe3=input.timeframe(defval ='1D', group = "MACD", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- MACD = request.security(syminfo.tickerid,timeframe3 , ta.ema(close, FastLength)) - request.security(syminfo.tickerid,timeframe3 , ta.ema(close, Slowlength))
- aMACD = request.security(syminfo.tickerid,timeframe3 , ta.ema(MACD, MACDLength))
- delta = MACD - aMACD
- // Calculate Buy/Sell orders
- LongMACD = ta.crossover(delta, 0)
- ShortMACD = ta.crossunder(delta, 0)
- //
- length4 = input.int(46, minval=1, title="CCI LENGTH", group = "CCI")
- src_CCI = high
- //CALCULATIONS//
- ma = ta.sma(src_CCI, length4)
- cci = (src_CCI - ma) / (0.015 * ta.dev(src_CCI, length4))
- //TRADE CONDITIONS//
- CCI_LONG = cci >-90
- CCI_SHORT = cci < 90
- // Coral Trend
- sm =input(5, title="Smoothing Period", group = "CoralTrend")
- cd = input(2.6, title="Constant D", group = "CoralTrend")
- ribm=input(false, title="Ribbon Mode", group = "CoralTrend")
- timeframe4=input.timeframe(defval ='4D', group = "CoralTrend")
- //initialise vars
- var float i1 = na
- var float i2 = na
- var float i3 = na
- var float i4 = na
- var float i5 = na
- var float i6 = na
- src12=request.security(syminfo.tickerid,timeframe4, close)
- di = (sm - 1.0) / 2.0 + 1.0
- c1 = 2 / (di + 1.0)
- c2 = 1 - c1
- c3 = 3.0 * (cd * cd + cd * cd * cd)
- c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
- c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
- i1 := c1*src1 + c2*nz(i1[1])
- i2 := c1*i1 + c2*nz(i2[1])
- i3 := c1*i2 + c2*nz(i3[1])
- i4 := c1*i3 + c2*nz(i4[1])
- i5 := c1*i4 + c2*nz(i5[1])
- i6 := c1*i5 + c2*nz(i6[1])
- bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3)
- CoralLong = bfr > nz(bfr[1])?true:false
- CoralShort = bfr < nz(bfr[1])?true:false
- //INPUTS//
- length_AROON = input.int(13, minval=1, group = "AROON")
- //CALCULATIONS//
- upper1 = 100 * (ta.highestbars(high, length_AROON + 1) + length_AROON)/length_AROON
- lower1 = 100 * (ta.lowestbars(low, length_AROON + 1) + length_AROON)/length_AROON
- //TRADE CONDITIONS//
- AROON_LONG = upper1 > 94 and lower1 < 6
- AROON_SHORT = lower1 > 94 and upper1< 6
- // STOCHASTIC
- lengthK = input.int(10, "%K Length", minval = 1, maxval = 15000)
- lengthD = input.int(4, "%D Length", minval = -1, maxval = 4999)
- lengthEMA = input.int(13, "EMA Length", minval = 1, maxval = 4999)
- emaEma(source, length) => ta.ema(ta.ema(source, length), length)
- highestHigh = ta.highest(lengthK)
- lowestLow = ta.lowest(lengthK)
- highestLowestRange = highestHigh - lowestLow
- relativeRange = close - (highestHigh + lowestLow) / 2
- smi = 200 * (emaEma(relativeRange, lengthD) / emaEma(highestLowestRange, lengthD))
- EMAsmi = ta.ema(smi, lengthEMA)
- // LONG/SHORT STOCHASTIC
- StochasticLong = smi > EMAsmi
- StochasticShort = smi < EMAsmi
- length1 = input.int(6, minval=1)
- upper12 = 100 * (ta.highestbars(high, length+1) + length1)/length1
- lower12 = 100 * (ta.lowestbars(low, length+1) + length1)/length1
- long_Condition = ta.crossover(upper12,lower12)
- short_Condition = ta.crossunder(upper12,lower12)
- top = input.float(0.6, step=0.1)
- bottom = input.float(4, step=0.01)
- miningRevenue = request.security('QUANDL:BCHAIN/MIREV', 'D', close[1], barmerge.gaps_off, barmerge.lookahead_on)
- ma365 = request.security('QUANDL:BCHAIN/MIREV', 'D', ta.sma(close, 365)[1], barmerge.gaps_off, barmerge.lookahead_on)
- puellMultiple = miningRevenue / ma365
- smonadnu = puellMultiple < top
- smonavrhu = puellMultiple > bottom
- // User Inputsplot
- EEEEEE = input(37, 'LengthSTC', group="STC")
- BBBB = input(54, 'FastLengthSTC', group="STC")
- BBBBB = input(730, 'SlowLengthSTC', group="STC")
- AAA = input.float(0.19, title="STC Factor", group="STC", step = 0.01)
- // STC Calculations
- AAAA(BBB, BBBB, BBBBB) =>
- fastMA = ta.ema(BBB, BBBB)
- slowMA = ta.ema(BBB, BBBBB)
- AAAA = fastMA - slowMA
- AAAA
- AAAAA(EEEEEE, BBBB, BBBBB) =>
- var CCCCC = 0.0
- var DDD = 0.0
- var DDDDDD = 0.0
- var EEEEE = 0.0
- BBBBBB = AAAA(close, BBBB, BBBBB)
- CCC = ta.lowest(BBBBBB, EEEEEE)
- CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
- CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
- DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
- DDDD = ta.lowest(DDD, EEEEEE)
- DDDDD = ta.highest(DDD, EEEEEE) - DDDD
- DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
- EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
- EEEEE
- mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
- mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
- stc_low = mAAAAA < 50
- stc_high = mAAAAA > 50
- stc_long = mAAAAA > mAAAAA[1]
- stc_short = mAAAAA < mAAAAA[1]
- // ----- PSAR -----
- start = input.float(0.004, step=0.001, group = "PSAR")
- increment = input.float(0.009, step=0.001, group = "PSAR")
- maximum = input.float(0.5, step=0.01, group = "PSAR")
- out1 = ta.sar(start, increment, maximum)
- // plot(out, "ParabolicSAR", style=plot.style_cross, color=#2962FF)
- psarLong = out1 < close
- psarShort = out1 > close
- //Moving Average
- ma1 = ta.vwma(src,input.int(4, group = 'Moving Average'))
- malong = close > ma1
- mashort = close < ma1
- marise = ta.rising(ma1, 1)
- mafall = ta.falling(ma1, 1)
- // ----- QSTICK -----
- length2=input(4, group = "QSTICK")
- hline(0)
- s2=ta.sma((close-open),length2)
- qLong = s2 >= 0
- qShort = s2 < 0
- // RSI Strat
- rsiLen = input( 5 )
- rsiBot = input( 5 )
- rsiTop = input( 99 )
- price = close
- vrsi = ta.rsi(price, rsiLen)
- co = ta.crossover(vrsi, rsiTop)
- cu = ta.crossunder(vrsi, rsiBot)
- //RAVI
- LengthMAFast = input(19, title="Length MA Fast", group = "RAVI")
- LengthMASlow = input(65, title="Length MA Slow", group = "RAVI")
- TradeLine = input.float(0.14, title="Trade Line", step=0.01, group = "RAVI")
- xMAF = ta.sma(close, LengthMAFast)
- xMAS = ta.sma(close, LengthMASlow)
- xRAVI = ((xMAF - xMAS) / xMAS) * 100
- var float pos = na
- if xRAVI > TradeLine
- pos := 1
- else if xRAVI < TradeLine
- pos := -1
- else
- pos := nz(pos[1], 0)
- RAVILONG = (ta.crossover(xRAVI, TradeLine) and pos == 1)
- rAVISHORT = (ta.crossunder(xRAVI, TradeLine) and pos == -1)
- //TRIX Component
- TRIXLENGTH = input.int(67, minval=1, title = "TRIX Length", group = "TRIX")
- // Calculate TRIX
- trixValue = 10000 * ta.change(ta.ema(ta.ema(ta.ema(math.log(close), TRIXLENGTH), TRIXLENGTH), TRIXLENGTH))
- // Define long and short conditions
- TRIXLONG = ta.crossover(trixValue, 0)
- TRIXSHORT = ta.crossunder(trixValue, 0)
- //END TRIX
- //ICHIMOKU CLOUD component
- conversionPeriods = input.int(9, minval=1, title="Conversion Line Length", group = "ICHO")
- basePeriods = input.int(26, minval=1, title="Base Line Length", group = "ICHO")
- laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length", group = "ICHO")
- displacement = input.int(26, minval=1, title="Lagging Span", group = "ICHO")
- donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
- conversionLine = donchian(conversionPeriods)
- baseLine = donchian(basePeriods)
- leadLine1 = math.avg(conversionLine, baseLine)
- leadLine2 = donchian(laggingSpan2Periods)
- // Define buy and sell conditions
- ICHLONG = ta.crossover(conversionLine, baseLine) and close > leadLine1 and close > leadLine2
- ICHSHORT = ta.crossunder(conversionLine, baseLine) and close < leadLine1 and close < leadLine2
- //END ICHIMOKU CLOUD
- /// (buySignal and RSI_long ) //and (CoralLong and malong)
- //(sellSignal and RSI_short) //and (CoralShort or qShort) and (mafall or mashort ) or AROON_SHORT
- /////////
- longCondition = (buySignal and RSI_long ) and CoralLong and malong
- shortCondition = (sellSignal and RSI_short or rAVISHORT or TRIXSHORT and short_condition) and (CoralShort or qShort) and (mafall or mashort) or AROON_SHORT and RTIshort or HullShort
- //shortCondition = (sellSignal and RSI_short or rAVISHORT and short_condition) and (CoralShort or qShort) and (mafall or mashort) or AROON_SHORT and RTIshort or HullShort
- if barstate.isconfirmed and isInTimeRange and longCondition
- strategy.entry("Long", strategy.long)
- if barstate.isconfirmed and isInTimeRange and shortCondition
- strategy.entry("Short", strategy.short)
Advertisement
Comments
-
- download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement