Tsl is a global array (declaration line 76) who is populated by a loop in OnCalculate, line 220.
Tsl[0] content is the first occurence of the loop.
yoake wrote: Tue Dec 20, 2022 3:12 am Supertrend Filter by alexgrover (Alex Grover)
I am in the process of converting the Supertrend Filter (Using recursion ver) pinescript to MQL4.
But there is a part I don't understand.
If anyone is familiar with PineScript, could you give me some advice?
What is this expression " Tsl[0] " translated into MQL4?
Or can you give me a simple way to find out the value of " Tsl[0] "?
(Does "Tsl[0]" means current Tsl value?? But it has not been calculated. )
Thank you in advance.
Code: Select all
//@version=2 study("Supertrend Filter",overlay=true) // Pd=input(200) Factor=input(0.9) // P = pow(Pd,2) a = 2/(P+1) d = abs(close - nz(Tsl[0],hl2)) t = a*d+(1-a)*nz(t[1],d) src = Factor*nz(Tsl[0],hl2) + (1-Factor)*close Up=nz(Tsl[0],hl2)-t Dn=nz(Tsl[0],hl2)+t // TrendUp=src[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up TrendDown=src[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn // Trend = src > TrendDown[1] ? 1: src< TrendUp[1]? -1: nz(Trend[1],1) Tsl = Trend==1? TrendDown : TrendUp css = Tsl > Tsl[1] ? #0080FF : Tsl < Tsl[1] ? #FF0040 : na plot(Tsl,color=fixnan(css),transp=0)