• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 seagraph, Today, 03:27 PM
        0 responses
        11 views
        0 likes
        Last Post seagraph  
        Started by dedouglas, Today, 02:54 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by elkhatabi, 08-01-2019, 06:36 PM
        5 responses
        53 views
        0 likes
        Last Post NinjaTrader_RyanL  
        Started by mr_trade, Today, 01:01 PM
        4 responses
        19 views
        0 likes
        Last Post mr_trade  
        Started by Renorail, Today, 12:31 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Working...
        X