NexusFi: Find Your Edge


Home Menu

 





EasyLanguage SuperTrend indicator


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Big Mike with 11 posts (59 thanks)
    2. looks_two ABCTG with 9 posts (6 thanks)
    3. looks_3 chtangwin with 6 posts (26 thanks)
    4. looks_4 Sam7768 with 5 posts (2 thanks)
      Best Posters
    1. looks_one Big Mike with 5.4 thanks per post
    2. looks_two chtangwin with 4.3 thanks per post
    3. looks_3 cedar with 1.3 thanks per post
    4. looks_4 ABCTG with 0.7 thanks per post
    1. trending_up 97,673 views
    2. thumb_up 103 thanks given
    3. group 42 followers
    1. forum 86 posts
    2. attach_file 9 attachments




 
 

EasyLanguage SuperTrend indicator

 
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537

Here is my version of a TradeStation/MultiCharts EasyLanguage SuperTrend indicator.

I made it a function so it could be called easily from a strategy.

Function:
 
Code
                            
// SuperTrend function 
// March 25 2010
// Big Mike https://nexusfi.com

inputs
ATRLength(NumericSimple), ATRMult(NumericSimple), Strength(NumericSimple), STrend(NumericRef);

vars
ATR(0), 
avg(0), 
dn(0), 
up(0), 
trend(1), 
flag(0), 
flagh(0), 
ST(0),
hl(0); 


hl Highest(HighATRLength) - Lowest(LowATRLength);
ATR XAverage(hlATRLength);
avg = (XAverage(highStrength) + XAverage(lowStrength))/2;
up avg ATR
dn avg ATR

if 
up[1] and Highest(HighStrength)[1then
trend 
1
else if dn[1] and Lowest(LowStrength)[1then
trend 
= -1;


if 
trend and trend[1] > 0 then flag=else flag=0
if 
trend and trend[1] < 0 then flagh else flagh 0

if 
trend and dn dn[1then dn=dn[1];
if 
trend and up up[1then up=up[1];

if 
flag 1 then up avg ATR
if 
flagh 1 then dn avg ATR

if 
trend 1 then ST dn else ST up;
SuperTrend ST;
STrend trend
Please note, on my version I use personally, the line "avg = (XAverage(high, Strength) + XAverage(low, Strength))/2;" from above function uses a Jurik-like phased moving average, not XAverage(EMA). But I haven't posted that yet, so I just made this use XAverage instead. Replace with your favorite MA.

Indicator:
 
Code
                            
// SuperTrend indicator
// March 25 2010
// Big Mike https://nexusfi.com 

inputs
ATRLength(9), ATRMult(1), Strength(9);

vars
strend(0),
st(0);

st SuperTrend(ATRLengthATRMultStrengthstrend);

Plot1(st,"Up");
Plot2(st,"Down");
Plot3(st,"SuperTrend",iff(strend 1,GetPlotColor(1),GetPlotColor(2))); 
To get the desired Indicator effect and control over plot colors that I wanted, I made Plot1 and Plot2 a real plot so you could precisely control the RGB color. You need to mark these plots as invisible once you setup the indicator! I will provide a screen shot below as an example.

Plot3 is the real plot, and it will be colored based on if trend is up or down.

[img]https://nexusfi.com/v/pd7kqs.png[/img]

Here are some example screenshots:

[img]https://nexusfi.com/v/qxucdm.png[/img]

[img]https://nexusfi.com/v/4my8dg.png[/img]

[img]https://nexusfi.com/v/mj9exw.png[/img]

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Deepmoney LLM
Elite Quantitative GenAI/LLM
 
 
daedalus
Omaha, NE
 
Posts: 47 since Nov 2009
Thanks Given: 15
Thanks Received: 25


Is the name of the function "SuperTrend"?

In OEC we have to combine functions and indicator code into the same file and call the functions manually. Can't get her to compile using SuperTrend as the function name.... is this correct?

 
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537


daedalus View Post
Is the name of the function "SuperTrend"?

In OEC we have to combine functions and indicator code into the same file and call the functions manually. Can't get her to compile using SuperTrend as the function name.... is this correct?

Yes, function name is SuperTrend.

I'm not sure about OEC sorry. If you have to combine them, try taking the function code but using the indicator inputs, then add the plots.. more or less.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread
 
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537

Attached is a MultiCharts pla which includes the SuperTrend function, SuperTrend indicator, at the Hull Moving Average I was using. You can replace the Mov Avg (jtHMA) with whatever floats your boat.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Attached Files
Elite Membership required to download: BMT SuperTrend.pla
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread
 
frathom
 
Posts: 1 since Feb 2010
Thanks Given: 1
Thanks Received: 0

[...]
[...]
[...]
[...]

 
factory15
clifton, nj
 
Posts: 2 since Jul 2010
Thanks Given: 1
Thanks Received: 2

Mike-

when does the ATR Mult come into play?



thanks

-Steve

Thanked by:
 
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537


factory15 View Post
Mike-

when does the ATR Mult come into play?



thanks

-Steve

It doesn't, was a bug in the code I listed above. You just need to modify:
 
Code
                            
up avg + (ATR*ATRMult); 

dn avg - (ATR*ATRMult); 
If you want to add it.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread
Thanked by:
 
factory15
clifton, nj
 
Posts: 2 since Jul 2010
Thanks Given: 1
Thanks Received: 2

Thanks Mike...

if you dont mind me asking- as a CL guy, what numbers do you plug in for ATRLength and Strength typically? Do you find it works pretty well?

I converted this over to thinkscript and I think I've got it working...anxious to see it in action.

thanks again

Thanked by:
 
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537



factory15 View Post
Thanks Mike...

if you dont mind me asking- as a CL guy, what numbers do you plug in for ATRLength and Strength typically? Do you find it works pretty well?

I converted this over to thinkscript and I think I've got it working...anxious to see it in action.

thanks again

I don't use indicators in my trading, sorry. But the defaults of the script were probably what I used when I wrote it.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread

 



Last Updated on October 31, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts