https://youtu.be/jZQbBKk_gos?t=1738
Below my code and in attachment.
The strategy is enabled.
https://i.imgur.com/uB3qNTU.png
Text and Markers is enabled:
For some reason nothing displays on the chart.
What's wrong?
How to fix it?
#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.Indicators; using NinjaTrader.NinjaScript.DrawingTools; #endregion //This namespace holds Strategies in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Strategies { public class Test2 : Strategy { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Strategy here."; Name = "Test2"; 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; ProfitTarget = 25; StopLoss = 25; } else if (State == State.Configure) { SetProfitTarget("", CalculationMode.Ticks, ProfitTarget); SetStopLoss("", CalculationMode.Ticks, StopLoss, false); } } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 2) return; // Set 1 if ((High[0] > High[1]) && (High[1] > High[2]) && (Times[0][0].TimeOfDay >= new TimeSpan(9, 30, 0)) && (Times[0][0].TimeOfDay <= new TimeSpan(11, 50, 0))) { EnterLongLimit(Convert.ToInt32(DefaultQuantity), 0, ""); } // Set 2 if ((High[1] > High[2]) && (High[0] > High[1]) && (Times[0][0].TimeOfDay <= new TimeSpan(11, 50, 0)) && (Times[0][0].TimeOfDay >= new TimeSpan(9, 30, 0))) { ExitShortLimit(Convert.ToInt32(DefaultQuantity), 0, "", ""); } } #region Properties [NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="ProfitTarget", Order=1, GroupName="Parameters")] public int ProfitTarget { get; set; } [NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="StopLoss", Order=2, GroupName="Parameters")] public int StopLoss { get; set; } #endregion } }
Comment