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 Eiji with 5 posts (1 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,157 views
    2. thumb_up 103 thanks given
    3. group 42 followers
    1. forum 86 posts
    2. attach_file 9 attachments




 
Search this Thread

EasyLanguage SuperTrend indicator

  #1 (permalink)
 
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,322 since Jun 2009
Thanks Given: 33,143
Thanks Received: 101,476

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 Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
67 thanks
Battlestations: Show us your trading desks!
48 thanks
NexusFi site changelog and issues/problem reporting
47 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
31 thanks

  #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
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,322 since Jun 2009
Thanks Given: 33,143
Thanks Received: 101,476


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 Reply With Quote
  #5 (permalink)
 
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,322 since Jun 2009
Thanks Given: 33,143
Thanks Received: 101,476

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 Reply With Quote
The following 12 users say Thank You to Big Mike for this post:
  #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
The following user says Thank You to factory15 for this post:
  #8 (permalink)
 
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,322 since Jun 2009
Thanks Given: 33,143
Thanks Received: 101,476


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 Reply With Quote
The following user says Thank You to Big Mike for this post:
  #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
The following user says Thank You to factory15 for this post:
  #10 (permalink)
 
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,322 since Jun 2009
Thanks Given: 33,143
Thanks Received: 101,476



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 Reply With Quote
The following 4 users say Thank You to Big Mike for this post:





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