Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order fill resolution in Strategy Analyzer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Order fill resolution in Strategy Analyzer

    Hello,

    I have an strategy that uses an indicator in 30 min timeframe and this indicator needs tick replay mode to works.

    I need to run backtesting to this, using ES at 30 min timeframe but filling the orders at tick granularity. It is not possible to do this, because the indicator needs tick replay to work. So, how could I change the code in order to the strategy allways take the indicator data from 30 min TF (enabling the tick replay feature), but fills the orders with 1 tick resolution data?

    This is the original code:

    namespace NinjaTrader.NinjaScript.Strategies.GomPro
    {
    public class GomOFNakedPOCSampleStrat : Strategy
    {
    private Indicators.GomPro.GomOrderFlowProLevels GomOrderFlowProLevels1;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Fades closest naked POC";
    Name = "GomOFNakedPOCSampleStrat";
    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;
    Target = 10;
    Stop = 10;
    MinimumAge =5;
    }
    else if (State == State.Configure)
    {
    SetProfitTarget("L", CalculationMode.Ticks, Target);
    SetStopLoss("L", CalculationMode.Ticks, Stop, false);
    }
    else if (State == State.DataLoaded)
    {
    // you can use the ninja strategy builder to get the correct initializer
    // here are the enums:

    // public enum DeltaCalcType {BidAsk,UpDownTick};
    // public enum ImbalanceComparisonType { Ratio, Difference };
    // public enum ImbalanceTypeType { Diagonal, Horizontal, Both };


    GomOrderFlowProLevels1 = GomOrderFlowProLevels(Close, Gom.DeltaLib.DeltaCalcType.BidAsk, -1, 0, 1, false,
    Gom.OrderFlow.ImbalanceDirectionType.Diagonal, Gom.OrderFlow.ImbalanceComparisonType.Ratio, 3,
    Gom.OrderFlow.ImbalanceDirectionType.None, Gom.OrderFlow.ImbalanceComparisonType.Ratio, 3,
    0,-1, 3, 0, Gom.OrderFlow.SRZoneEndConditionType.FullCandleCro ss, 1, false);

    }

    }

    protected override void OnBarUpdate()
    {
    if (IsFirstTickOfBar)

    {

    GomOrderFlowProLevels1.Update();
    double price=0;
    bool found=false;

    // for each level like NakedPOCLow1, we have to check is the data series actually contains a number.
    // NakedPOCLow1BarsAgo contains the "age" of the naked poc, ie how many bars ago it created.

    if ( GomOrderFlowProLevels1.NakedPOCLow1.IsValidDataPoi nt(0) && // check if value is populated
    GomOrderFlowProLevels1.NakedPOCLow1BarsAgo[0] >=MinimumAge) // check if poc is old enough
    {
    found=true;
    price=GomOrderFlowProLevels1.NakedPOCLow1[0]; // get the poc
    }
    //same for second level
    else if ( GomOrderFlowProLevels1.NakedPOCLow2.IsValidDataPoi nt(0) && // check if value is populated
    GomOrderFlowProLevels1.NakedPOCLow2BarsAgo[0] >=MinimumAge) // check if poc is old enough
    {
    found=true;
    price=GomOrderFlowProLevels1.NakedPOCLow2[0]; // get the poc
    }

    // etc etc all levels can be checked




    if (found)
    EnterLongLimit(Convert.ToInt32(DefaultQuantity), price, @"L");


    }
    }

    Thanks!

    #2
    Hi federicoo, thanks for your question.

    You must use the order entry method overload that accepts a BarsInProgressIndex. If your 1 tick series were the only added data series (BarsArray[1]) you would submit the Long Limit order like this:
    EnterLongLimit(1, true, Convert.ToInt32(DefaultQuantity), price, @"L")

    Please let me know if I can assist any further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X