Why code made by Strategy Builder is does`n works?
public class smacross1 : Strategy { private SMA SMA1; private SMA SMA2; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Strategy here."; Name = "smacross1"; Calculate = Calculate.OnPriceChange; EntriesPerDirection = 1; EntryHandling = EntryHandling.AllEntries; IsExitOnSessionCloseStrategy = false; 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) { AddDataSeries(Data.BarsPeriodType.Day, 1); } else if (State == State.DataLoaded) { SMA1 = SMA(Closes[1], 2); SMA2 = SMA(Opens[1], 2); } } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 1) return; // Set 1 if (CrossAbove(SMA1, SMA2, 0)) { Draw.Diamond(this, @"smacross1 Diamond_1", false, 0, GetCurrentAsk(0), Brushes.Red); } // Set 2 if (CrossBelow(SMA1, SMA2, 0)) { Draw.Diamond(this, @"smacross1 Diamond_1", false, 0, GetCurrentAsk(0), Brushes.Yellow); } } }
Comment