Adding amaSuperTrendU11 to custom strategy - compile error | Traders Hideout


futures.io - futures trading strategies, market news, trading charts and platforms


Traders Hideout


Discuss day trading practices and futures trading strategies on this forum for all markets. This forum is also for discussing and reviews for brokers, data feeds, and commercial or third party add-ons




 

Adding amaSuperTrendU11 to custom strategy - compile error

  #8 (permalink)

Market Wizard
Berlin, Europe
 
Trading Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker/Data: Interactive Brokers
Favorite Futures: Keyboard
 
Fat Tails's Avatar
 
Posts: 9,798 since Mar 2010
Thanks: 4,236 given, 26,404 received

The amaSuperTrendU11 may be used with automated strategies without restrictions. I have already created a few SuperTrend strategies that were just doing fine.

In case that you do not know, how to call the amaSuperTrendU11 from a strategy, this is what I recommend:

- open the strategy builder and create a simple stop and reverse strategy by using the trend plot from the amaSuperTrendU11
- unlock and compile the strategy to make sure that it works as expected

Now study the code of the strategy and copy what you need. Below is a sample strategy that compiles. I think it will probably answer your questions.

 
Code
public class MyCustomStrategy6 : Strategy
{
private NinjaTrader.NinjaScript.Indicators.LizardIndicators.amaSuperTrendU11 amaSuperTrendU111;

protected override void OnStateChange()
{
	if (State == State.SetDefaults)
	{
		Description						= @"Enter the description for your new custom Strategy here.";
		Name							= "MyCustomStrategy6";
		Calculate						= Calculate.OnBarClose;
		EntriesPerDirection					= 1;
		EntryHandling						= EntryHandling.AllEntries;
		IsExitOnSessionCloseStrategy				= true;
		ExitOnSessionCloseSeconds				= 30;
		IsFillLimitOnTouch					= false;
		MaximumBarsLookBack					= MaximumBarsLookBack.TwoHundredFiftySix;
		OrderFillResolution					= OrderFillResolution.Standard;
		Slippage						= 0;
		StartBehavior						= StartBehavior.WaitUntilFlat;
		TimeInForce						= TimeInForce.Gtc;
		TraceOrders						= false;
		RealtimeErrorHandling					= RealtimeErrorHandling.StopCancelClose;
		StopTargetHandling					= StopTargetHandling.PerEntryExecution;
		BarsRequiredToTrade					= 20;
		// Disable this property for performance gains in Strategy Analyzer optimizations
		// See the Help Guide for additional information
		IsInstantiatedOnEachOptimizationIteration	        = true;
	}
	else if (State == State.Configure)
	{
	}
	else if (State == State.DataLoaded)
	{				
		amaSuperTrendU111 = amaSuperTrendU11(Close, amaSuperTrendU11BaseType.Median, amaSuperTrendU11VolaType.True_Range, amaSuperTrendU11OffsetType.Wilder, false, 8, 15, 2.5);
	}
}

protected override void OnBarUpdate()
{
	if (BarsInProgress != 0) 
		return;
		if (CurrentBars[0] < 1)
	return;

	 // Set 1
	if ((amaSuperTrendU111.Trend[0] > 0)
		 && (amaSuperTrendU111.Trend[1] < 0))
	{
		EnterLong(Convert.ToInt32(DefaultQuantity), "");
	}
		
	 // Set 2
	if ((amaSuperTrendU111.Trend[0] < 0)
		 && (amaSuperTrendU111.Trend[1] > 0))
	{
		EnterShort(Convert.ToInt32(DefaultQuantity), "");
	}
		
}
}

Reply With Quote
The following 2 users say Thank You to Fat Tails for this post: