I've been updating the Price Action Order Entry Buttons to enter with limit orders but have ran into an issue where the Stop(ExitStopMarket) and Profit Targets(ExitLimit)t don't match the actual order entry number.
Now this only happens when trading Futures and only on playback (Historical or Market Replay).
Made a quick video to show what happens. The first trades, only ES and NQ do not set proper limit or Stop. TSLA works just fine.
On the 2nd trade, I switched it to a Market order instead of Limit. Then All of them work properly.
>>>>>>>>>>>>>>>>>>>>>>>>
Please see the video link below:
LimitOrderEntryIssue
>>>>>>>>>>>>>>>>>>>>>>>>
Works perfectly fine with the following conditions:
-With Stocks
-Futures Work when trading Real time (With Sim Account)
-Playback Futures with 'Market Order' only.
Conditions where it doesn't set proper Stop and Profit (All 3 have to be met to not work):
-Only on Playback (Historical or Market Replay)
-Only with Futures
-Only when using Limit Order to enter.
I made a quick simple strategy to try and narrow down the root of the problem but the same issue still exists. (Same from video)
namespace NinjaTrader.NinjaScript.Strategies.TradeSimpleStrategies.CurrentTest
{
public class EntryExample : Strategy
{
private bool myFreeTradeShort = true;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = "Entry Example";
Calculate = Calculate.OnEachTick;
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;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if(State != State.Realtime ) return ;
if (CurrentBars[0] < 2)
return;
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>
if ((Close[0] < Low [1])
&& (Position.MarketPosition == MarketPosition.Flat))
{
EnterShortLimit(100, Low[1], "MyEntryShort");
myFreeTradeShort = true;
}
if (Position.MarketPosition == MarketPosition.Short && myFreeTradeShort == true)
{
ExitShortStopMarket(0, true, Position.Quantity, High[1], "MyStopShort", "MyEntryShort");
ExitShortLimit(0, true, Position.Quantity, Low[1] - (High[1] - Low[1]) *3, "MyTargetShort", "MyEntryShort");
myFreeTradeShort = false;
}
}
}
}
Please let me know if there is an oversight on my end or if this just the nature of Futures with the playback feature.
Thank you!

Comment