Modify SuperTrend - Sierra Chart | futures io social day trading
futures io futures trading


Modify SuperTrend
Updated: Views / Replies:1,466 / 10
Created: by Renko123 Attachments:4

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 4  
 
Thread Tools Search this Thread
 

Modify SuperTrend

  #1 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received

Modify SuperTrend

Could someone with more ability then me modify the supertrend indicator to plot only the uptrend?
I tried, had to accept that i couldn't get it working.
Thanks in advance.

 
Code
/*============================================================================
	SuperTrend Stop study function.
----------------------------------------------------------------------------*/
SCSFExport scsf_SuperTrendStop(SCStudyInterfaceRef sc)
{
	SCSubgraphRef Stop = sc.Subgraph[0];
	
	SCSubgraphRef Median       =  sc.Subgraph[1];

	SCFloatArrayRef TrueRange    = Stop.Arrays[0];
	SCFloatArrayRef AvgTrueRange = Stop.Arrays[1];
	SCFloatArrayRef Trend        = Stop.Arrays[2];


	SCInputRef ATRMultiplier = sc.Input[0];
	SCInputRef ATRPeriod = sc.Input[1];
	SCInputRef MedianPeriod = sc.Input[2];

	// Set configuration variables
	if (sc.SetDefaults)
	{
		// Set the configuration and defaults
		sc.GraphName = "SuperTrend Stop";
		
		sc.StudyDescription = "";
		sc.DrawZeros = false;
		sc.GraphRegion = 0;
		sc.ValueFormat = sc.BaseGraphValueFormat;
		
		//During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
		sc.FreeDLL = 0;
		
		sc.AutoLoop = 1;
		
		Stop.Name = "Stop";
		Stop.DrawStyle = DRAWSTYLE_DASH;
		Stop.LineWidth = 2;
		Stop.PrimaryColor = COLOR_BLUE;
		Stop.SecondaryColor = COLOR_RED;
		Stop.SecondaryColorUsed = 1;

		ATRMultiplier.Name = "ATR Multiplier";
		ATRMultiplier.SetFloat(2);
		ATRMultiplier.SetFloatLimits(0.000001f,(float)MAX_STUDY_LENGTH);
		
		ATRPeriod.Name = "ATR Period";
		ATRPeriod.SetInt(3);
		ATRPeriod.SetIntLimits(1,MAX_STUDY_LENGTH);
		
		MedianPeriod.Name = "Median Period";
		MedianPeriod.SetInt(3);
		MedianPeriod.SetIntLimits(1,MAX_STUDY_LENGTH);

		return;
	}
	
	// Do data processing
	sc.MovingMedian(sc.HLAvg, Median, sc.Index, MedianPeriod.GetInt());
	sc.ATR(sc.BaseDataIn, TrueRange, AvgTrueRange, sc.Index, ATRPeriod.GetInt(), MOVAVGTYPE_SIMPLE);

	if (sc.Index == 0)
	{
		sc.ValueFormat = sc.BaseGraphValueFormat;

		Stop[sc.Index] = sc.Close[sc.Index];
		Trend[sc.Index] = 1;
		return;
	}

	if (sc.FormattedEvaluate(sc.Close[sc.Index], sc.ValueFormat, GREATER_OPERATOR, Stop[sc.Index-1], sc.ValueFormat))
	{
		Trend[sc.Index] = 1;
		float NewStop = Median[sc.Index] - ATRMultiplier.GetFloat()*AvgTrueRange[sc.Index-1];
		if (Trend[sc.Index-1] < 0)
		{
			Stop[sc.Index] = NewStop;
		}
		else
		{
			Stop[sc.Index] = max(NewStop, Stop[sc.Index-1]);
		}
	}
	else if (sc.FormattedEvaluate(sc.Close[sc.Index], sc.ValueFormat, LESS_OPERATOR, Stop[sc.Index-1], sc.ValueFormat))
	{
		Trend[sc.Index] = -1;
		float NewStop = Median[sc.Index] + ATRMultiplier.GetFloat()*AvgTrueRange[sc.Index-1];
		if (Trend[sc.Index-1] > 0)
		{
			Stop[sc.Index] = NewStop;
		}
		else
		{
			Stop[sc.Index] = min(NewStop, Stop[sc.Index-1]);
		}
	}
	else
	{
		Trend[sc.Index] = Trend[sc.Index-1];
		Stop[sc.Index] = Stop[sc.Index-1];
	}

	Stop.DataColor[sc.Index] = Trend[sc.Index] > 0 ? Stop.PrimaryColor : Stop.SecondaryColor;

}

Reply With Quote
 
  #2 (permalink)
Market Wizard
virginia
 
Futures Experience: Intermediate
Platform: ninja
Favorite Futures: ES
 
cory's Avatar
 
Posts: 5,216 since Jun 2009
Thanks: 628 given, 6,313 received
Forum Reputation: Legendary


Renko123 View Post
Could someone with more ability then me modify the supertrend indicator to plot only the uptrend?
I tried, had to accept that i couldn't get it working.
Thanks in advance.

why not just set downtrend color to background color?

Reply With Quote
The following user says Thank You to cory for this post:
 
  #3 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received



cory View Post
why not just set downtrend color to background color?

Thanks for the reply cory.
Its good to see a fellow member from the DC metro area.

Setting the background color to chart color wont do what i need.
Because the stop value is still plotted on the chart and picked up by the spreadsheet.

If there was a separate StopLong and a StopShort instead of one "Stop" variable , I would be able to choose ignore to keep the StopLong or the StopShort value from showing up in the chart and being captured by the spreadsheet.

Reply With Quote
 
  #4 (permalink)
Elite Member
Alesia E.U.
 
Futures Experience: Intermediate
Platform: Sierra chart
Favorite Futures: Futures
 
Posts: 166 since Feb 2011
Thanks: 139 given, 109 received

Hi

try this , set scale Same as Region

 
Code
/*============================================================================
	SuperTrend Stop study function.
----------------------------------------------------------------------------*/
SCSFExport scsf_SuperTrendStop(SCStudyInterfaceRef sc)
{
	SCSubgraphRef Stop = sc.Subgraph[0];
	
	SCSubgraphRef Median       =  sc.Subgraph[1];

        SCSubgraphRef Stop1       =  sc.Subgraph[2];

	SCFloatArrayRef TrueRange    = Stop.Arrays[0];
	SCFloatArrayRef AvgTrueRange = Stop.Arrays[1];
	SCFloatArrayRef Trend        = Stop.Arrays[2];


	SCInputRef ATRMultiplier = sc.Input[0];
	SCInputRef ATRPeriod = sc.Input[1];
	SCInputRef MedianPeriod = sc.Input[2];

	// Set configuration variables
	if (sc.SetDefaults)
	{
		// Set the configuration and defaults
		sc.GraphName = "SuperTrend Stop";
		
		sc.StudyDescription = "";
		sc.DrawZeros = false;
		sc.GraphRegion = 0;
		sc.ValueFormat = sc.BaseGraphValueFormat;
		
		//During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
		sc.FreeDLL = 1;
		
		sc.AutoLoop = 1;
		
		Stop.Name = "Stop";
		Stop.DrawStyle = DRAWSTYLE_DASH;
		Stop.LineWidth = 2;
		Stop.PrimaryColor = COLOR_BLUE;
		Stop.SecondaryColor = COLOR_RED;
		Stop.SecondaryColorUsed = 1;

		ATRMultiplier.Name = "ATR Multiplier";
		ATRMultiplier.SetFloat(2);
		ATRMultiplier.SetFloatLimits(0.000001f,(float)MAX_STUDY_LENGTH);
		
		ATRPeriod.Name = "ATR Period";
		ATRPeriod.SetInt(3);
		ATRPeriod.SetIntLimits(1,MAX_STUDY_LENGTH);
		
		MedianPeriod.Name = "Median Period";
		MedianPeriod.SetInt(3);
		MedianPeriod.SetIntLimits(1,MAX_STUDY_LENGTH);

		return;
	}
	
	// Do data processing
	sc.MovingMedian(sc.HLAvg, Median, sc.Index, MedianPeriod.GetInt());
	sc.ATR(sc.BaseDataIn, TrueRange, AvgTrueRange, sc.Index, ATRPeriod.GetInt(), MOVAVGTYPE_SIMPLE);

	if (sc.Index == 0)
	{
		sc.ValueFormat = sc.BaseGraphValueFormat;

		Stop[sc.Index] = sc.Close[sc.Index];
                Stop1[sc.Index] = sc.Close[sc.Index];
		Trend[sc.Index] = 1;
		return;
	}

	if (sc.FormattedEvaluate(sc.Close[sc.Index], sc.ValueFormat, GREATER_OPERATOR, Stop1[sc.Index-1], sc.ValueFormat))
	{
		Trend[sc.Index] = 1;
		float NewStop = Median[sc.Index] - ATRMultiplier.GetFloat()*AvgTrueRange[sc.Index-1];
		if (Trend[sc.Index-1] < 0)
		{
			Stop[sc.Index] = NewStop;
                        Stop1[sc.Index] = NewStop;
		}
		else
		{
			Stop[sc.Index] = max(NewStop, Stop1[sc.Index-1]);
                        Stop1[sc.Index] = max(NewStop, Stop1[sc.Index-1]);

		}
	}
	else if (sc.FormattedEvaluate(sc.Close[sc.Index], sc.ValueFormat, LESS_OPERATOR, Stop1[sc.Index-1], sc.ValueFormat))
	{
		Trend[sc.Index] = -1;
		float NewStop = Median[sc.Index] + ATRMultiplier.GetFloat()*AvgTrueRange[sc.Index-1];
		if (Trend[sc.Index-1] > 0)
		{
			Stop1[sc.Index] = NewStop;
                        Stop[sc.Index] = 0;
		}
		else
		{
			Stop1[sc.Index] = min(NewStop, Stop1[sc.Index-1]);
                        Stop[sc.Index] = 0;
		}
	}
	else
	{
		Trend[sc.Index] = Trend[sc.Index-1];
		Stop1[sc.Index] = Stop1[sc.Index-1];
                Stop[sc.Index] = 0;
	}


}

Reply With Quote
 
  #5 (permalink)
Elite Member
Alesia E.U.
 
Futures Experience: Intermediate
Platform: Sierra chart
Favorite Futures: Futures
 
Posts: 166 since Feb 2011
Thanks: 139 given, 109 received

if works remember to change sc.FreeDLL = 1; to sc.FreeDLL = 0;

Reply With Quote
 
  #6 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received

Thanks crazybears,
That worked for the long side, but it doesn't allow me to be able to select ignore for the short side or provide a separate named variable value plotted on the chart for the long and short side.
ie:
StopLong
StopShort



crazybears View Post
Hi

try this , set scale Same as Region

 
Code
/*============================================================================
	SuperTrend Stop study function.
----------------------------------------------------------------------------*/
SCSFExport scsf_SuperTrendStop(SCStudyInterfaceRef sc)
{
	SCSubgraphRef Stop = sc.Subgraph[0];
	
	SCSubgraphRef Median       =  sc.Subgraph[1];

        SCSubgraphRef Stop1       =  sc.Subgraph[2];

	SCFloatArrayRef TrueRange    = Stop.Arrays[0];
	SCFloatArrayRef AvgTrueRange = Stop.Arrays[1];
	SCFloatArrayRef Trend        = Stop.Arrays[2];


	SCInputRef ATRMultiplier = sc.Input[0];
	SCInputRef ATRPeriod = sc.Input[1];
	SCInputRef MedianPeriod = sc.Input[2];

	// Set configuration variables
	if (sc.SetDefaults)
	{
		// Set the configuration and defaults
		sc.GraphName = "SuperTrend Stop";
		
		sc.StudyDescription = "";
		sc.DrawZeros = false;
		sc.GraphRegion = 0;
		sc.ValueFormat = sc.BaseGraphValueFormat;
		
		//During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
		sc.FreeDLL = 1;
		
		sc.AutoLoop = 1;
		
		Stop.Name = "Stop";
		Stop.DrawStyle = DRAWSTYLE_DASH;
		Stop.LineWidth = 2;
		Stop.PrimaryColor = COLOR_BLUE;
		Stop.SecondaryColor = COLOR_RED;
		Stop.SecondaryColorUsed = 1;

		ATRMultiplier.Name = "ATR Multiplier";
		ATRMultiplier.SetFloat(2);
		ATRMultiplier.SetFloatLimits(0.000001f,(float)MAX_STUDY_LENGTH);
		
		ATRPeriod.Name = "ATR Period";
		ATRPeriod.SetInt(3);
		ATRPeriod.SetIntLimits(1,MAX_STUDY_LENGTH);
		
		MedianPeriod.Name = "Median Period";
		MedianPeriod.SetInt(3);
		MedianPeriod.SetIntLimits(1,MAX_STUDY_LENGTH);

		return;
	}
	
	// Do data processing
	sc.MovingMedian(sc.HLAvg, Median, sc.Index, MedianPeriod.GetInt());
	sc.ATR(sc.BaseDataIn, TrueRange, AvgTrueRange, sc.Index, ATRPeriod.GetInt(), MOVAVGTYPE_SIMPLE);

	if (sc.Index == 0)
	{
		sc.ValueFormat = sc.BaseGraphValueFormat;

		Stop[sc.Index] = sc.Close[sc.Index];
                Stop1[sc.Index] = sc.Close[sc.Index];
		Trend[sc.Index] = 1;
		return;
	}

	if (sc.FormattedEvaluate(sc.Close[sc.Index], sc.ValueFormat, GREATER_OPERATOR, Stop1[sc.Index-1], sc.ValueFormat))
	{
		Trend[sc.Index] = 1;
		float NewStop = Median[sc.Index] - ATRMultiplier.GetFloat()*AvgTrueRange[sc.Index-1];
		if (Trend[sc.Index-1] < 0)
		{
			Stop[sc.Index] = NewStop;
                        Stop1[sc.Index] = NewStop;
		}
		else
		{
			Stop[sc.Index] = max(NewStop, Stop1[sc.Index-1]);
                        Stop1[sc.Index] = max(NewStop, Stop1[sc.Index-1]);

		}
	}
	else if (sc.FormattedEvaluate(sc.Close[sc.Index], sc.ValueFormat, LESS_OPERATOR, Stop1[sc.Index-1], sc.ValueFormat))
	{
		Trend[sc.Index] = -1;
		float NewStop = Median[sc.Index] + ATRMultiplier.GetFloat()*AvgTrueRange[sc.Index-1];
		if (Trend[sc.Index-1] > 0)
		{
			Stop1[sc.Index] = NewStop;
                        Stop[sc.Index] = 0;
		}
		else
		{
			Stop1[sc.Index] = min(NewStop, Stop1[sc.Index-1]);
                        Stop[sc.Index] = 0;
		}
	}
	else
	{
		Trend[sc.Index] = Trend[sc.Index-1];
		Stop1[sc.Index] = Stop1[sc.Index-1];
                Stop[sc.Index] = 0;
	}


}


Reply With Quote
 
  #7 (permalink)
Elite Member
Alesia E.U.
 
Futures Experience: Intermediate
Platform: Sierra chart
Favorite Futures: Futures
 
Posts: 166 since Feb 2011
Thanks: 139 given, 109 received

Hi Renko123

maybe i didn't understand but you didn't want to plot only the up trend of super trend ?

do you want the choice to plot only the up or the down trend ?

Reply With Quote
 
  #8 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received

Yes, crazybears.

If possible the ability to choose to plot either long, short or both on the chart.
something like choices in the input.
SCInputRef PlotLong = sc.Input[3];
SCInputRef PlotShort = sc.Input[4];

With the supertrend directional stops "Stop" or "Stop1" plotted on the chart depending on which input was chosen.

Thanks.





crazybears View Post
Hi Renko123

maybe i didn't understand but you didn't want to plot only the up trend of super trend ?

do you want the choice to plot only the up or the down trend ?


Reply With Quote
 
  #9 (permalink)
Elite Member
Alesia E.U.
 
Futures Experience: Intermediate
Platform: Sierra chart
Favorite Futures: Futures
 
Posts: 166 since Feb 2011
Thanks: 139 given, 109 received

Hi

try this

Attached Files
Register to download File Type: cpp Supertrend2.cpp (4.7 KB, 9 views)
Reply With Quote
 
  #10 (permalink)
Trading for Fun
Washington, DC USA
 
Futures Experience: Intermediate
Platform: Tradestation, SC
Favorite Futures: NQ, ES, YM
 
Posts: 56 since Nov 2013
Thanks: 9 given, 2 received


Thanks crazybears for the coding changes,

However some problems still remains.
The subgraph SuperTrend(SG5) stop name for long or short is still the same.
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


There needs to be a separate subgraph stop name for each the long and the short trend.
ie:subgraph
StopLong(SG5)
StopShort(SG6)

Another issue is when the option to show only the short stop is selected.
The stop is all over the place.
The stop moves up and down the short side trend.
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).




crazybears View Post
Hi

try this


Reply With Quote

Reply



futures io > > > > Modify SuperTrend

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
StochasticSlow <--- need help to modify it khalid alshalan ThinkOrSwim 4 January 2nd, 2015 09:44 AM
Please help to modify this Indi hen78 NinjaTrader Programming 2 October 23rd, 2013 12:52 PM
Modify Supertrend strategy in mt4 indiantrader MetaQuotes MetaTrader MQL Programming 7 April 7th, 2012 01:36 PM
looking to modify vroc and use in a scan. adross1 ThinkOrSwim Programming 2 February 25th, 2012 05:17 PM
Does anyone now how to modify Session Time in NT7? benharrell Traders Hideout 4 July 15th, 2010 08:25 PM


All times are GMT -4. The time now is 08:00 PM.

Copyright © 2017 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
Page generated 2017-12-12 in 0.11 seconds with 20 queries on phoenix via your IP 54.234.255.29