Hi, I am having an issue with my Intrabar strategy, I would like the executions intrabar to occur on crossover's intrabar. Most of the time there is multiple crossover events intrabar but my strategy is only executing once per bar. Ocassionally running it on sim with live data I will get multiple triggers on the same bar, but I think there is something wrong with my code. Please help
Is there a method to calculate faster than each tick? I'm building a high frequency strategy and will need the quickest execution when crossovers occur.
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class PriceActionBotV2 : Strategy
{
private Line X Line X1;
private Line Y Line Y1;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "PriceActionBotV2";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.High;
OrderFillResolutionType = BarsPeriodType.Minute;
OrderFillResolutionValue = 1;
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)
{
Line X1 = Line X(Close);
Line Y1 = Line Y(Close);
Line X1.Plots[0].Brush = Brushes.Navy;
Line Y1.Plots[0].Brush = Brushes.Orange;
AddChartIndicator(Line X1);
AddChartIndicator(Line Y1);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if (CrossAbove(Line X1, Line Y1, 1))
{
EnterLong(Convert.ToInt32(DefaultQuantity), @"long");
}
// Set 2
if (CrossBelow(Line X1, Line Y1, 1))
{
EnterShort(Convert.ToInt32(DefaultQuantity), @"short");
}
}
}
}
Comment