Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Modify the order to is a valid price for the order type before modifying the order.

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

    Modify the order to is a valid price for the order type before modifying the order.

    Hi guys,

    how can I checking that the price you are attempting to modify the order to is a valid price for the order type before modifying the order.

    Some situation my Auto Strategy stop to work and auto close because i try move stop to a price that not is more valid...

    thank you for help

    #2
    Hello,

    Thank you for the post.

    Can you provide more detail on where you are currently doing this change from? Is this from OnBarUpdate? Also, are you using the Set methods to set the Stop order, for example, SetStopLoss?

    In most cases, you would need to confirm the price you are moving the order to will be valued based on the current Close price, if the order price ends up on the opposite side of the market it would not be valid.

    The most common way to do this would be to check the Close[0] price, this would likely be the solution if you are using OnBarUpdate to make this modification. If you are using a number of Ticks and SetStopLoss, you may need to calculate the price that would be generated based off the current Close and the number of Ticks you supply.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse, Thank you for your support,
      My strategy working OnBarUpdate , and i user SetStopLoss, SetProfitTarget
      the script that i use to set, enter, stop and management.


      protected override void OnBarUpdate()

      set stops targets
      SetStopLoss("Target1", CalculationMode.Price, Fib100, false);
      SetProfitTarget("Target1", CalculationMode.Price, Fib000);

      limit orders.
      myEntryOrder236_1 = EnterShortMIT(0, true , Convert.ToInt32(Qct1), Fib236, "Target1");

      cancel limit if not fill.
      CancelOrder(myEntryOrder236_1);

      Trailing stop. the problems is here, i think is because of spread.
      SetStopLoss("Target1", CalculationMode.Price, ParabolicSAR1[0] + (1 * TickSize), false);


      I need a confirmation if the price is valid before I move the stop, if no have bid/ask or price is above/below stop it not move...



      log
      1/30/2018 10:39 Default Disabling NinjaScript strategy '/121473174'

      1/30/2018 10:39 Order vitorino1127, Unable to submit order change request: Order rate must be within 1 - 1000 points affected Order: BuyToCover 1000 StopMarket @ 108.751

      1/30/2018 10:39 Order Order='413466156/vitorino1127' Name='Stop loss' New state='Working' Instrument='USDJPY' Action='Buy to cover' Limit price=0 Stop price=108.751 Quantity=1,000 Type='Stop Market' Time in force=GTC Oco='17761403' Filled=0 Fill price=0 Error='Unable to change order' Native error='Unable to submit order change request: Order rate must be within 1 - 1000 points'

      1/30/2018 10:39 Default Strategy '/121473174' submitted an order that generated the following error 'Unable to change order'. Strategy has sent cancel requests, attempted to close the position and terminated itself.

      Comment


        #4
        Hello,

        Thank you for the reply.

        Yes, in this case, you would likely need to check the three variables you are using for prices to ensure they are on the correct side of the market.

        Code:
        SetStopLoss("Target1", CalculationMode.Price, Fib100, false);
        SetProfitTarget("Target1", CalculationMode.Price, Fib000);
        SetStopLoss("Target1", CalculationMode.Price, ParabolicSAR1[0] + (1 * TickSize), false);
        Because you are specifying prices here, you would need to check the Fib100, Fib000, and the Parabolic calculation being used to ensure they are correct when these methods are called. If the price is equal or greater/lesser than the current price, you would need to modify the price being supplied before calling the Set method.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cls71, Today, 04:45 AM
        0 responses
        1 view
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        213 views
        1 like
        Last Post PaulMohn  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        4 responses
        544 views
        0 likes
        Last Post PaulMohn  
        Started by GLFX005, Today, 03:23 AM
        0 responses
        3 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        12 views
        0 likes
        Last Post XXtrader  
        Working...
        X