Page 35 of 44

Re: Supertrend indicators for MT4

Posted: Tue Dec 20, 2022 3:59 am
by remcous
Hello,

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)
Image

Re: Supertrend indicators for MT4

Posted: Tue Dec 20, 2022 4:25 am
by yoake
remcous wrote: Tue Dec 20, 2022 3:59 am Hello,

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.

Thanks for the reply.
Does this mean that Pinescript can get the values regardless of the rows of the calculation results?

Re: Supertrend indicators for MT4

Posted: Tue Dec 20, 2022 4:29 am
by remcous
Sorry i don't know what is Pinescript, but since OnCalculate event is call on every tick, Tsl is always populated with value.
yoake wrote: Tue Dec 20, 2022 4:25 am Thanks for the reply.
Does this mean that Pinescript can get the values regardless of the rows of the calculation results?

Re: Supertrend indicators for MT4

Posted: Sun Dec 25, 2022 5:13 am
by yoake
[quote=yoake post_id=1295498956 time=1671466344 user_id=4951333]
Supertrend Filter by alexgrover (Alex Grover)
https://www.tradingview.com/script/2raJ ... nd-Filter/


I could not solve the problem.

The problem is that the calculation results change depending on the number of historical data and the starting candle of the calculation.

If anyone downloaded attached file last time, please stop using it.
The calculation results change depending on the historical bars of each chart. (Even if it is the same currency pair!)
It is not reproducible.

:exclaim:
Of course, with TradingView, this problem does not occur.


Sorry for the inconvenience.
Yoake

Re: Supertrend indicators for MT4

Posted: Fri Jan 20, 2023 7:33 am
by chocolatier
vvFish wrote: Mon Nov 07, 2022 11:17 am ;)
Image
hello,
when I add the zero named indicator to the subwindow, it does not remove the title of the other indicator like yours.
I wonder where am I going wrong, could you please explain?
Thanx in advance.

Re: Supertrend indicators for MT4

Posted: Fri Jan 20, 2023 4:27 pm
by vvFish
chocolatier wrote: Fri Jan 20, 2023 7:33 am hello,
when I add the zero named indicator to the subwindow, it does not remove the title of the other indicator like yours.
I wonder where am I going wrong, could you please explain?
Thanx in advance.
;)

Re: Supertrend indicators for MT4

Posted: Fri Jan 20, 2023 8:31 pm
by chocolatier
vvFish wrote: Fri Jan 20, 2023 4:27 pm ;)
Image


Image
Thank you so much,
Do we have a chance to do the same cleaning on the main chart window?
:)

Re: Supertrend indicators for MT4

Posted: Sun Jan 22, 2023 10:17 pm
by chocolatier
BeatlemaniaSA wrote: Wed Nov 09, 2022 3:12 am Absolute magic from Master Coder kvak! Your coding skills are simply amazing! Forex Station coders are simply the best ;)

Warmest regards,
BeatlemaniaSA
Image

Image

Image

Image
Hi BeatlemaniaSA,
Could you share the indicators you use on this screen, please?
Thanks in advance.

Re: Supertrend indicators for MT4

Posted: Sun Jan 22, 2023 10:55 pm
by BeatlemaniaSA
chocolatier wrote: Sun Jan 22, 2023 10:17 pm Hi BeatlemaniaSA,
Could you share the indicators you use on this screen, please?
Thanks in advance.
Just use Kvak's supertrend found here viewtopic.php?p=1295495340#p1295495340 with one of the later versions of my XU-Hybrid found here viewtopic.php?p=1295456155#p1295456155 :thumbup:

Play around with the setup and see what works for you.

Re: Supertrend indicators for MT4

Posted: Sun Jan 22, 2023 11:44 pm
by chocolatier
kvak wrote: Mon Nov 07, 2022 9:24 am Requested file...
Histo version supertrend
Image
could you please share the mql4 version?