NexusFi: Find Your Edge


Home Menu

 





EasyLanguage SuperTrend indicator


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Big Mike with 11 posts (60 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.5 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 198,333 views
    2. thumb_up 106 thanks given
    3. group 42 followers
    1. forum 87 posts
    2. attach_file 9 attachments




 
Search this Thread
  #1 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597

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(High, ATRLength) - Lowest(Low, ATRLength);
ATR = XAverage(hl, ATRLength);
avg = (XAverage(high, Strength) + XAverage(low, Strength))/2;
up = avg + ATR; 
dn = avg - ATR; 

if 
c > up[1] and c > Highest(High, Strength)[1] then
trend 
= 1
else if c < dn[1] and c < Lowest(Low, Strength)[1] then
trend 
= -1;


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

if 
trend > 0 and dn < dn[1] then dn=dn[1];
if 
trend < 0 and up > up[1] then 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(ATRLength, ATRMult, Strength, strend);

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 X Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
No book, only a stair: journaling fills where price move …
Cryptocurrency
I developed a free AI-powered (Kronos) forecasting indic …
The Elite Circle
[WTS] ATAS Lifetime ULTRA license – EU buyers only – …
Platforms and Indicators
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
EA
Platforms and Indicators
 
  #3 (permalink)
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?


Reply With Quote
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597


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 X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597

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 X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #6 (permalink)
frathom
 
Posts: 1 since Feb 2010
Thanks Given: 1
Thanks Received: 0

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


Reply With Quote
  #7 (permalink)
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


Reply With Quote
Thanked by:
  #8 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597


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 X Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:
  #9 (permalink)
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


Reply With Quote
Thanked by:
  #10 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 R.I.P. 1977-2026 
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,597



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 X Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on March 19, 2026


© 2026 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 - Downloads - Top
no new posts