NexusFi: Find Your Edge


Home Menu

 





Help with SuperTrend input


Discussion in EasyLanguage Programming

Updated
    1. trending_up 2,799 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
davidcolin
Vancouver BC Canada
 
Posts: 7 since Dec 2014
Thanks Given: 5
Thanks Received: 2

Hello,

I'm not an EasyLanguage expert but I do have some(very) basic knowledge. I am trying to plot a custom ShowMe based on the SuperTrend user function (appended below). For the life of me I cannot figure out what the final input (strend) is supposed to be. When I plot the indicator SuperTrend there is no input for strend, only for ATRLength, ATRmult and Strength. I just want red dots when C < Supertrend and green if vice versa but I can't plot this without this final input. Driving me nuts. Any help would be appreciated.

I've appended the indicator code as well.

Dave

SuperTrend Function:

// SuperTrend function

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;



SuperTrend Indicator:

// SuperTrend indicator

inputs:
ATRLength(10), ATRMult(1), Strength(10);

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


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Iran Airspace Collapses 18 Points to 15.5% While Hormuz …
Prediction Markets & Event Contracts
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
Iran Airspace Contract Surges to 33.5% as Project Freedo …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
Hungary Called for Magyar at 97pct, Ending 16-Year Orban …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
197 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
BERN ALGOS algo trading journal
8 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642


davidcolin,

welcome to NexusFi. When you are working in the Tradestation development environment (or in Multicharts's PL Editor for that matter) you can highlight a reserved word and press F1, this will bring up an explanation of this word does.

NumerifRef is used to reference values back from a function, meaning you don't pass anything into the function using this input, but you can use it to receive a value. In your case of of the supertrend it just references +1 or -1 depending on the trend being up or down. You can use a simple numeric variable to hold what the function references back via STrend, but you don't have to use this variable later in your code.

By the way you can show your appreciation for a post here on Futures.io using the "Thanks" button under it.

Regards,

ABCTG


Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
davidcolin
Vancouver BC Canada
 
Posts: 7 since Dec 2014
Thanks Given: 5
Thanks Received: 2

Hello ABCTG,

Thank you for answering my recent forum post re: the variable required to use the supertrend function. Unfortunately, not really having a programming background, I didn't even understand your answer. And now I am running into the same problem with a function for donchian channels. I want to use this function and I know what to enter for the inputs, however it seems to want me to enter something for the variables. Would you be able to tell me what I need to enter to use this function properly? Thanks and sorry to bother you. I'm not sure who else to ask.

Code is:


inputs:
period (NumericSimple),
myMid (NumericRef),
myUpper (NumericRef),
myLower (NumericRef),
upperPrice (NumericSeries),
lowerPrice (NumericSeries);


myUpper = Highest(upperPrice, period);
myLower = Lowest(lowerPrice, period);
myMid = (myUpper + myLower) / 2;


David


Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

David,

I am sorry, but I don't understand what you mean with "it seems to want me to enter something for the variables". Your code snippet only shows inputs and no variables, so it's not really clear what you mean.

For the inputs you can see that you have three NumericRef inputs, so these will return values to the indicator (signal or function) calling your function.

Then you have "period" that sets the lookback length for the Highest and Lowest function and you have the price inputs for the Highest and Lowest function i.e. upperPrice and lowerPrice. The latter two are probably something like High or Low.

Regards,

ABCTG




davidcolin View Post
Hello ABCTG,

Thank you for answering my recent forum post re: the variable required to use the supertrend function. Unfortunately, not really having a programming background, I didn't even understand your answer. And now I am running into the same problem with a function for donchian channels. I want to use this function and I know what to enter for the inputs, however it seems to want me to enter something for the variables. Would you be able to tell me what I need to enter to use this function properly? Thanks and sorry to bother you. I'm not sure who else to ask.

Code is:


inputs:
period (NumericSimple),
myMid (NumericRef),
myUpper (NumericRef),
myLower (NumericRef),
upperPrice (NumericSeries),
lowerPrice (NumericSeries);


myUpper = Highest(upperPrice, period);
myLower = Lowest(lowerPrice, period);
myMid = (myUpper + myLower) / 2;


David


Follow me on X Reply With Quote
  #6 (permalink)
davidcolin
Vancouver BC Canada
 
Posts: 7 since Dec 2014
Thanks Given: 5
Thanks Received: 2

DUUUUH...my apologies, I was actually looking at the indicator code where myMid, myUpper and myLower were variables. Sorry for the mistake.

Anyway what I meant was, I still don't get what to enter as a value for numericref inputs when using the function to say, plot a custom ShowMe. For example

SuperTrend(20, 2, 2, STrend(NumericRef)???? )

OR

DonchianChannel(20, ? , ? , ?, High , Low)


Reply With Quote
Thanked by:
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

David,

you have to create variables and use these to pick the values up that the function references.

Assuming you have created a variable called "trendDirection" you'd use this in the function header:

 
Code
SuperTrend(20, 2, 2, trendDirection ) ;
Now the variable trendDirection can be used to plot the value that the SuperTrend function references via its STrend input.

It will be similar for the DonchianChannel function, but you'll need three variables here.

Regards,

ABCTG


Follow me on X Reply With Quote
Thanked by:




Last Updated on July 31, 2016


© 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