Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SL ab einer bestimmten Tickzahl nachziehen

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

    SL ab einer bestimmten Tickzahl nachziehen

    Hallo, ich habe eine Strategie im StrategyBuilder programmiert. Jetzt muss ich nur noch eine Kleinigkeit dazu programmieren, dies ist aber im StrategyBuilder nicht möglich.
    Wie kann ich den SL ab einer bestimmten erreichten Tickanzahl auf einen bestimmten Wert zum Einstieg ziehen?
    Oder gibt es hier jemanden, der das für mich programmieren könnte?

    Vielen Dank schonmal.
    Hello, I have programmed a strategy in StrategyBuilder. Now I just need to program a little something to it, but this is not possible in StrategyBuilder.
    How can I pull the SL from a certain reached tick count to a certain value to enter?
    Or is there someone here who could program this for me?

    Many thanks already.
    Last edited by NinjaTrader_Jim; 01-25-2022, 01:12 PM. Reason: Translation from https://www.deepl.com/ added

    #2
    Welcome to the forums c_schmitti!

    Thanks for your post.

    I am including some information on how you can move the stop loss to the breakeven point, and I am including a more advanced example that demonstrates how you can make some custom logic to manage your stop loss with Conditions and Actions in the Strategy Builder.

    If you instead want to move an entry order, this is similar to moving an Exit order in Conditions and Actions. Simply make another condition that would call the Enter order method (using the same signal name) with the new price you want to move the order to. This is similar to what is demonstrated in the Multi Step Breakeven example attached.

    More advanced examples on how to move the stop loss in the Strategy Builder can be found below.



    If this does not resolve your inquiry, could you elaborate on your intentions? Screenshots can help, and publicly available language translators like DeepL can help us assist you further.
    Attached Files

    Comment


      #3
      Super Vielen Dank. Das hat mir sehr weitergeholfen.
      Thank you very much. This has helped me a lot.
      Last edited by NinjaTrader_Jim; 01-27-2022, 11:09 AM. Reason: Translation added.

      Comment


        #4
        Die Logik funktioniert soweit prima, aber ein kleines Problem habe ich noch.
        Bei ganz wenigen Verlusttrades wird der St opLoss überlaufen und der Trade bleibt aktiv. s. Bilder
        Woran kann das liegen?
        The logic works fine, but I still have a small problem. With very few losing trades the StopLoss is overflowed and the trade remains active. see pictures What could be the reason for this?
        Last edited by NinjaTrader_Jim; 01-27-2022, 11:08 AM. Reason: Translation added

        Comment


          #5
          Hier habe ich ein gutes Beispiel gefunden.
          Der erste Kauf wird mit 12 Tick im Stoploss beendet.
          Der zweite Kauf wird nicht mit Stoploss beendet und läuft bis zu ExitonSessionClose
          Warum?
          Here I have found a good example.
          The first buy is ended with 12 tick in stoploss.
          The second buy is not ended with stoploss and runs until ExitonSessionClose.
          Why?
          Last edited by NinjaTrader_Jim; 01-27-2022, 11:21 AM. Reason: Translation added

          Comment


            #6
            Hello c_schmitti,

            Please be sure to post English translations of your messages using an online translator so our staff and the community can assist and learn from this thread.

            The first things to check:
            • Is this a historical order or a realtime order? Realtime can be tested with Market Replay data in the Playback Connection. Historical can be tested on a chart or in the Strategy Analyzer.
            • Do you see any errors in the log tab of the Control Center? These can hint to if an order got rejected, and can also point out other errors that can be helpful when diagnosing strategy behavior.
            The next thing to do whenever a order is expected to be submitted and is not submitted is to reproduce the issue so it can be analyzed with debugging prints. You would want to know:
            • Are my order submission methods being reached?
            • If the order submission methods are not reached, it would mean the logic did not allow the order submission method to be reached.
            • If the order submission methods are reached but no order is submitted, the strategy should be re-tested with TraceOrders to see why the order was ignored.
            Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm
            TraceOrders - https://ninjatrader.com/support/help...aceorders2.htm
            Debugging in the Strategy Builder - https://drive.google.com/file/d/1mTq...w?usp=drivesdk
            Playback Connection - https://ninjatrader.com/support/help...connection.htm
            Debugging Demo - https://drive.google.com/file/d/1rOz...w?usp=drivesdk

            If you are backtesting a strategy, and it submits a stop loss that ends up on the other side of the market, the order would be ignored. When testing the strategy with realtime data, the order will be rejected.

            You could also test increasing the distance of the stop to see if it does get accepted with a greater distance, and this can also verify if the stop loss was submitted with an price that end up on the other side of the market. Remember that backtesting is performed bar-by-bar, and there is no intrabar movement in a backtest.

            Last edited by NinjaTrader_Jim; 01-27-2022, 11:24 AM.

            Comment


              #7
              Hallo,

              es sind keinerlei Fehler vorhanden.
              Kann es sein, das der Stoploss nur in der gleichen Kerze in der der Einstieg war nicht ausgeführt wird?
              Im letzten Bild ist gut zu sehen, dass der erste SL ausgeführt wurde, jedoch einer einer anderen Kerze.
              Der zweite Trade wurde nicht ausgestoppt, weil der Stoploss-Wert in der gleichen Kerze überlaufen wurde und in den Folgekerzen nicht mehr erreicht wurde.
              Ist dies möglich???

              Hello,

              there are no errors.
              Can it be that the stoploss is not executed only in the same candle in which the entry was?
              In the last picture you can see well that the first SL was executed, but a different candle.
              The second trade was not stopped out because the stoploss was overrun in the same candle and was not reached in the following candles.
              Is this possible???

              Comment


                #8
                Hello c_schmitti,

                Debugging prints and TraceOrders will tell the tale if your order method was reached, or if it was ignored.

                Set methods in Stops and Targets will have the stop loss submitted upon the execution of the entry order.

                Exit methods will be submitted in Conditions and Actions, so you would be waiting on the next bar when you are in a position to have the exit order submitted.

                So if the next bar after your entry order drops past the initial stop distance, the initial stop could be submitted to an invalid level and the order submission would be ignored in the backtest.
                Last edited by NinjaTrader_Jim; 01-27-2022, 01:35 PM.

                Comment


                  #9
                  Hallo,
                  würde die Stop-Ausführung nur im Backtest fehlerhaft sein und beim Live-Handel dennoch funktionieren?
                  Wenn also der nächste Balken nach Ihrer Entry-Order über den anfänglichen Stop-Abstand fällt, könnte der anfängliche Stop auf einem ungültigen Niveau eingereicht werden und die Order-Übermittlung würde im Backtest ignoriert.

                  Hello,
                  would the stop execution only be incorrect in the backtest and still work in live trading?
                  So if the next bar after your entry order falls above the initial stop distance, the initial stop could be submitted at an invalid level and the order submission would be ignored in the backtest.

                  Comment


                    #10
                    Hello c_schmitti,

                    Thanks for posting with the translation.

                    Before I answer this question, I need to preface the following:

                    Backtesting, realtime simulations, and live trading are all different:
                    • Backtesting is bar by bar, and uses the OHLC of the data series to simulate order fills. By default, there is no intrabar granularity.
                    • Realtime simulations use the realtime market data to simulate order fills. Strategy logic can also be updated following Calculate.OnEachTick and Calculate.OnPriceChange at this time.
                    • Live simulations take place outside of NinjaTrader so the order has to leave NinjaTrader and be processed by the broker/exchange following their rules.
                    Discrepancies between realtime and backtest - https://ninjatrader.com/support/help...ime_vs_bac.htm

                    Now, getting back to the question:

                    If an Exit order is submitted to protect the position from Conditions and Actions, we need to process the bar after the entry is executed when (Position.MarketPosition == MarketPosition.Long).

                    If we are processing OnBarClose or with historical processing, we only process that next bar when it closes. So the Close[0] (current price) of that bar may be further away from the entry price by the time the Exit order is submitted.

                    If we are processing OnEachTick/OnPriceChange with realtime processing, we would process the next bar after the entry is executed on that bar's first tick. So, in that case, the target/stop would be submitted 1 tick after the entry and the current market price would not be as far away from the entry price. This case would answer your question where it would not work in backtest, but would in live.

                    Taking this a step further:

                    Could this be improved so your custom exits are submitted upon the execution of the entry order, rather than waiting for the next tick or bar closure?

                    Yes, this could be improved in an unlocked NinjaScript strategy to submit orders with OnExecutionUpdate. An example can be found below.

                    SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Today, 05:17 AM
                    0 responses
                    53 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    130 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    70 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    44 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    49 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X