EasyLanguage SuperTrend indicator - futures io
futures io futures trading



EasyLanguage SuperTrend indicator


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Big Mike with 11 posts (55 thanks)
    2. looks_two ABCTG with 9 posts (6 thanks)
    3. looks_3 chtangwin with 6 posts (23 thanks)
    4. looks_4 Sam7768 with 5 posts (2 thanks)
      Best Posters
    1. looks_one Big Mike with 5 thanks per post
    2. looks_two chtangwin with 3.8 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 74,963 views
    2. thumb_up 96 thanks given
    3. group 39 followers
    1. forum 84 posts
    2. attach_file 9 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
 

EasyLanguage SuperTrend indicator

(login for full post details)
  #1 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received

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://futures.io

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://futures.io 

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.



Here are some example screenshots:







Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on futures io?
ZigZag with Depth and Backstep
EasyLanguage Programming
Automatic pattern research with NT
Elite Algorithmic NinjaTrader Trading
Webinar: Finding your own way in trading w/Adam Grimes
The Elite Circle
Tools for backtesting?
Platforms and Indicators
NT8 indicator to simulate a Funding Evaluation where to …
NinjaTrader
 
 
(login for full post details)
  #3 (permalink)
Omaha, NE
 
 
Posts: 46 since Nov 2009
Thanks: 15 given, 25 received


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
 
(login for full post details)
  #4 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received


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

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #5 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received

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

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Attached Files
Register to download File Type: pla BMT SuperTrend.pla (9.3 KB, 846 views)
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
The following 12 users say Thank You to Big Mike for this post:
 
(login for full post details)
  #6 (permalink)
 
 
Posts: 1 since Feb 2010
Thanks: 1 given, 0 received

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

Reply With Quote
 
(login for full post details)
  #7 (permalink)
clifton, nj
 
 
Posts: 2 since Jul 2010
Thanks: 1 given, 2 received

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:
 
(login for full post details)
  #8 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received


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

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #9 (permalink)
clifton, nj
 
 
Posts: 2 since Jul 2010
Thanks: 1 given, 2 received

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:
 
(login for full post details)
  #10 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received



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

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
The following 4 users say Thank You to Big Mike for this post:
 
(login for full post details)
  #11 (permalink)
Miami, Florida USA
 
 
Posts: 5 since Dec 2010
Thanks: 0 given, 0 received

Hello BigMike/Others: Can you suggest a way to get the formal algorithm for the SuperTrend Indicator?

I converted Roonius' v2.3 Ninja script available at tradingstudies.com to TS EasyLanguage successfully but from time to time the price and the indicator diverge due to conditions that are no being contemplated by the code. In order to correct that I need to know the algorithm, have not been able to figure out the underlying theory by looking at the code's logic ("reverse engineering").

Roonius has not responded but perhaps someone out there can point me in the right direction.

Thanking you in advance,

JVBehar

Reply With Quote
 
(login for full post details)
  #12 (permalink)
Dallas, Texas, USA
 
Experience: Beginner
Platform: NT 6.5 & Tradestation
Trading: Equities & ES
 
Posts: 45 since Sep 2010
Thanks: 21 given, 9 received

---

Thanks Mike, this is great.

Need some guidance from Tradestation gurus...how do I covert txt files in to ELD files? I tried to important txt files but TS is not accepting them.

Thanks much....

Reply With Quote
 
(login for full post details)
  #13 (permalink)
Dallas, Texas, USA
 
Experience: Beginner
Platform: NT 6.5 & Tradestation
Trading: Equities & ES
 
Posts: 45 since Sep 2010
Thanks: 21 given, 9 received

Found the answer. Posting below for future use...

https://www.tradestation.com:443/Discussions/Topic.aspx?Topic_ID=110336&PAGE=1&

Reply With Quote
The following user says Thank You to Sam7768 for this post:
 
(login for full post details)
  #14 (permalink)
Quebec
 
Experience: Intermediate
Platform: Multicharts 64 +VolProfile
Broker: AMP Trading / CQG
Trading: Ym, Es
 
Serger's Avatar
 
Posts: 72 since Oct 2010
Thanks: 64 given, 24 received

Newbie to code
I try to make a signal whit Big Mike SuperTrend ... . but any resultats have you idea why ?
I have compile it and any error ???
{ Super Trend strategy }

inputs: price(Close), SuperTrend( 21 ), upColour(Blue), downColour(Red);
variables: Avg(0), colour(0);



if Avg > Avg[1] then colour = upColour;
if Avg < Avg[1] then colour = downColour;


{buy sell Criteria}

if colour[1] <> colour then
if colour = upColour then
Buy ( "jup" ) next bar at market ;

if colour[1] <> colour then
if colour = downColour then
sell short ( "jdn" ) next bar at market ;



Thank you for your help if ......

Reply With Quote
 
(login for full post details)
  #15 (permalink)
Milano
 
 
Posts: 13 since May 2011
Thanks: 29 given, 0 received

Good evening everyone ... sorry for my english I have a problem .... use of tradepulse fastbrokers and should use the language .... I have a easy language code for the Hull .... but I do not agree and I several mistakes .... can someone help me ... This applies to the 3d right? Thanks

Reply With Quote
 
(login for full post details)
  #16 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received


Tom Joad View Post
Good evening everyone ... sorry for my english I have a problem .... use of tradepulse fastbrokers and should use the language .... I have a easy language code for the Hull .... but I do not agree and I several mistakes .... can someone help me ... This applies to the 3d right? Thanks

In order to help, you'll need to describe the exact problem. A screenshot is helpful.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #17 (permalink)
Milano
 
 
Posts: 13 since May 2011
Thanks: 29 given, 0 received


Big Mike View Post
In order to help, you'll need to describe the exact problem. A screenshot is helpful.

Mike

Thank you Mike...(Big Mike)
I managed to solve right now and your disponibilita'e'ottima. I am happy to be part of this community ', I have some language problem but I think I make it a nice day

Reply With Quote
 
(login for full post details)
  #18 (permalink)
Stockholm
 
Experience: Intermediate
Platform: Nanotrader/ tradestaion
Broker: WHS / TS
Trading: EC / SI / ES / BP
 
Posts: 19 since Mar 2011
Thanks: 8 given, 5 received

Hello Mike,

I impoted this supertrend in TS but both lines stay RED even though the settings are right red and blue.



Lamboo

Reply With Quote
 
(login for full post details)
  #19 (permalink)
Dallas, Texas, USA
 
Experience: Beginner
Platform: NT 6.5 & Tradestation
Trading: Equities & ES
 
Posts: 45 since Sep 2010
Thanks: 21 given, 9 received


Big Mike View Post
In order to help, you'll need to describe the exact problem. A screenshot is helpful.

Mike

Hello Mike, and other Tradestation Experts,

I am trying to write a strategy (in Tradestation) based on the super trend...

" if st cross below close then buy ("buy") next bar at market;"

Attached a screen shot. At times, even though close is above Supertrend, Supertrend does not change (which is a good thing), and price comes back to below the super trend, but how do I code this?

If I say "st cross below close" the strategy triggers a buy even though the Supertrend does not change the side.

Any advice / suggestions?

Sam

Attached Thumbnails
Click image for larger version

Name:	Picture1.png
Views:	515
Size:	284.5 KB
ID:	39028  
Reply With Quote
 
(login for full post details)
  #20 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received

Sam,

You need to post your full code so someone can look it over and duplicate the issue. You can post just a minimal signal that you confirm duplicates the problem.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #21 (permalink)
Dallas, Texas, USA
 
Experience: Beginner
Platform: NT 6.5 & Tradestation
Trading: Equities & ES
 
Posts: 45 since Sep 2010
Thanks: 21 given, 9 received

Sure Mike. This is what I was doing...

***************
inputs:ATRLength(9), ATRMult(1), Strength(9);
Var: p(0),strend(0),st(0);

st = SuperTrend(ATRLength, ATRMult, Strength, strend);

If st cross below close then buy ("buy") next bar at market;

if st cross above close then Sell ("sell") next bar at market;

***********************

This works, except for the fact that, at times, even though close crosses supertrend (from above or below), the Supertrend does not change the side (which is a great thing). But,

because the way I coded (above), the strategy keeps buying & selling in this situations (as I posted in above pic). How do I control this / code in such a way that buy or sell happens only when the supertrend changes side and not just close crossing Supertrend.

Any help will be greatly appreciated.

Rgds,

Reply With Quote
The following user says Thank You to Sam7768 for this post:
 
(login for full post details)
  #22 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received

Gotcha.

The strend var is the key if i remember, monitor it for a change = if I remember it is 1 for long, -1 for short, so you could do something like:

if strend = 1 and strend[1] <> 1 then buy 1 contract next bar at market;

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #23 (permalink)
Dallas, Texas, USA
 
Experience: Beginner
Platform: NT 6.5 & Tradestation
Trading: Equities & ES
 
Posts: 45 since Sep 2010
Thanks: 21 given, 9 received

Thanks much Mike. Will try this.

Reply With Quote
 
(login for full post details)
  #24 (permalink)
vienna
 
 
Posts: 22 since Aug 2009
Thanks: 0 given, 38 received

Does somebody know which codes lines need to be changed to plot the stop as stairstep on every bar like
in this picture https://www.janarps.com/catalog/images/images_big/Arps_Triple_Trender.jpg
instead of a solid line ?

Reply With Quote
 
(login for full post details)
  #25 (permalink)
Madison, NJ
 
Experience: Intermediate
Platform: CQG/TOS
Broker: Optimus/CQG
Trading: ZN/TN/ES/NQ
 
Posts: 131 since Jun 2010
Thanks: 60 given, 107 received

Hi Mike, I'm looking at the SuperTrend function you posted last year.

This is the part that I need some help:

if
flag = 1 then up = avg + ATR;
if
flagh = 1 then dn = avg - ATR;


1)what are flag and flagh supposed to do
?
2)you already defined "up = avg + ATR" and "dn = avg - ATR" earlier in the indicator. Why do we have to repeat it here?

Thank you.

Reply With Quote
 
(login for full post details)
  #26 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received


shzhning View Post
Hi Mike, I'm looking at the SuperTrend function you posted last year.

This is the part that I need some help:

if
flag = 1 then up = avg + ATR;
if
flagh = 1 then dn = avg - ATR;


1)what are flag and flagh supposed to do
?
2)you already defined "up = avg + ATR" and "dn = avg - ATR" earlier in the indicator. Why do we have to repeat it here?

Thank you.

Yes I think we discussed this above in the thread, it was a mistake.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #27 (permalink)
Madison, NJ
 
Experience: Intermediate
Platform: CQG/TOS
Broker: Optimus/CQG
Trading: ZN/TN/ES/NQ
 
Posts: 131 since Jun 2010
Thanks: 60 given, 107 received

Mike, thanks for the quick reply.

Regardless of the bug, I'm still confused about:

1) the purpose of flag and flagh, and
2) why the following is repeated in the function code
up = avg + (ATR*ATRMult);
dn = avg - (ATR*ATRMult);


Thank you.

Reply With Quote
 
(login for full post details)
  #28 (permalink)
NJ
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 7 since May 2010
Thanks: 2 given, 23 received

Thanks to Mike and others. This is a great thread. SuperTrend is one of my favorite indicator. I converted the anaSuperTrendM1 indicator (also from futures.io (formerly BMT)) to Easy Language. Hope it is ok.

Please let me know if any issues.

Indicator: anaSuperTrendM1

 
Code
inputs:
	periodMedian(3),
	periodATR(3),
	multiplier(2);
	
variables:
	median(0),
	upTrend(true),
	priorUpTrend(true),
	currentUpTrend(true),
	stopDot(0),
	priorStop(0),
	newStop(0),
	offset(0);

median = 0.5 * (high + low);
if currentbar = 1 then begin
	upTrend = true;
	stopDot = close;
end
else begin
	// FirstTickOfBar
	priorUpTrend = upTrend[1];
	priorStop = stopDot[1];
	offset = averagetruerange(periodATR)[1];

	if close > priorStop then begin
		upTrend = true;
		currentUpTrend = true;
		newStop = _anaMovingMedian(median, periodMedian) - multiplier * offset;
		if priorUpTrend = false then
			stopDot = newStop
		else
			stopDot = maxlist(newStop, priorStop);
	end
	else 
	if close < priorStop then begin
		upTrend = false;
		currentUpTrend = false;
		newStop = _anaMovingMedian(median, periodMedian) + multiplier * offset;
		if priorUpTrend = true then
			stopDot = newStop
		else
			stopDot = minlist(newStop, priorStop);
	end	
	else begin
		upTrend = priorUpTrend;
		currentUpTrend = priorUpTrend;
		stopDot = priorStop;
	end;
end;

if currentUpTrend = true  then plot1(stopDot, "UpStopDot");
if currentUpTrend = false then plot2(stopDot, "DnStopDot");
Function: _anaMovingMedian

 
Code
Inputs:
	PriceValue( numericseries ), 
	Period(NumericSimple);

variables:
	medianIndex(0),
	priorIndex(0),
	even(false),
	sPeriod(0),
	idx(0),
	val(0),
	initialized(false);
	
array:
	mArray[](0);

{ OnStartUp }	
if initialized = false then begin
	initialized = true;
	array_setmaxindex(mArray, Period);
	fill_array(mArray, 0.0);
	if mod(Period, 2) = 0 then begin
		even = true;
		medianIndex = floor(Period/2);
		priorIndex = medianIndex - 1;
	end
	else begin
		even = false;
		medianIndex = floor((Period - 1)/2);
	end;
end;

{ OnUpdate }
if currentbar < Period then begin
	sPeriod = currentbar;
	for idx = 1 to sPeriod begin
		mArray[idx] = PriceValue[idx-1];
	end;
	array_sort(mArray, 1, sPeriod, true);
	if mod(sPeriod, 2) = 0 then begin
		idx = floor(sPeriod/2);
		val = 0.5 * (mArray[Period - idx] + mArray[Period - idx + 1]);
	end
	else begin
		idx = floor((1 + sPeriod)/2);
		val = mArray[Period - idx + 1];
	end;
end
else begin
	for idx = 1 to Period begin
		mArray[idx] = PriceValue[idx-1];
	end;
	array_sort(mArray, 1, Period, true);
	if even then
		val = 0.5 * (mArray[medianIndex] + mArray[priorIndex])
	else
		val = mArray[medianIndex];
end;

_anaMovingMedian = val;

Reply With Quote
The following 8 users say Thank You to chtangwin for this post:
 
(login for full post details)
  #29 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received

Nice work, we can always use some good EL programmers

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #30 (permalink)
NJ
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 7 since May 2010
Thanks: 2 given, 23 received

Thanks Mike. futures.io (formerly BMT) is the greatest forum I ever know. Certainly glad I can contribute. I am new to EL and trading. Having programming background, writing code is easy, but learning trading is hard.

Feel free to let me know if there is any programming need, could be a good exercise for me.

Reply With Quote
The following user says Thank You to chtangwin for this post:
 
(login for full post details)
  #31 (permalink)
Stockholm
 
Experience: Intermediate
Platform: Nanotrader/ tradestaion
Broker: WHS / TS
Trading: EC / SI / ES / BP
 
Posts: 19 since Mar 2011
Thanks: 8 given, 5 received

Hello, is this the EL for the indicator or the strategy?
I see 2 diffrent, do they belong together or are they 2 separate indicators or strategy's?

Lamboo

Reply With Quote
 
(login for full post details)
  #32 (permalink)
NJ
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 7 since May 2010
Thanks: 2 given, 23 received

Hi Lamboo,

1st one is indicator code, 2nd one is for _anaMovingMedian function used by the indicator.
All you need is copy and paste the code in EasyLanguage Editor (File -> New).

Hope this helps.

Reply With Quote
 
(login for full post details)
  #33 (permalink)
Quebec
 
Experience: Intermediate
Platform: Multicharts 64 +VolProfile
Broker: AMP Trading / CQG
Trading: Ym, Es
 
Serger's Avatar
 
Posts: 72 since Oct 2010
Thanks: 64 given, 24 received

Changwin,
I import, compile code and indic .. but one problem ..
I have make :subgraph1 ...same as instrument but just one red line at 0.001
Have you one idea why?
Thank you

Attached Thumbnails
Click image for larger version

Name:	anaSuperTrendM1.png
Views:	284
Size:	41.3 KB
ID:	53745  
Reply With Quote
 
(login for full post details)
  #34 (permalink)
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,779 since Jun 2009
Thanks: 32,306 given, 97,566 received


chtangwin View Post
Thanks Mike. futures.io (formerly BMT) is the greatest forum I ever know. Certainly glad I can contribute. I am new to EL and trading. Having programming background, writing code is easy, but learning trading is hard.

Feel free to let me know if there is any programming need, could be a good exercise for me.

Please check here for requests:


Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my futures io Trade Journal Started this thread Reply With Quote
 
(login for full post details)
  #35 (permalink)
New York
 
 
Posts: 44 since May 2011
Thanks: 12 given, 30 received


chtangwin View Post
I converted the anaSuperTrendM1 indicator (also from futures.io (formerly BMT)) to Easy Language.

Please let me know if any issues.

Function: _anaMovingMedian

 
Code
Inputs:
    PriceValue( numericseries ), 
    Period(NumericSimple);
 
variables:
    medianIndex(0),
    priorIndex(0),
    even(false),
    sPeriod(0),
    idx(0),
    val(0),
    initialized(false);
 
array:
    mArray[](0);
 
{ OnStartUp }    
if initialized = false then begin
    initialized = true;
    array_setmaxindex(mArray, Period);
    fill_array(mArray, 0.0);
    if mod(Period, 2) = 0 then begin
        even = true;
        medianIndex = floor(Period/2);
        priorIndex = medianIndex - 1;
    end
    else begin
        even = false;
        medianIndex = floor((Period - 1)/2);
    end;
end;
 
{ OnUpdate }
if currentbar < Period then begin
    sPeriod = currentbar;
    for idx = 1 to sPeriod begin
        mArray[idx] = PriceValue[idx-1];
    end;
    array_sort(mArray, 1, sPeriod, true);
    if mod(sPeriod, 2) = 0 then begin
        idx = floor(sPeriod/2);
        val = 0.5 * (mArray[Period - idx] + mArray[Period - idx + 1]);
    end
    else begin
        idx = floor((1 + sPeriod)/2);
        val = mArray[Period - idx + 1];
    end;
end
else begin
    for idx = 1 to Period begin
        mArray[idx] = PriceValue[idx-1];
    end;
    array_sort(mArray, 1, Period, true);
    if even then
        val = 0.5 * (mArray[medianIndex] + mArray[priorIndex])
    else
        val = mArray[medianIndex];
end;
 
_anaMovingMedian = val;

hello, getting an error that fill_array is not defined in the function. Thanks

{ OnStartUp }
if initialized = false then begin
initialized = true;
array_setmaxindex(mArray, Period);
fill_array(mArray, 0.0);
if mod(Period, 2) = 0 then begin
even = true;

Reply With Quote
The following user says Thank You to cedar for this post:
 
(login for full post details)
  #36 (permalink)
Quebec
 
Experience: Intermediate
Platform: Multicharts 64 +VolProfile
Broker: AMP Trading / CQG
Trading: Ym, Es
 
Serger's Avatar
 
Posts: 72 since Oct 2010
Thanks: 64 given, 24 received

and Work fine ,,
Thank you so much !!

Reply With Quote
 
(login for full post details)
  #37 (permalink)
NJ
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 7 since May 2010
Thanks: 2 given, 23 received

TS file attached. Some minor changes to MC code below.

 
Code
inputs:
	PriceValue(NumericSeries), 
	Period(NumericSimple);

variables:
	medianIndex(0),
	priorIndex(0),
	even(true),
	sPeriod(0),
	idx(0),
	val(0),
	initialized(false);
	
array:
	mArray[](0);

{ OnStartUp }	
if initialized = false then begin
	initialized = true;
	array_setmaxindex(mArray, Period);
	fill_array(mArray, 0.0);
	if mod(Period, 2) = 0 then begin
		even = true;
		medianIndex = floor(Period/2);
		priorIndex = medianIndex - 1;
	end
	else begin
		even = false;
		medianIndex = floor((Period - 1)/2);
	end;
end;

{ OnUpdate }
if currentbar <= Period then begin
	sPeriod = currentbar;
	for idx = 1 to sPeriod begin
		mArray[idx] = PriceValue[idx-1];
	end;
	array_sort(mArray, 1, sPeriod, true);
	if mod(sPeriod, 2) <> 0 then begin
		idx = floor(sPeriod/2);
		val = 0.5 * (mArray[Period - idx] + mArray[Period - idx + 1]);
	end
	else begin
		idx = sPeriod/2;
		val = mArray[Period - idx];
	end;
end
else begin
	for idx = 1 to Period begin
		mArray[idx] = PriceValue[idx-1];
	end;
	array_sort(mArray, 1, Period, true);
	if even then
		val = 0.5 * (mArray[medianIndex] + mArray[priorIndex])
	else
		val = mArray[medianIndex];
end;

_anaMovingMedian = val;

Attached Files
Register to download File Type: eld ANASUPERTREND.ELD (12.2 KB, 475 views)
Reply With Quote
The following 14 users say Thank You to chtangwin for this post:
 
(login for full post details)
  #38 (permalink)
Stockholm
 
Experience: Intermediate
Platform: Nanotrader/ tradestaion
Broker: WHS / TS
Trading: EC / SI / ES / BP
 
Posts: 19 since Mar 2011
Thanks: 8 given, 5 received

Thank you so much!!!!

Reply With Quote
 
(login for full post details)
  #39 (permalink)
New York
 
 
Posts: 44 since May 2011
Thanks: 12 given, 30 received


chtangwin View Post
TS file attached.

thank you chtangwin, I appreciate you taking the time to do this.

Reply With Quote
 
(login for full post details)
  #40 (permalink)
New York
 
 
Posts: 44 since May 2011
Thanks: 12 given, 30 received

While one will go broke taking every signal, I find the various forms of superTrend are great as a trend 'filter'. Can be easily used in strategies.

So once Trend is identified, take signals(some other method) in the direction of SuperTrend.

A slight modification to the anaSuperTrend code. The following will generate just one line and switch colors.

 
Code
 
{if currentUpTrend = true  then begin
 plot1(stopDot, "UpStopDot");
end;
if currentUpTrend = false then begin
 plot2(stopDot, "DnStopDot");
end;}
 
Plot1(stopDot);
 
If close > stopDot Then 
SetPlotColor(1,Green)else 
  SetPlotColor(1,magenta);

Attached Thumbnails
Click image for larger version

Name:	Nov 4.bmp
Views:	609
Size:	2.06 MB
ID:	54137  
Reply With Quote
The following 4 users say Thank You to cedar for this post:
 
(login for full post details)
  #41 (permalink)
NJ
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 7 since May 2010
Thanks: 2 given, 23 received

Hi cedar,

That's a nice modification of the code. Or, you can set style to point (see pic below).

Can you explain what signal you use or find useful? I tried strategies mainly use superTrend for entry.
Just as you said, it catches the major trend, but also a lot false entries. It could not be used in real trading at this point.

Thanks.

Attached Thumbnails
Click image for larger version

Name:	superTrend.png
Views:	522
Size:	13.2 KB
ID:	54169  
Reply With Quote
 
(login for full post details)
  #42 (permalink)
New York
 
 
Posts: 44 since May 2011
Thanks: 12 given, 30 received


chtangwin View Post

Can you explain what signal you use or find useful? I tried strategies mainly use superTrend for entry.
Just as you said, it catches the major trend, but also a lot false entries. It could not be used in real trading at this point.

good to hear from you chtangwin.

What I find useful, is once the 'Trend' is identified by superTrend. Then use an oscillator(CCI, Stochastic, %R etc) to take trades in the direction of the trend. So essentially we are buying/selling pullbacks in the direction of the trend.

As a quick exmaple, in the attachement below, I put on a 12 period CCI.

As you know it takes rigorous testing to take a strategy from an idea to production. very few things pan out. I find using wide stops and proper profit targets, help quite a bit for intraday trading.

Attached Thumbnails
Click image for larger version

Name:	Nov 5.bmp
Views:	661
Size:	1.49 MB
ID:	54176  
Reply With Quote
 
(login for full post details)
  #43 (permalink)
NJ
 
Experience: Beginner
Platform: NinjaTrader
 
Posts: 7 since May 2010
Thanks: 2 given, 23 received

Thanks a lot! Initial test shows a downward equity curve though, will look more into it.

Reply With Quote
 
(login for full post details)
  #44 (permalink)
San Diego CA, USA
 
Experience: Beginner
Platform: TradeStation
Trading: YM
 
Posts: 22 since Jan 2012
Thanks: 12 given, 5 received

Hi All,

My first post here. What a great place! I loaded the TCanasupertrend with the mod and switched the line to dots. I would like to change it to be just one row of dots in a flat line at the bottom or top of the charts so it doesnt muck up the view of price action. Anyone care to share how to add that in the EL code.

Thanks so much for all your efforts here.

Eiji


cedar View Post
While one will go broke taking every signal, I find the various forms of superTrend are great as a trend 'filter'. Can be easily used in strategies.

So once Trend is identified, take signals(some other method) in the direction of SuperTrend.

A slight modification to the anaSuperTrend code. The following will generate just one line and switch colors.

 
Code
 
{if currentUpTrend = true  then begin
 plot1(stopDot, "UpStopDot");
end;
if currentUpTrend = false then begin
 plot2(stopDot, "DnStopDot");
end;}
 
Plot1(stopDot);
 
If close > stopDot Then 
SetPlotColor(1,Green)else 
  SetPlotColor(1,magenta);


Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #45 (permalink)
The Netherlands
 
Experience: None
Platform: MultiCharts, TradingView
Trading: ...
 
Jura's Avatar
 
Posts: 774 since Apr 2010
Thanks: 2,347 given, 688 received


Eiji View Post
I loaded the TCanasupertrend with the mod and switched the line to dots. I would like to change it to be just one row of dots in a flat line at the bottom or top of the charts so it doesnt muck up the view of price action. Anyone care to share how to add that in the EL code.

Where can we find the code for the TCanasupertrend indicator? (I couldn't find it here on futures.io (formerly BMT)) And what does 'with the mod' mean?

It would be hard to change the EasyLanguage code to what you want without something to start with.

Reply With Quote
 
(login for full post details)
  #46 (permalink)
San Diego CA, USA
 
Experience: Beginner
Platform: TradeStation
Trading: YM
 
Posts: 22 since Jan 2012
Thanks: 12 given, 5 received

Jura,
here is the code for the TCanaSupertrend

inputs:
PeriodMedian(3),
PeriodATR(3),
Multiplier(2);

variables:
priceMedian(0),
upTrend(true),
priorUpTrend(true),
currentUpTrend(true),
stopDot(0),
priorStop(0),
newStop(0),
offset(0);

priceMedian = 0.5 * (high + low);
if currentbar = 1 then begin
upTrend = true;
stopDot = close;
end
else begin
// FirstTickOfBar
priorUpTrend = upTrend[1];
priorStop = stopDot[1];
offset = AvgTrueRange(periodATR)[1];

if close > priorStop then begin
upTrend = true;
currentUpTrend = true;
newStop = _TC_anaMovingMedian(priceMedian, periodMedian) - multiplier * offset;
if priorUpTrend = false then
stopDot = newStop
else
stopDot = maxlist(newStop, priorStop);
end
else if close < priorStop then begin
upTrend = false;
currentUpTrend = false;
newStop = _TC_anaMovingMedian(priceMedian, periodMedian) + multiplier * offset;
if priorUpTrend = true then
stopDot = newStop
else
stopDot = minlist(newStop, priorStop);
end
else begin
upTrend = priorUpTrend;
currentUpTrend = priorUpTrend;
stopDot = priorStop;
end;
end;



{if currentUpTrend = true then begin
plot1(stopDot, "UpStopDot");
end;
if currentUpTrend = false then begin
plot2(stopDot, "DnStopDot");
end;}

Plot1(stopDot);

If close > stopDot Then
SetPlotColor(1,Green)else
SetPlotColor(1,red);



I would love just a single row of dots instead of it being plotted above and below the price action. Any help would be greatly appreciated.

Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Eiji for this post:
 
(login for full post details)
  #47 (permalink)
The Netherlands
 
Experience: None
Platform: MultiCharts, TradingView
Trading: ...
 
Jura's Avatar
 
Posts: 774 since Apr 2010
Thanks: 2,347 given, 688 received


Eiji View Post
here is the code for the TCanaSupertrend

(...)

Hi Eiji,

Your code uses a function called _TC_anaMovingMedian, for example here:

 
Code
newStop = _TC_anaMovingMedian(priceMedian, periodMedian) + multiplier * offset;
What's the code for this function? Or do you want to substitute that for something else?

Tip: add the pasted code between [ code ] and [ / code ] tags for better formatting (the # in the text box).

Reply With Quote
 
(login for full post details)
  #48 (permalink)
San Diego CA, USA
 
Experience: Beginner
Platform: TradeStation
Trading: YM
 
Posts: 22 since Jan 2012
Thanks: 12 given, 5 received

Jura,


Thanks for replying, Im not sure what you are asking. I grabbed the code from an earlier post on this thread and added the modification from another post. the code plots a line changing color from red to green , above and below price action on the chart. I like the signals and in the least it is a great filter, but do not like that it obscures the view and busies up the screen.
Im not a programmer but have figured out how to paste copied text into the EL development to create the file and get it to work. Other than that Im just guessing.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #49 (permalink)
San Diego CA, USA
 
Experience: Beginner
Platform: TradeStation
Trading: YM
 
Posts: 22 since Jan 2012
Thanks: 12 given, 5 received

Anyone?

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #50 (permalink)
The Netherlands
 
Experience: None
Platform: MultiCharts, TradingView
Trading: ...
 
Jura's Avatar
 
Posts: 774 since Apr 2010
Thanks: 2,347 given, 688 received


Eiji View Post
Anyone?

What I'd do is set the indicator to a separate panel (so not 'Same as Symbol' as found in the properties of the indicator), then change the lines from 'Line' to 'Histogram', give these a fixed value (like 10), and change the width so you'll have tick Histogram bars. Lastly, use SetPlotColor() to change the color of the Histogram plot depending on what your definition of 'bulish/uptrend' versus 'bearish/downtrend' is. Then you'll have a separate panel below your chart which shows you the trend/direction, without messing up the price.

Since I can't get the indicator to work here without the function, you'll probably have to do this for yourself.

Reply With Quote
The following user says Thank You to Jura for this post:
 
(login for full post details)
  #51 (permalink)
San Diego CA, USA
 
Experience: Beginner
Platform: TradeStation
Trading: YM
 
Posts: 22 since Jan 2012
Thanks: 12 given, 5 received

That works good enough. Thanks

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #52 (permalink)
it
 
Experience: Advanced
Platform: mc
 
Posts: 32 since Jun 2010
Thanks: 50 given, 3 received

Hi Mike, i downloaded indicator futures.io (formerly BMT) supertrend for multicharts, and it's ok now i have in multicharts platform. one question. i have supertrend on multicharts on 5 minute chart, and i have supertrend on ninja on 5 minute chart same instruement and same settage 10 3. i see line different between 2 platform? how i can resolve?
thank you very much and sorry for my poor english
Max

Reply With Quote
 
(login for full post details)
  #53 (permalink)
San Diego, CA
 
 
Posts: 5 since Oct 2011
Thanks: 0 given, 1 received

Hey all. Great work. If I was to call the TCana indicator 2x in a signally indicator how would I go about doing this? Can the entire indicator become a function that can then be called on? Any help would be much appreciated!

Reply With Quote
 
(login for full post details)
  #54 (permalink)
Napoli/italy
 
 
Posts: 2 since Jun 2012
Thanks: 0 given, 0 received

Hello everyone,
i like very much the supertrend indicator but i like to see plotted in the graph both the atr bands(upper and lower).Few days ago i found on the web this indicator,plotted on the monthly graph of Eurostoxx50:

The idea is that when prices touch the upper band the trend is up and when they touch the lower band the trend is down.It's very effective.
I'm trying to understand by the evolution of the bands the criteria of their calculation,but so far unsuccesful.
Could you help me?
Thanks and forgive my poor english

Reply With Quote
 
(login for full post details)
  #55 (permalink)
Atlanta Georgia/United States
 
 
Posts: 7 since Jun 2012

Hi All,I saw a filter with Supertrend posted by some member called indiantrader based in Mumbai India and i wish to know where i can download the indicator used as a filter..I think its called TRENDSTREGNT A.Does anyone write strategies and can you help me with writing a strategy using Super Trend??


Thanks,

STAN

Reply With Quote
 
(login for full post details)
  #56 (permalink)
Washington DC
 
Experience: Intermediate
Platform: TradeStation
Trading: EC
 
Posts: 6 since Sep 2012
Thanks: 0 given, 3 received

The "Style" tab is no longer the same as when this code was published... Anyone have an update?

Reply With Quote
 
(login for full post details)
  #57 (permalink)
Washington DC
 
Experience: Intermediate
Platform: TradeStation
Trading: EC
 
Posts: 6 since Sep 2012
Thanks: 0 given, 3 received


Jura View Post
Hi Eiji,

Your code uses a function called _TC_anaMovingMedian, for example here:

 
Code
newStop = _TC_anaMovingMedian(priceMedian, periodMedian) + multiplier * offset;
What's the code for this function? Or do you want to substitute that for something else?

Tip: add the pasted code between [ code ] and [ / code ] tags for better formatting (the # in the text box).

The code for the _TC_anaMovingMedian function can be found in a previous post. The .ELA file contains both the indicator and function.
JW

Reply With Quote
The following user says Thank You to jwwjcw for this post:
 
(login for full post details)
  #58 (permalink)
San Diego, CA
 
 
Posts: 5 since Oct 2011
Thanks: 0 given, 1 received

How could this indicator be written as a channel instead of switching each time the price crossed it's path? I'd like both sides of the channel calculated at all times.

Reply With Quote
 
(login for full post details)
  #59 (permalink)
Atlanta Georgia/United States
 
 
Posts: 7 since Jun 2012

Regarding the post/comment by X9991..Is it really possible to have the supertrend trade within a channel instead of switching anytime the price crosses the trend line??
Please anyone that has an opinion should please post or send personal msg.

thx

Reply With Quote
 
(login for full post details)
  #60 (permalink)
Lima, Peru
 
 
Posts: 4 since Nov 2012
Thanks: 5 given, 1 received

This is my first post here, and would like to thank everyone for giving their +2 cents, i found each persons input and experience helpful.

I like the TCanaSuperTrend a good indicator to assist in desicion making and trend following, but as some people previously mentioned, its great to have other indicators (CCI, Stochastics, MACD etc) give entry to the trade once the Trend direction is identified.

im relativley new to coding for TS (coding in general) but will try to make a strategy utilizing TCanaSupertrend+ some other indicator and post my findings here.

Thank you guys once again!!

Reply With Quote
 
(login for full post details)
  #61 (permalink)
London
 
 
Posts: 14 since Jan 2013
Thanks: 0 given, 3 received


Big Mike View Post
Gotcha.

The strend var is the key if i remember, monitor it for a change = if I remember it is 1 for long, -1 for short, so you could do something like:

if strend = 1 and strend[1] <> 1 then buy 1 contract next bar at market;

Mike

Mike - just adding my thanks to this old thread - I was able to get a Supertrend function up and running in MC with this post. It's my favourite indicator from a prorealtime past so v grateful for this.

Reply With Quote
 
(login for full post details)
  #62 (permalink)
Frankfurt / Germany
 
 
Posts: 47 since Jul 2013
Thanks: 28 given, 11 received


Big Mike View Post
Gotcha.

The strend var is the key if i remember, monitor it for a change = if I remember it is 1 for long, -1 for short, so you could do something like:

if strend = 1 and strend[1] <> 1 then buy 1 contract next bar at market;

Mike

I cannot replicate this unfortunately. The Signal does not open Positions.


Quoting 
Inputs:

smalength ( 200 ),
emalength ( 50 ),
ATRLength ( 30 ),
ATRMult ( 10 ),
Strength ( 30 ),

Variables:

smav ( 0 ),
emav ( 0 ),
vSuperTrend ( 0 ),
strend ( 0 );

// Call MAs
smav = Average(Close, smalength);
emav = XAverage(Close, emalength);

// Call Supertrend
vSuperTrend = SuperTrend(ATRLength, ATRMult, Strength, vSTrend);

// Open new positions (Long Only)

if marketposition = 0 then begin // Only open new positions if flat

if close > vSuperTrend then begin // Checks if Supertrend is below price action

end;

// EMA and SMA Both Rising & Supertrend switches from Red to Green
if smav > smav[1] and emav > emav[1] and emav > smav
and sTrend = 1 and sTrend[1] <> 1 then begin

Buy ("Enter Long") 1 Contracts Next Bar At Market;

end;

end;


Reply With Quote
 
(login for full post details)
  #63 (permalink)
Frankfurt / Germany
 
 
Posts: 47 since Jul 2013
Thanks: 28 given, 11 received

Anyone help for this?

Reply With Quote
 
(login for full post details)
  #64 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

The variable strend is never assigned a value, except the initial 0.
So your condition
 
Code
sTrend = 1 and sTrend[1] <> 1
can never become true.

Should it be
 
Code
vsTrend = 1 and vsTrend[1] <> 1
?

Regards,
ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #65 (permalink)
Frankfurt / Germany
 
 
Posts: 47 since Jul 2013
Thanks: 28 given, 11 received

Hi ABC,

I referred to BigMike's post #22 on Page 3.

I would like to code a Buy/Sell signal for Supertrend crossings.

In Ninjatrader I did it through the following:


Quoting 
// Condition set 1
if (anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[1] > Close[1]
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[0] < Close[0])
{
EnterLong(RiskSize, "Buy Long");
}

// Condition set 2
if (Position.Quantity > 0
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[1] < Close[1]
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[0] > Close[0])
{
ExitLong("Exit Long", "");
}

It works fine, but for Easy Language, I somehow don't get it

Reply With Quote
 
(login for full post details)
  #66 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

Hi sagetrade,

to check for a crossing is quite easy in EasyLanguage.
For an upcross you can do it like this:
 
Code
if MyVariable crosses over MyVariable[1]
or like this:
 
Code
if MyVariable > MyVariable[1] and MyVariable[1] < MyVariable[2]
or
 
Code
if MyVariable > MyVariable[1] and MyVariable[1] <= MyVariable[2]
depending on what you want.

For your code it makes a difference on the variable you want to use. Both sTrend and vSuperTrend are able to accomplish the task.
If you want to use vSuperTrend, then check for the cross. With sTrend you simply need to check for
 
Code
if sTrend = 1 and sTrend[1] = -1
Regards,
ABCTG


sagetrade View Post
Hi ABC,

I referred to BigMike's post #22 on Page 3.

I would like to code a Buy/Sell signal for Supertrend crossings.

In Ninjatrader I did it through the following:



It works fine, but for Easy Language, I somehow don't get it


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #67 (permalink)
Frankfurt / Germany
 
 
Posts: 47 since Jul 2013
Thanks: 28 given, 11 received


ABCTG View Post
For your code it makes a difference on the variable you want to use. Both sTrend and vSuperTrend are able to accomplish the task.
If you want to use vSuperTrend, then check for the cross. With sTrend you simply need to check for
 
Code
if sTrend = 1 and sTrend[1] = -1

thx so much ABC once again. Can you explain where the specific difference between variables vSuperTrend & sTrend is?

Reply With Quote
 
(login for full post details)
  #68 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

The vSuperTrend carries the value of the Supertrend and sTrend carries the direction of the Supertrend indicator.
This will become clear if you plot both variables. On this image the blue line is vSuperTrend and the red line is displaying the value of sTrend.



Regards,
ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #69 (permalink)
Frankfurt / Germany
 
 
Posts: 47 since Jul 2013
Thanks: 28 given, 11 received

But why do I need this sTrend variable at all?

When I look at my NinjaCode...


Quoting 
// Condition set 1
if (anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[1] > Close[1]
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[0] < Close[0])
{
EnterLong(RiskSize, "Buy Long");
}

// Condition set 2
if (Position.Quantity > 0
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[1] < Close[1]
&& anaSuperTrendM11(ATRStrength, ATRMult, ATRPeriod, false).StopDot[0] > Close[0])
{
ExitLong("Exit Long", "");
}

...there is no sTrend at all - just these three ATR variables.

Reply With Quote
 
(login for full post details)
  #70 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

You don't need it. The easiest thing is to just leave it in there, if you don't want to use it. You just have to use it as input of the function.
Otherwise delete the input and get rid of it within the code. This will leave you with the three ATR inputs to the function.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #71 (permalink)
Orlando, FL
 
Experience: Intermediate
Platform: Tradestation
Trading: oil
 
Posts: 6 since Sep 2013
Thanks: 11 given, 0 received

hello,

I was looking at the screenshots above and noticed it sayd 34 tick bars. What kind of chart is that? I used a "tick chart" with 34 tics but it didn't look like the screen shot you posted. Any ideas?

Reply With Quote
 
(login for full post details)
  #72 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received


bno83 View Post
hello,

I was looking at the screenshots above and noticed it sayd 34 tick bars. What kind of chart is that? I used a "tick chart" with 34 tics but it didn't look like the screen shot you posted. Any ideas?

What screenshot are you talking about? For the last one I posted in here I don't recall the settings, it was just to display one function value.

Regards,
ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #73 (permalink)
Orlando, FL
 
Experience: Intermediate
Platform: Tradestation
Trading: oil
 
Posts: 6 since Sep 2013
Thanks: 11 given, 0 received

sorry, im new to futures.io (formerly BMT)...i saw the screen shots here:

Reply With Quote
 
(login for full post details)
  #74 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

No problem. I understood that you were talking about a screenshot within this thread, but there are more than one here.
You can give get a link to the specific post when you click on "permalink" in the top right corner of every post.

Regards,

ABCTG


bno83 View Post
sorry, im new to futures.io (formerly BMT)...i saw the screen shots here:


Follow me on Twitter Reply With Quote
 
(login for full post details)
  #75 (permalink)
Orlando, FL
 
Experience: Intermediate
Platform: Tradestation
Trading: oil
 
Posts: 6 since Sep 2013
Thanks: 11 given, 0 received

ah, thanks for the permalink post...here it is.


Reply With Quote
 
(login for full post details)
  #76 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

You are welcome. It looks like a crude oil chart that is build from ASCII data, but I don't know what @Big Mike used (probably 1 tick data).

Regards,
ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #77 (permalink)
Poland
 
 
Posts: 4 since Sep 2014
Thanks: 0 given, 1 received

Hello

How can I run this script (on first post) BigMike in OEC TRADER platform ?

Regards,

Reply With Quote
 
(login for full post details)
  #78 (permalink)
West Branch, Mi, USA
 
Experience: Intermediate
Platform: Sierra Chart
Broker: TradePro/TransAct
Trading: NQ, CL
 
Posts: 59 since Nov 2012
Thanks: 10 given, 10 received

Hi Mike,

I'm new to trading and I don't write code. I wanted to ask you about your SuperTrend indicator for Tradestation.
When I install it, I'm getting an error...

// SuperTrend indicator
// March 25 2010
// Big Mike https://futures.io/

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

vars:
strend(0),
st(0);

st = SuperTrend(ATRLength, ATRMult, Strength, strend); <-------------------------------- Unknown Identifier.

Plot1(st,"Up");
Plot2(st,"Down");
Plot3(st,"SuperTrend",iff(strend = 1,GetPlotColor(1),GetPlotColor(2)));

Thanks,
Rockford

Reply With Quote
 
(login for full post details)
  #79 (permalink)
West Branch, Mi, USA
 
Experience: Intermediate
Platform: Sierra Chart
Broker: TradePro/TransAct
Trading: NQ, CL
 
Posts: 59 since Nov 2012
Thanks: 10 given, 10 received

Hi Mike,

Please disregard the previous message, I figured it out.

Thanks,
Rockford

Reply With Quote
 
(login for full post details)
  #80 (permalink)
Bradenton
 
 
Posts: 30 since May 2016
Thanks: 6 given, 4 received

Hi,

Sorry if I reply in this old thread but I am studying supertrend and as I would like to introduce it into Multicharts I found this interesting discussion. My question is about the meaning of the "strength" parameter as in the normal literature I read only two parameters are available for supertrend indicator:
  1. length (or number of bars or observation period)
  2. multiplyinf factor

I tried to read the code and calculations to give an intuitive interpretation but ...

Reply With Quote
 
(login for full post details)
  #81 (permalink)
Chicago, IL
 
Experience: Advanced
Platform: TradeStation & Ibkr
Trading: Index Futures & Options
 
Posts: 3 since Oct 2018
Thanks: 0 given, 3 received

Big Mike,

I copied and pasted over, and fixed the typo with ATR, and when I add the Indicator to a chart it shows up as a subchart below the price/volume bar chart in Tradestation. Please Advise! I wrote a system filter with the SuperTrend that I would really like to use, but it won't register because it doesn't match up with the Prices on the Chart.

Thanks so much for the code, and the help!

ZMazz

Reply With Quote
 
(login for full post details)
  #82 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

ZMazz,

select the chart where you have applied your indicator and go to the Format Analysis Technique dialog (for example via -> Format -> Analysis Technique). Select the particular indicator and click on Format. Switch to the "Scaling" tab and set the "Scale On" to "Same Axis as Underlying Data. You might also want to click on "Default" at the bottom of this window in order to set this scaling option as the new default for this indicator.

Regards,

ABCTG


Zoakes View Post
Big Mike,

I copied and pasted over, and fixed the typo with ATR, and when I add the Indicator to a chart it shows up as a subchart below the price/volume bar chart in Tradestation. Please Advise! I wrote a system filter with the SuperTrend that I would really like to use, but it won't register because it doesn't match up with the Prices on the Chart.

Thanks so much for the code, and the help!

ZMazz


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #83 (permalink)
Michigan
 
Experience: Intermediate
Platform: Ninja/TradeStation/TOS
Broker: Tradestation, AMP
Trading: YM
 
desitrader's Avatar
 
Posts: 27 since Oct 2011
Thanks: 16 given, 24 received

Hello - does anyone have multichart signal for Supertrend?

I have .NET version which doesn't support Easy Language. Appreciate if someone can share the code if you have one.

Reply With Quote
 
(login for full post details)
  #84 (permalink)
 
 
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,471 received

desitrader,

you should be able to use any standard Tradestation version in Multicharts. For example the one @Big Mike posted in the first post of this thread. There is also at least one version in the download section here:


Regards,

ABCTG


desitrader View Post
Hello - does anyone have multichart signal for Supertrend?

I have .NET version which doesn't support Easy Language. Appreciate if someone can share the code if you have one.


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #85 (permalink)
Bradenton
 
 
Posts: 30 since May 2016
Thanks: 6 given, 4 received

Does someone of you use the dynamic charts from investing.com? I don't know why the Investing.com's SuperTrend is completely different from this one.

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > EasyLanguage SuperTrend indicator


Last Updated on July 23, 2019


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