Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Move to breakeven

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

    #16
    Comment out your null setting and try again.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      Null

      I tried commenting out the null setting in OnPositionUpdate() but the following Print() isnt fired in the OnOrderUpdate:

      if(LongStopGem != null)
      {
      if(LongStopGem.Token == order.Token)
      {
      Print(
      "Order is " + order.ToString() + " \n");

      }
      }

      Similar for OnExecution.

      Using:

      SetStopLoss("LongEntryGem",CalculationMode.Price,Position.AvgPrice+TickSize* commission,true);

      Instead of:

      LongStopGem = ExitLongStop(Position.AvgPrice+TickSize*commission ,
      "LongStopGem","LongEntryGem");

      Does seem to move the stop loss correctly as this is output in the orders/executions however the first method provides a reference to the IOrder object and therefore should actually be more robust. I have just tried putting a try/catch around LongStopGem = ExitLongStop... but the Print() statement in the catch isnt fired. Its appears that this line is ignored completely.

      Comment


        #18
        correction

        In my previous post I meant second method provides a reference to the object.

        Comment


          #19
          mballagan,

          Please just post the script as a whole piece. You are likely resetting it too early or something along those lines.

          The way it works is very simple.

          Variables
          Code:
          private IOrder someOrder = null;
          OnBarUpdate()
          Code:
          someOrder = EnterLong();
          OnOrderUpdate()
          Code:
          if (someOrder != null && someOrder.Token == order.Token)
             // Do something;
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          56 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          143 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          160 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          96 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          276 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X