I have a simple SMA crossover strategy that runs on whole Nasdaq 100 list.
They are enabled, online and in sync, and I still don't get buy and sell signals on end of day market data. What am I missing?
The only whay for me to get the strategies to run is to de-enable and re-enable them, but this should run automatically or am I wrong?
is there something in my code? See below (partial code)
public class MySMAstrategy : Strategy { private SMA SMA1; private SMA SMA2; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"My simple SMA Strategy"; Name = "MySMAstrategy"; Calculate = Calculate.OnBarClose; EntriesPerDirection = 2; 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) { } else if (State == State.DataLoaded) { SMA1 = SMA(Close, 21); SMA1.Plots[0].Brush = Brushes.LimeGreen; AddChartIndicator(SMA1); SMA2 = SMA(Close, 14); SMA2.Plots[0].Brush = Brushes.Red; AddChartIndicator(SMA2); } } protected override void OnBarUpdate() { if (CurrentBars[0] < 1) return; // Set 1 if (CrossAbove(Close, SMA1, 1)) { Draw.ArrowUp(this, @"KÖP Arrow up_1", false, 0, 0, Brushes.Lime); Log(@"Köp " + Instrument.FullName.ToString() + " til pris: " + Instrument.MarketData, Cbi.LogLevel.Information); //SendMail(@"[email protected]", @"Köpsignal", @"Köp ", Instrument.FullName.ToString()); EnterLong(Convert.ToInt32(DefaultQuantity), ""); } // Set 2 if (CrossBelow(Close, SMA2, 1)) { Draw.ArrowDown(this, @"Sälj Arrow down_1", false, 0, 0, Brushes.Red); Log(@"Sälj " + Instrument.FullName.ToString() + " til pris: " + Instrument.MarketData, Cbi.LogLevel.Information); //SendMail(@"[email protected]", @"Sälj", @"Sälj ", Instrument.FullName.ToString()); ExitLong(Convert.ToInt32(DefaultQuantity), "", ""); }
Can I write to a textfile instead of the log?
Comment