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

Three questions about SetParabolicStop (running in realtime)

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

    Three questions about SetParabolicStop (running in realtime)

    1. I'd like to change the quantity of stops much like I can do with a stop order in ChangeOrder like so:

    ChangeOrder(stopOrder, stopOrder.Quantity-1, 0, Position.AveragePrice);

    2. My target orders were working fine until I added some logic in OnExecutionUpdate to use SetParabolicStop as follows:

    if(useTrailStop) // set as a boolean parameter at startup
    SetParabolicStop("SE", CalculationMode.Ticks, 10, true, 0.03, 0.3, 0.01);


    else stopOrder = ExitShortStopMarket(0, true, execution.Order.Filled, execution.Order.AverageFillPrice + stopLoss * TickSize, "SS", "SE");
    if (!tpSet){
    targetOrder = ExitShortLimit(0, true, execution.Order.Filled-1, execution.Order.AverageFillPrice - takeProfit * TickSize, "ST", "SE");
    tpSet = true; // only set 1 takeProfit order. Second one moved to BE and trailed
    chasePrice = execution.Order.AverageFillPrice - takeProfit * TickSize;


    }​

    ... Suddenly target orders are not being set any longer. Logs show they are being submitted but I'm not seeing any news on why they're not being accepted. Documentation says one can't combine stop orders and parabolic orders for the same position but I wouldn't think that also refers to target orders, does it?

    3. In the logs, the Parabolic Stops are working fine but the insist on not being MarketifTouched. See image from log. Does not matter if they are simulated stops or not.

    Many thanks for your time.

    Mark

    Last edited by markdshark; 03-29-2023, 12:46 PM.

    #2
    Hello, thanks for writing in.

    1. To modify the orders made with Set methods, you must call the same method again with the updated parameters, keeping the same "FromEntrySignal".

    2. You can not use Exit orders and Set orders at the same time. See the order handling rules here:
    https://ninjatrader.com/support/help...rnalOrderHandl ingRulesThatReduceUnwantedPositions
    "Set() methods that generate orders to exit a position will be ignored if:

    •A position is open and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction

    •A position is open and an order submitted by a non market order exit method (ExitLongLimit() for example) is active​"

    3. I will test this on my end and see what happens when isSimulatedStop is enabled.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      When I use SetParabolicStop it will submit a trigger pending order, it will not submit an MIT order, although this acts the same way as an MIT order by submitting a market order if the price it touched:
      Attached Files
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Thanks Chris. I'm good with question 3. Minor clarifications on 1 and 2 please:

        1. So for SetParabolicStop("LE", CalculationMode.Ticks, 10, true, 0.03, 0.3, 0.01); if "LE" originally had 2 orders and now has 1 for whatever reason, then calling the same code again: SetParabolicStop("LE", CalculationMode.Ticks, 10, true, 0.03, 0.3, 0.01); will now replace the existing 2 parabolic stops with a single one, correct? Because the syntax does not appear to offer a way to call SetParabolic... With an order quantity.

        SetParabolicStop(CalculationMode mode, double value)
        SetParabolicStop(stringfromEntrySignal,CalculationModemode,doublevalue,boolisSimulatedStop,doubleacceleration,doubleaccelerationMax,doubleaccelerationStep)


        2. So then the only way for item 2 would be to monitor price via onMarketUpdate and fire a market order to exit when marketUpdate.last = some value

        Thanks!

        Comment


          #5
          Hi Mark,

          For 1. There is no way to exit a portion of a position with one set of stops and targets. You first need to call EnterLong twice with unique signal names and target each order with its own SetParabolicStop/SetProfitTarget method e.g. in pseudocode

          Code:
          EntriesPerDirection = 2; //in State.SetDefaults
          ...
          SetParabolicStop("LE0", ...);
          SetProfitTarget("LE0", ...);
          EnterLong(1, "LE0");
          
          SetParabolicStop("LE1", ...);
          SetProfitTarget("LE1", ...);
          EnterLong(1, "LE1");
          ​For 2. You can just submit a Market Exit order to quickly exit the position and cancel the stop and target.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            I suppose it's not possible to use the SetParabolicStop order based on a different dataseries?

            Comment


              #7
              Hi Mark, Unfortunately, It is not possible. This is noted in the SetParabolicStop documentation:

              Should you have multiple Bars objects of the same instrument while using SetParabolicStop() in your strategy, you should only submit orders for this instrument to the first Bars context of that instrument. This is to ensure your order logic is processed correctly and any necessary order amendments are done properly.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Do we have access to the C# code for SetParabolicStop()?

                Comment


                  #9
                  Hi Mark, the SetParabolicStop() code is not available but it does work similarly to the ParabolicSAR that is available to view in the Indicators folder.

                  Kind regards,
                  -ChrisL​
                  Chris L.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Gerik, Today, 09:40 AM
                  2 responses
                  6 views
                  0 likes
                  Last Post Gerik
                  by Gerik
                   
                  Started by RookieTrader, Today, 09:37 AM
                  2 responses
                  10 views
                  0 likes
                  Last Post RookieTrader  
                  Started by alifarahani, Today, 09:40 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by KennyK, 05-29-2017, 02:02 AM
                  3 responses
                  1,285 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  11 responses
                  186 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X