Conversion Force Index with ATR from TradingView
Forums › ProRealTime forum Italiano › Supporto ProBuilder › Conversion Force Index with ATR from TradingView
- This topic has 3 replies, 3 voices, and was last updated 1 month ago by robertogozzi.
-
-
09/18/2024 at 7:01 AM #237739
Hello,
I can’t manage to convert the Elder’s Force Index indicator with 3 ATR on my own. The indicator displays the FI with its ATRs, and when the FI is outside the 3rd ATR, it shows a dot to indicate that it’s overbought or oversold. Is anyone able to help me?Thank you very much.Original Indicator URL : https://www.tradingview.com/script/GNbQ24KL-Elder-Force-Index-With-ATR-Channels-loxx/Salve,
Non riesco a convertire da solo l’indicatore Elder’s Force Index con 3 ATR. L’indicatore mostra l’FI con i suoi ATR e quando l’FI è al di fuori del 3° ATR, mostra un punto per indicare che è ipercomprato o ipervenduto. Qualcuno può aiutarmi?Grazie mille.
URL indicatore originale:http://www.tradingview.com/script/GNbQ24KL-Elder-Force-Index-With-ATR-Channels-loxx/
CODE:
//@version=5
indicator(title=‘Elder Force Index With ATR Channels [loxx]’, shorttitle=‘EFIATR [loxx]’, format=format.volume, timeframe=“”, timeframe_gaps=true, max_bars_back = 5000)RMA(x, t) =>
EMA1 = x
EMA1 := na(EMA1[1]) ? x : (x – nz(EMA1[1])) * (1/t) + nz(EMA1[1])
EMA1EMA(x, t) =>
EMA1 = x
EMA1 := na(EMA1[1]) ? x : (x – nz(EMA1[1])) * (2 / (t + 1)) + nz(EMA1[1])
EMA1
_bpDom(len, bpw, mult) =>
HP = 0.0
BP = 0.0
Peak = 0.0
Real = 0.0
counter = 0.0
DC = 0.0
alpha2 = (math.cos(0.25 * bpw * 2 * math.pi / len) + math.sin(0.25 * bpw * 2 * math.pi / len) – 1) / math.cos(0.25 * bpw * 2 * math.pi / len)
HP := (1 + alpha2 / 2) * (close – nz(close[1])) + (1 – alpha2) * nz(HP[1])
beta1 = math.cos(2 * math.pi / len)
gamma1 = 1 / math.cos(2 * math.pi * bpw / len)
alpha1 = gamma1 – math.sqrt(gamma1 * gamma1 – 1)
BP := 0.5 * (1 – alpha1) * (HP – nz(HP[2])) + beta1 * (1 + alpha1) * nz(BP[1]) – alpha1 * nz(BP[2])
BP := bar_index == 1 or bar_index == 2 ? 0 : BP
Peak := 0.991 * Peak
Peak := math.abs(BP) > Peak ? math.abs(BP) : Peak
Real := Peak != 0 ? BP / Peak : Real
DC := nz(DC[1])
DC := DC < 6 ? 6 : DC
counter := counter[1] + 1
if ta.crossover(Real, 0) or ta.crossunder(Real, 0)
DC := 2 * counter
if 2 * counter > 1.25 * nz(DC[1])
DC := 1.25 * DC[1]
if 2 * counter < 0.8 * nz(DC[1])
DC := 0.8 * nz(DC[1])
counter := 0
temp_out = mult * DC
temp_out//inputs
src = input.source(close, title = “Source”, group = “Basic Settings”)
calc_type = input.string(“Fixed”, title = “Calculation Type”, options =[“Fixed”, “Band-pass Dominant Cycle”], group = “Basic Settings”)len = input.int(13, title = “Fixed EFI Period”, group = “Fixed Settings”)
slen = input.int(21, title=‘Fixed Signal Period’, group = “Fixed Settings”)
atr_sm = input.int(21, title =“Fixed ATR Smoothing Length”, group = “Fixed Settings”)bp_period = input.int(13, “Band-pass Period”, minval = 1, group = “Band-pass”)
bp_width = input.float(0.20, “Band-pass Width”, step = 0.1, group = “Band-pass”)
cycle_len = input.float(100, “Signal and ATR Percent of Dominant Cycle (%)”, step = 1.0, group = “Band-pass”)/100
efi_reduction = input.float(75, “EFI Percent of Dominant Cycle (%) “, step = 1.0, group = “Band-pass”)/100len_out_fast = int(nz(_bpDom(bp_period, bp_width, efi_reduction), 1)) < 1 ? 1 : int(nz(_bpDom(bp_period, bp_width, efi_reduction), 1))
len_out_slow = int(nz(_bpDom(bp_period, bp_width, cycle_len), 1)) < 1 ? 1 : int(nz(_bpDom(bp_period, bp_width, cycle_len), 1))atr_mult1 = input.int(1, title = “ATR Mult Level 1”, group = “ATR Multipliers”)
atr_mult2 = input.int(2, title = “ATR Mult Level 2”, group = “ATR Multipliers”)
atr_mult3 = input.int(3, title = “ATR Mult Level 3”, group = “ATR Multipliers”)trunc_atr = input.bool(true, title = “Truncate over ATR Mult Level 4?”, group = “UI Options”)
//core calc
efi = EMA(ta.change(close) * volume, calc_type == “Fixed” ? len : len_out_fast)
sig = EMA(efi, calc_type == “Fixed” ? len : len_out_slow)
atr_ema = math.abs(efi[1] – efi)
atr_out = RMA(atr_ema, calc_type == “Fixed” ? len : len_out_slow)//atr channel calc
atr_high1 = sig + atr_out * atr_mult1
atr_low1 = sig – atr_out * atr_mult1atr_high2= sig + atr_out * atr_mult2
atr_low2 = sig – atr_out * atr_mult2atr_high3 = sig + atr_out * atr_mult3
atr_low3 = sig – atr_out * atr_mult3atr_obhigh = sig + atr_out * (atr_mult3 + 1)
atr_oblow = sig – atr_out * (atr_mult3 + 1)efi_out = trunc_atr ? efi > atr_obhigh ? atr_high3 : efi < atr_oblow ? atr_low3 : efi : efi
//plot atr channels
plot(atr_high1, color = bar_index % 2 == 0 ? na : color.new(color.gray, 30), linewidth = 1, title = “ATR1 High”)
plot(atr_high2, color = bar_index % 4 == 0 ? na : color.new(color.gray, 30), linewidth = 1, title = “ATR2 High”)
plot(atr_high3, color = color.new(color.gray, 30), linewidth = 2, title = “ATR3 High”)plot(atr_low1, color = bar_index % 2 == 0 ? na : color.new(color.gray, 30), linewidth = 1, title = “ATR1 Low”)
plot(atr_low2, color = bar_index % 4 == 0 ? na : color.new(color.gray, 30), linewidth = 1, title = “ATR2 Low”)
plot(atr_low3, color = color.new(color.gray, 30), linewidth = 2, title = “ATR3 Low”)//plot main
plot(0, color=color.gray, style = plot.style_circles, title=‘Zero Line’, linewidth = 2)
plot(sig, color=color.new(color.white, 0), title=‘Signal’, linewidth = 2)
plot(efi_out, color = #4f6cdf, title=‘EFI’, linewidth = 2)//plot shapes
plot(efi_out >= atr_high3 ? efi_out : na, style = plot.style_circles, linewidth = 3, color = #D2042D, title = “Over ATR4 High”)
plot(efi_out <= atr_low3 ? efi_out : na, style = plot.style_circles, linewidth = 3, color = #2DD204, title = “Over ATR4 Low”)09/18/2024 at 3:42 PM #237783Eccolo qui:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147//-----------------------------------------////PRC_Elder Force index//version = 0//18.09.2024//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//-----------------------------------------////-----Inputs------------------------------////-----------------------------------------//src=closecalcType=1 //Boolean//1=Fixed 0=Band-pass Dominant Cyclelen=13 //Fixed EFI Periodslen=21 //Fixed Signal PeriodatrM=21 //Fixed ATR Smoothing LengthbpPeriod=13 //Band-pass periodbpWidth=0.20 //Band-pass WidthcycleLen=100/100 //Signal and ATR percent of dominant cycle (%)efireduction=75/100 //EFI percent of dominat cycle (%)atrMult1=1atrMult2=2atrMult3=3truncAtr=1 //truncate over ATR Mult Level 4?//-----------------------------------------////--Length Out calculation Band-pass type--////-----------------------------------------//peak=0real=0counter=0dc=0alpha2=(cos(0.25*bpWidth*2*180/bpPeriod)+sin(0.25*bpWidth*2*180/bpPeriod)-1)/cos(0.25*bpWidth*2*180/bpPeriod)if barindex<=1 thenhp=0elsehp=(1+alpha2/2)*(close-close[1])+(1-alpha2)*hp[1]endifbeta1=cos(2*180/bpPeriod)gamma1=1/cos(2*180*bpWidth/bpPeriod)alpha1=gamma1-sqrt(gamma1*gamma1-1)if barindex<=2 thenbp=0elsebp=0.5*(1-alpha1)*(hp-hp[2])+beta1*(1+alpha1)*bp[1]-alpha1*bp[2]endifpeak=0.991*peakif abs(bp)>peak thenpeak=abs(bp)elsepeak=peakendifif peak<>0 thenreal=bp/peakelsereal=realendifif dc<6 thendc=6elsedc=dcendifcounter=counter+1if real crosses over 0 or real crosses under 0 thendc=2*counterif 2*counter>1.25*dc[1] thendc=1.25*dc[1]elsif 2*counter<0.8*dc[1] thendc=0.8*dc[1]endifcounter=0endiftempoutFast=efireduction*dctempoutSlow=cycleLen*dcif tempoutFast<1 thenlenOutFast=1elselenOutFast=round(tempoutFast)endifif tempoutSlow<1 thenlenOutSlow=1elselenOutSlow=round(tempoutSlow)endif//-----------------------------------------////-----EFI and Signal Calculation----------////-----------------------------------------//if calcType=1 thenefi=average[len,1]((close-close[1])*volume)sig=average[len,1](efi)length=lenelseefi=average[lenOutFast,1]((close-close[1])*volume)sig=average[lenOutSlow,1](efi)length=lenOutSlowendifatrEMA=abs(efi[1]-efi)src1 = atrEMAalpha = 1/lengthif barindex = 2*length thenatrOUT = average[length](src1)elseatrOUT = alpha*src1 + (1-alpha)*atrOUT[1]endif//-----------------------------------------////-----ATR Channel Calculation-------------////-----------------------------------------//atrHigh1=sig+atrOut*atrMult1atrHigh2=sig+atrOut*atrMult2atrHigh3=sig+atrOut*atrMult3atrLow1=sig-atrOut*atrMult1atrLow2=sig-atrOut*atrMult2atrLow3=sig-atrOut*atrMult3atrObHigh=sig+atrOut*(atrMult3+1)atrObLow=sig-atrOut*(atrMult3+1)if truncAtr thenif efi>atrObHigh thenefiOut=atrHigh3elseif efi<atrOblow thenefiOut=atrLow3elseefiOut=efiendifendifelseefiOut=efiendif//-----------------------------------------////-----Plot shapes-------------------------////-----------------------------------------//if efiOut>=atrHigh3 thendrawpoint(barindex,efiOut,3)coloured(210,4,45)elsif efiout<=atrLow3 thendrawpoint(barindex,efiOut,3)coloured(45,210,4)endif//-----------------------------------------////-----------------------------------------////-----------------------------------------//return efiOut as "EFI" coloured("blue")style(line,2), sig as "Signal" coloured("orange")style(line,2), 0 as "zero"style(dottedline,2)coloured("grey"), atrHigh1 as "ATR1 high"coloured("grey")style(dottedline,1), atrHigh2 as "ATR2 high"coloured("grey")style(dottedline2,1), atrHigh3 as "ATR3 high"coloured("grey")style(line,2), atrLow1 as "ATR1 low"coloured("grey")style(dottedline,1),atrLow2 as "ATR2 low"coloured("grey")style(dottedline2,1),atrLow3 as "ATR3 low"coloured("grey")style(line,2)1 user thanked author for this post.
09/18/2024 at 4:07 PM #23778609/18/2024 at 4:26 PM #237790Hai iniziato usando l’Inglese ed hai finito con lo Spagnolo, pur avendo scelto il forum Italiano!
Per favore, non rispondere cercando di usare la lingua dell’interlocutore, né l’Inglese per forza. Usa SOLO la lingua del forum prescelto.
Grazie 🙂
-
AuthorPosts
Find exclusive trading pro-tools on