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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    41 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X