Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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:
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.
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..."
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
#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
}
}