Can you please help me understand why I can't get my "Prior Day Close" script to work ,I am trying to short when the price cross the Prior day close.But the Strategy analyzer isn't giving any output. Below is my actual script :
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class PDAYCLOSE : Strategy
{
private PriorDayOHLC PriorDayOHLC1;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "PDAYCLOSE";
Calculate = Calculate.OnPriceChange;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.UniqueEntries;
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 = 5;
// 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)
{
PriorDayOHLC1 = PriorDayOHLC(Close);
SetStopLoss(@" ", CalculationMode.Ticks, 100, false);
SetProfitTarget("", CalculationMode.Ticks, 200);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if (CrossBelow(PriorDayOHLC1.PriorClose, PriorDayOHLC1.PriorClose, 0))
{
EnterShort(Convert.ToInt32(DefaultQuantity), @"");
}
}
}
}
#region Wizard settings, neither change nor remove
Thanks in Advance
Comment