Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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(5 , "1st Multiplier", group = "Loxx", step=0.1) //~using the same step as supertrend and *2 to test the robustness = 0.05*2 = 0.1
- multloxx2 = input.float(2 , "2nd Multiplier", group = "Loxx", step=0.1) //~
- multloxx3 = input.float(3 , "3rd Multiplier", group = "Loxx", step=0.1) //~
- multloxx1825 = input.float(1.825, "4th Multiplier", group = "Loxx", step=0.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)
- [supertrendloxx3, directionloxx3] = pine_supertrend(srcloxx, multloxx3, adaptloxx ? lenloxx : per)
- [supertrendloxx2, directionloxx2] = pine_supertrend(srcloxx, multloxx2, adaptloxx ? lenloxx : per)
- [supertrendloxx1825, directionloxx1825] = pine_supertrend(srcloxx, multloxx1825, adaptloxx ? lenloxx : per)
- // loxx_long = directionloxx == -1 and directionloxx[1] == 1
- // loxx_short = directionloxx == 1 and directionloxx[1] == -1
- loxx_long = close > supertrendloxx5
- loxx_short = close < supertrendloxx5
- loxx_long_2 = directionloxx2 == -1 and directionloxx2[1] == 1
- loxx_short_2 = directionloxx == 1 and directionloxx[1] == -1
- loxx_long_3 = directionloxx3 == -1 and directionloxx3[1] == 1
- loxx_short_3 = close < supertrendloxx3
- loxx_long_1_825 = close > supertrendloxx1825
- loxx_short_1_825 = close < supertrendloxx1825
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement