I am trying to teach myself a little bit about coding so I can test various automated strategies.
Can someone explain in basic English the order of operations and logic used (in English) for the stop loss in this script? For example, does the stop loss get used whenever the price is .1% against the trade, or does there need to be a moving average cross against the position first? I can't quite figure out the logic of how this is coded just by looking at the chart.
Unfortunately since this is raw code I can't use the automated strategy builder to tweak the stop loss settings, so I have to learn some code it appears. Thanks in advance.
namespace NinjaTrader.NinjaScript.Strategies
{
public class VervootCrossKK : Strategy
{
private ZeroLagHATEMA zLagHATEMA;
private ZeroLagTEMA zLagTEMA;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Sylvain Vervoort's minimal lag moving average crossover strategy as outlined in May 2008's issue of Traders' Tips for Stocks & Commodities magazine.";
Name = "VervootCrossKK";
Calculate = Calculate.OnBarClose;
BarsRequiredToTrade = 20;
IsInstantiatedOnEachOptimizationIteration = true;
protected override void OnBarUpdate()
{
if (CrossAbove(zLagTEMA, zLagHATEMA, 1))
EnterLong();
else if (CrossBelow(zLagTEMA, zLagHATEMA, 1))
ExitLong();
}
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Period", Description = "Numbers of bars used for calculations", Order = 1, GroupName = "Parameters")]
public int Period
{ get; set; }
}