Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

scalein - scaleout - stoploss

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

    scalein - scaleout - stoploss

    Hello,

    there are several questions about how to scale in and to scale out with NinjaTrader. Scale in and scale out is possible with different entry-names (it is also possible with one entry-name and using exitshortstop/exitlongstop but I want to be clear about setstoploss).

    When there are eg 2 setups for entries with different names

    kL1a (scale in 1)
    kL1b (scale in 2)
    kL1c (scale in 3)
    (auto entry long at key-reversalbar)

    mL1a
    mL1b
    mL1c
    (manual entry long 3 contracts)

    For having accurate stoplosses one need to do
    SetStopLoss("kL1a",CalculationMode.Ticks, x, false);
    SetStopLoss("kL1b",CalculationMode.Ticks, y, false);
    SetStopLoss("kL1c",CalculationMode.Ticks, z, false);

    SetStopLoss("mL1a",CalculationMode.Ticks, x, false);
    SetStopLoss("mL1b",CalculationMode.Ticks, y, false);
    SetStopLoss("mL1c",CalculationMode.Ticks, z, false);

    We do an entry with one of the setups, eg the "kL1" entries are filled.

    The output window shows (even when there is only entry kL1a, kL1b and kL1c):

    17.11.2013 03:50:59 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='kL1a' Mode=Ticks Value=8 Currency=0 Simulated=False
    17.11.2013 03:50:59 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='kL1b' Mode=Ticks Value=9 Currency=0 Simulated=False
    17.11.2013 03:50:59 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='kL1c' Mode=Ticks Value=10 Currency=0 Simulated=False
    17.11.2013 03:50:59 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='mL1a' Mode=Ticks Value=8 Currency=0 Simulated=False
    17.11.2013 03:50:59 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='mL1b' Mode=Ticks Value=9 Currency=0 Simulated=False
    17.11.2013 03:50:59 Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='mL1c' Mode=Ticks Value=10 Currency=0 Simulated=False
    17.11.2013 03:50:59 Entered internal SetStopTarget() method: Type=Stop

    Chart trader shows correctly 3 stops for kL1a, kL1b and kL1c.
    Why do appear the stoplosses for both setups in outputwindow? Can there be issues in live-trading with these stops? Is it possbile that there are eg 3 entries but 2x3 stoplosses on the exchange, so that one can have naked positions when market turns other direction?

    And referring to the "samplescaleout" I want to ask if the "basic" setstoploss immediately with the entry should be in initialize like in samplescaleout or it should be in onbarupdate with "if Position...flat" like in other samples.

    Thank you in advance for clearifying this for everyone who tries to scalein and scaleout and is not a programmer or working with Iorders


    Best regards
    Tony
    Last edited by tonynt; 11-22-2013, 04:20 AM. Reason: typing error

    #2
    Hi Tony, first of all your understanding is correct, in managed mode you want to scale in first to be able to scale out later on.

    The set's should only make it to the output window when called upon. The 3:50 time is you entry time as well, correct?

    If you see one set of orders for your strategy position, or individual orders per each entry execution would depend on the Stop and Target submission setting your strategy is set to use.

    A initial static stop would be best placed in Initialize(), this way it's attached to each entry execution immediately, if you want to dynamically modify the values you would need to call this method again in OnBarUpdate() and provide the new values to change to. This would be the same for SetStopLoss and SetProfitTarget.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hello Bertrand,

      thank you for your reply. The stoplosses are in output window when enabling the strategies (without entries)

      I do not understand "If you see one set of orders for your strategy position, or individual orders per each entry execution would depend on the Stop and Target submission setting your strategy is set to use." Sorry.

      I do not use Targets. My question is referring the stoplosses. The stop submission is with setstoploss in initialize and modified in onbarupdate.

      As there appear the stops for both setups in the output window, can it happen that there are 3 stops on the exchange for the 3 entries and also 3 stops for the other setup that has not yet been causing entries because conditions not true, this question is because the stops also of the "not-yet-filled" entries appear in the output window.

      With Iorders I could manage in onexcution which stops were filled, there was no stop from another setup with entries not filled and no stop of not-yet-filled entries showing in the output window.

      I hope I could explain my question more accurately.

      Thank you for your support.

      Best regards
      Tony



      Originally posted by NinjaTrader_Bertrand View Post
      Hi Tony, first of all your understanding is correct, in managed mode you want to scale in first to be able to scale out later on.

      The set's should only make it to the output window when called upon. The 3:50 time is you entry time as well, correct?

      If you see one set of orders for your strategy position, or individual orders per each entry execution would depend on the Stop and Target submission setting your strategy is set to use.

      A initial static stop would be best placed in Initialize(), this way it's attached to each entry execution immediately, if you want to dynamically modify the values you would need to call this method again in OnBarUpdate() and provide the new values to change to. This would be the same for SetStopLoss and SetProfitTarget.
      Last edited by tonynt; 11-22-2013, 07:19 AM.

      Comment


        #4
        Tony, the stops would only be actually submitted in if there was a managed position open from the script that would listen to the specified entry name > otherwise those would be ignored.

        Both modes to submit exits for a strategy are further explained here - http://www.ninjatrader.com/support/h...EntryExecution
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hello,

          another question in this concern please. I can bring up setstoploss in onbarupdate like
          stop1=DonchianChannel(3).Lower[1]-2*TickSize;
          SetStopLoss("kL5a",CalculationMode.Price, stop1, false);
          SetStopLoss("kL5b",CalculationMode.Price, stop1, false);

          When it is better to do the initial stoplosses in Initialize how can I work with variables like "stop1" here in this example in Initialize?

          Thank you!
          Tony

          Originally posted by NinjaTrader_Bertrand View Post
          Tony, the stops would only be actually submitted in if there was a managed position open from the script that would listen to the specified entry name > otherwise those would be ignored.

          Both modes to submit exits for a strategy are further explained here - http://www.ninjatrader.com/support/h...EntryExecution

          Comment


            #6
            Hi Tony, it would not be useful to try setting this case in Initialize(), since to be able to update the stops dynamically > you have to be in OnBarUpdate(), calculate your values and then process the updates. Initialize() is useful for static stops, i.e. always 12 ticks. The 12 tick value then could be for sure a variable / user input.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hello Bertrand,

              thank you for your reply.

              Please let me be more accurate referring to your reply.

              It "would not be useful" to try this or it "is not possible"?

              Please let me explain: It is useful to do the initial stoploss this way because with tick values one has different prices in fast moving markets and therefore different stop-prices. As one stopline overlays the other one can not see if the stops are correct. With 3 entries (scaling-in) I see a line with "1". Below there is another line but the stop is "1" or is it "2" (with 3 entries). To control this you have to go to the orders tab. This makes no sense or takes to much time. Therefore in my opinion - after 4 years of testing SIM and live - it makes more sense to make an initial stop that will be for all entries at the same price to see with a glance if everything is OK (when having 48 charts on 4 screens I can not "read" the orders tab.)

              Can it be done in Initialize with a variable like I posted (or stop below bar[1]) or another way to have same stop as I tried to explain? And is it not good to do the initialstoploss in onbarupdate with if flat? (this honestly I have not understood with your first answer)

              Thank you for your support!

              Best regards
              Tony

              Originally posted by NinjaTrader_Bertrand View Post
              Hi Tony, it would not be useful to try setting this case in Initialize(), since to be able to update the stops dynamically > you have to be in OnBarUpdate(), calculate your values and then process the updates. Initialize() is useful for static stops, i.e. always 12 ticks. The 12 tick value then could be for sure a variable / user input.
              Last edited by tonynt; 11-27-2013, 09:04 AM. Reason: my translation unlogical

              Comment


                #8
                Tony, having a dynamic stoploss that would adjust each bar from Initialize() could not work, this method would not be called each to do the adjustment. That is something you do from OnBarUpdate().

                The strategy could submit one stop order for example for the strategy position though, and not individual ones per entry execution - you can change this for each strategy instance (Stop & Target submission settings).

                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Bertrand,

                  thank you for your reply. Obviously I couldn´t explain correctly. The goal is not to do a dynamic stop in Initialize - I understand. The goal is to do a stop that is the same for all entries/contracts of a trade (triggered at the same time but different for a tick because of moving markets) so that all stops are shown in one price with one number. This does not work with ticks and distance. Does this work somehow? This is the question please.

                  Would it make sense or can be used a stop like

                  double entrybarlow = closes[5][1] - 2 * TickSize; // can this be a fixed with a certain bar like in drawing objects?
                  SetStopLoss("kL5a",CalculationMode.Price, entrybarlow, false);
                  SetStopLoss("kL5b",CalculationMode.Price, entrybarlow, false);

                  Did I miss the answer if one should not do the initial stoploss in onbarupdate with if flat and one should do this in Initialize?

                  If it is not a problem to do the initial stoploss in onbarupdate with if flat (I didn´t understand or read exactly what is the difference) then one need not to do in Initialize.

                  Sorry, if I missed, I dont want to bother.

                  Thank you for your support.

                  Best
                  Tony

                  Originally posted by NinjaTrader_Bertrand View Post
                  Tony, having a dynamic stoploss that would adjust each bar from Initialize() could not work, this method would not be called each to do the adjustment. That is something you do from OnBarUpdate().

                  The strategy could submit one stop order for example for the strategy position though, and not individual ones per entry execution - you can change this for each strategy instance (Stop & Target submission settings).

                  http://www.ninjatrader.com/support/h...t_strategy.htm
                  Last edited by tonynt; 11-27-2013, 10:50 AM. Reason: Typing error

                  Comment


                    #10
                    Hi Tony,

                    double entrybarlow = closes[5][1] - 2 * TickSize;

                    This would need to be certainly done in OnBarUpdate(). It is so to speak a dynamic stop as the offset from entry applied is not static but depending on the actual price value of the referenced bar.

                    When you run your script with the Stop and Target handling ByStrategyPosition you get one stop for the overall position, thus only one order that is amended as new fills come in that would be added to the strategy position.

                    You want to reset your stop always in if flat...if you used a stop in CalculationMode.Price mode, this is to reset the price value used. Otherwise a new entry could use an old set price level.

                    Other than that, I would set a default stop loss in Initialize() and then trail if desired in OnBarUpdate(), just recalling the Set() method for the tied to position > would update the stop.

                    I hope this info helps, Happy Thanksgiving.
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by andrewtrades, Today, 04:57 PM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by chbruno, Today, 04:10 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post chbruno
                    by chbruno
                     
                    Started by josh18955, 03-25-2023, 11:16 AM
                    6 responses
                    436 views
                    0 likes
                    Last Post Delerium  
                    Started by FAQtrader, Today, 03:35 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post FAQtrader  
                    Started by rocketman7, Today, 09:41 AM
                    5 responses
                    19 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X