Help with SuperTrend input - futures io
futures io futures trading



Help with SuperTrend input


Discussion in EasyLanguage Programming

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




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Help with SuperTrend input

(login for full post details)
  #1 (permalink)
Vancouver BC Canada
 
 
Posts: 7 since Dec 2014
Thanks: 5 given, 2 received

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

 
Best Threads (Most Thanked)
in the last 7 days on futures io
Selling Options on Futures?
107 thanks
Battlestations: Show us your trading desks!
99 thanks
Rank your Futures vs Stocks trading priority
54 thanks
Want your NinjaTrader indicator created, free?
27 thanks
Whats this confusion with margins?
23 thanks
 
(login for full post details)
  #3 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received


davidcolin,

welcome to futures.io. 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 Twitter Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
(login for full post details)
  #4 (permalink)
Vancouver BC Canada
 
 
Posts: 7 since Dec 2014
Thanks: 5 given, 2 received

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
 
(login for full post details)
  #5 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

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 Twitter Reply With Quote
 
(login for full post details)
  #6 (permalink)
Vancouver BC Canada
 
 
Posts: 7 since Dec 2014
Thanks: 5 given, 2 received

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
The following user says Thank You to davidcolin for this post:
 
(login for full post details)
  #7 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

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 Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Help with SuperTrend input


Last Updated on July 31, 2016


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts