NexusFi: Find Your Edge


Home Menu

 





SuperTrendU11 backtesting


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one sburtt with 4 posts (1 thanks)
    2. looks_two GaryD with 3 posts (0 thanks)
    3. looks_3 sam028 with 1 posts (1 thanks)
    4. looks_4 Fat Tails with 1 posts (3 thanks)
    1. trending_up 3,402 views
    2. thumb_up 5 thanks given
    3. group 7 followers
    1. forum 8 posts
    2. attach_file 1 attachments




 
Search this Thread

SuperTrendU11 backtesting

  #1 (permalink)
 
GaryD's Avatar
 GaryD 
Orlando, Florida
 
Experience: None
Platform: shoes
Trading: happy
Posts: 6,462 since May 2011

Can anyone explain how to use the indicator "SuperTrendU11" in a simple backtest? I am trying to understand the three settings it offers.

Beyond that, if you know;

1) Can you test just a simple crossover backtest?

and,

2) Can you use it as a trailing stop in a backtest?

and,

3) A real bonus would be if there is a way to have the "Baseline Smoothing" type also be a backtest variable?

Thanks to anyone who can help with this.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


@GaryD :

1) yes, you can test a crossover

2) yes, you can use it as a trailing stop

3) yes, you can select the moving average and offset type

But you need to code the strategy for a backtest.

If you call the SuperTrendU11 from a strategy, you need to

- declare the parameters under variables
- declare the SuperTrend under variables
- then call the SuperTrend in Initialize

Example:

 
Code
#region Variables
private double	multiplier = 2.5; 
private int basePeriod = 13;
private int rangePeriod = 14;       
private bool reverseIntraBar = false;
private anaSuperTrendU11BaseType thisBaseType	= anaSuperTrendU11BaseType.Median; 
private anaSuperTrendU11OffsetType thisOffsetType = anaSuperTrendU11OffsetType.Median; 
private anaSuperTrendU11VolaType thisVolaType = anaSuperTrendU11VolaType.True_Range; 
Indicator.anaSuperTrendU11 mySTU = null;

protected override void Initialize()
{
   mySTU = anaSuperTrendU11(basePeriod, multiplier, rangePeriod, reverseIntraBar, thisBaseType, thisOffsetType, thisVolaType);
...
}

Now, if you want to access the parameters of the strategy for a backtest, you need to serialize them within the strategy.

That is about all.


P.S: I have updated the anaSuperTrendU11 today, as it did not catch the correct baseline period for the Butterworth, Gauss and Supersmoother filters. Please download it again.

Reply With Quote
Thanked by:
  #4 (permalink)
 
GaryD's Avatar
 GaryD 
Orlando, Florida
 
Experience: None
Platform: shoes
Trading: happy
Posts: 6,462 since May 2011


Fat Tails View Post
@GaryD :

1) yes, you can test a crossover

2) yes, you can use it as a trailing stop

3) yes, you can select the moving average and offset type

But you need to code the strategy for a backtest.

If you call the SuperTrendU11 from a strategy, you need to

- declare the parameters under variables
- declare the SuperTrend under variables
- then call the SuperTrend in Initialize

Example:

 
Code
#region Variables
private double	multiplier = 2.5; 
private int basePeriod = 13;
private int rangePeriod = 14;       
private bool reverseIntraBar = false;
private anaSuperTrendU11BaseType thisBaseType	= anaSuperTrendU11BaseType.Median; 
private anaSuperTrendU11OffsetType thisOffsetType = anaSuperTrendU11OffsetType.Median; 
private anaSuperTrendU11VolaType thisVolaType = anaSuperTrendU11VolaType.True_Range; 
Indicator.anaSuperTrendU11 mySTU = null;

protected override void Initialize()
{
   mySTU = anaSuperTrendU11(basePeriod, multiplier, rangePeriod, reverseIntraBar, thisBaseType, thisOffsetType, thisVolaType);
...
}

Now, if you want to access the parameters of the strategy for a backtest, you need to serialize them within the strategy.

That is about all.


P.S: I have updated the anaSuperTrendU11 today, as it did not catch the correct baseline period for the Butterworth, Gauss and Supersmoother filters. Please download it again.




That is how YOU do it... lol!

For a guy who barely understands anything about programming language, is there a simpler way? or am I making it complicated?

Oh, and I now see the gauss baseline thing, may be a problem I was seeing. Thanks so much.

Started this thread Reply With Quote
  #5 (permalink)
 
GaryD's Avatar
 GaryD 
Orlando, Florida
 
Experience: None
Platform: shoes
Trading: happy
Posts: 6,462 since May 2011

I figured it out. It took a few tries to determine what I was looking for, but I managed to get the SuperTrend to function in a backtest for entries and/or exits. I was calling for price to be above, below, equal, etc, and it did not work, but it took at "crosses..."

Started this thread Reply With Quote
  #6 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4


Fat Tails View Post
@GaryD :

1) yes, you can test a crossover

2) yes, you can use it as a trailing stop

3) yes, you can select the moving average and offset type

But you need to code the strategy for a backtest.

If you call the SuperTrendU11 from a strategy, you need to

- declare the parameters under variables
- declare the SuperTrend under variables
- then call the SuperTrend in Initialize

Example:

 
Code
#region Variables
private double	multiplier = 2.5; 
private int basePeriod = 13;
private int rangePeriod = 14;       
private bool reverseIntraBar = false;
private anaSuperTrendU11BaseType thisBaseType	= anaSuperTrendU11BaseType.Median; 
private anaSuperTrendU11OffsetType thisOffsetType = anaSuperTrendU11OffsetType.Median; 
private anaSuperTrendU11VolaType thisVolaType = anaSuperTrendU11VolaType.True_Range; 
Indicator.anaSuperTrendU11 mySTU = null;

protected override void Initialize()
{
   mySTU = anaSuperTrendU11(basePeriod, multiplier, rangePeriod, reverseIntraBar, thisBaseType, thisOffsetType, thisVolaType);
...
}

Now, if you want to access the parameters of the strategy for a backtest, you need to serialize them within the strategy.

That is about all.


P.S: I have updated the anaSuperTrendU11 today, as it did not catch the correct baseline period for the Butterworth, Gauss and Supersmoother filters. Please download it again.

Hi Fat Tails,

sorry to bother you, but I am incurring in the following message error when attempting to optimize the values of anaSuperTrendU11 in StrategyAnalyzer:



Below is the code I am using, I would really appreciate if you could tell me what I am doing wrong. Thanksfor your help, and wish you a good day

 
Code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion

namespace NinjaTrader.Strategy
{
    [Description("")]
    public class aaaAnaSuperTrendLong : Strategy
    {
    
        #region Variables
		
		private int period = 14;
		private int multiplier = 2;
		private int rngPeriod = 4;
		private bool reverseIntraBar = false;
		private anaSuperTrendU11BaseType thisBaseType	= anaSuperTrendU11BaseType.TEMA; 
		private anaSuperTrendU11OffsetType thisOffsetType = anaSuperTrendU11OffsetType.Default; 
		private anaSuperTrendU11VolaType thisVolaType = anaSuperTrendU11VolaType.Standard_Deviation; 
		Indicator.anaSuperTrendU11 mySTU = null;

        #endregion

        protected override void Initialize()
        {
			mySTU = anaSuperTrendU11(period, multiplier, rngPeriod, reverseIntraBar, thisBaseType, thisOffsetType, thisVolaType);
			Add(anaSuperTrendU11(period, multiplier, rngPeriod, reverseIntraBar, thisBaseType, thisOffsetType, thisVolaType));
            CalculateOnBarClose = true;
			EntryHandling 	=	EntryHandling.UniqueEntries;
			ExitOnClose = false;
		}
        
        protected override void OnBarUpdate()
        {							

			//StopLoss Reset
			if (Position.MarketPosition == MarketPosition.Flat)
				SetStopLoss(CalculationMode.Ticks,100);
				
			//Enter Long
			if (CrossAbove(...))
				EnterLong("Long");

			//Set StopLoss anaSuperTrendU11
			if (Position.MarketPosition == MarketPosition.Long)
             SetStopLoss(CalculationMode.Price,Instrument.MasterInstrument.Round2TickSize(anaSuperTrendU11(period, multiplier, rngPeriod, reverseIntraBar, thisBaseType, thisOffsetType, thisVolaType).StopDot[0]));
			
        }

        #region Properties
				
		[Description("")]
        [GridCategory("Parameters")]
        public int Period
        {
            get { return period; }
            set { period = Math.Max(0, value); }
        }
		
		[Description("")]
        [GridCategory("Parameters")]
        public int Multiplier
        {
            get { return multiplier; }
            set { multiplier = Math.Max(0, value); }
        }		
		
		[Description("")]
        [GridCategory("Parameters")]
        public int RngPeriod
        {
            get { return rngPeriod; }
            set { rngPeriod = Math.Max(0, value); }
        }		
	
		[Description("")]
        [GridCategory("Parameters")]
        public bool ReverseIntraBar
        {   get { return reverseIntraBar; }
            set { reverseIntraBar = value; }
        }
 		#endregion
    }
}

Reply With Quote
  #7 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

Please show a screenshot of the parameters.
I replaced the "if (CrossAbove(...))" by an "if (true)", and the optimization works fine...

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
 sburtt 
London, UK
 
Experience: Advanced
Platform: NinjaTrader
Trading: EUR/USD
Posts: 58 since Jul 2012
Thanks Given: 3
Thanks Received: 4


sam028 View Post
Please show a screenshot of the parameters.
I replaced the "if (CrossAbove(...))" by an "if (true)", and the optimization works fine...

effectively your right, i tried that, I was using the multiplier with a double instead of int value. thanks!

Reply With Quote
Thanked by:
  #9 (permalink)
 curleta 
Olivos, Buenos Aires, _Argentina
 
Experience: Intermediate
Platform: ninjatrader
Trading: futures
Posts: 52 since Nov 2014
Thanks Given: 14
Thanks Received: 2

Hello guys ..

He has served this indicator ranges 1 minute, 3 minutes or f5 minutes?
that difference with the "chandelier stop" that also takes the trend?


they rank them work better? I have not tried it but I think it is not like any other trend indicator, I think it really is very good.

sorry for my English ..
thanks

Reply With Quote




Last Updated on December 8, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts