Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code breaking

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

    Code breaking

    HI everybody.

    I don't know if someone has problems with their strategies with all these beta changes but mine is not working anymore and I can't put my finger on the problem...

    I have really weird results like buying selling on the first bar of session when the code makes that impossible. I would like to know where changes occured in NT7 to make this code not work anymore.

    I am using two time frame : 1 minute to buy and sell and 50 ticks to monitor stops so I am using BarInprogress in my code ( 0 = 1 minute; 1= 50 ticks).
    I am also using Token in my order management. So let me show you part of my stop management rules :

    protected override void OnExecution(IExecution execution)
    {

    if (entryBOrder1 != null && entryBOrder1.Token == execution.Order.Token)
    {
    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
    {

    stopSOrder1 = ExitLongStop(1, true, execution.Order.Filled, execution.Order.AvgFillPrice - (stopLoss * TickSize), "MyStop4","TV1 aL");


    targetBOrder1 = ExitLongLimit(1, true, execution.Order.Filled, execution.Order.AvgFillPrice + (firstTarget_Ticks * TickSize), "MyLTarget1","TV1 aL");


    if (execution.Order.OrderState != OrderState.PartFilled)
    {
    entryBOrder1 = null;
    BuyPosition1 = true;
    BuyPosition1AvgPrice = execution.Order.AvgFillPrice;
    }
    }
    }


    if ((stopSOrder1 != null && stopSOrder1.Token == execution.Order.Token) || (targetBOrder1 != null && targetBOrder1.Token == execution.Order.Token)|| (timeSOrder1 != null && timeSOrder1.Token == execution.Order.Token))
    {
    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled)
    {
    timeSOrder1 = null;
    stopSOrder1 = null;
    targetBOrder1 = null;
    BuyPosition1 = false;
    }
    }



    I know that token is not good anymore. Could that be the problem ?

    Should I change my code if yes what would be the new order syntax without token ?

    Has BarInProgress method been modified ?


    Sorry but I am a bit lost with all the beta changes and need some clues to resolve this.


    Thanks

    #2
    blarouche,

    Token can very well be the cause of the issue since the Token can change from when the strategy goes from historical to live. You want to definitely change that in the code first. In NT7 all you have to do is compare the IOrders to each other directly.

    entryBOrder1 == execution.Order

    BarsInProgress should behave the same.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    618 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    561 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    566 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X