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

When to use different ProfitChaseStopTrail Examples

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

    When to use different ProfitChaseStopTrail Examples

    Hello Chelsea,

    Where can I find a brief description on when to use the three examples (pros and cons) you have kindly provided below? Thanks.

    ProfitChaseStopTrailExitOrdersExample_NT8
    ProfitChaseStopTrailSetMethodsExample_NT8
    ProfitChaseStopTrailUnmanagedExample_NT8



    #2
    Hi billythekid72, thanks for your question. I've moved this to a new topic, the question in reference to this set of examples:



    The Unmanaged example vs the two managed approach examples difference will be known by reading about the managed approach and the unmanaged approach:




    There is a bit more flexibility when using Exit orders vs the Set methods. You can assign Exit orders to an Order object and control them more easily. Theres an example on this page here:


    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chris, this is exactly what I need.

      Comment


        #4
        Hello,

        I printed out the number of total trades in each of the 3 examples provided (see code snippets below), and found out the total number of trades in each example is different from each other, Each of the example was run in the Strategy Analyzer with identical settings, using 2000 ticks on ES instrument, starting date 1/1/20, end date 7/18/20.

        ProfitChaseStopTrailSetMethodsExample:: tradeCount 34266

        ProfitChaseStopTrailExitOrdersExample:: tradeCount 55308

        ProfitChaseStopTrailUnmanagedExample:: tradeCount 55367

        Why should this be the case? The number of EnterLong trades should ALL have the same number of EnterLong trade count. Please advice.

        1, for the ProfitChaseStopTrailUnmanagedExample
        else if (!exitOnCloseWait && entryOrder == null && profitTarget == null && stopLoss == null)
        {
        Print(string.Format("ProfitChaseStopTrailUnmanaged Example:: tradeCount {0}", tradeCount++));

        entryName = "entry";
        entryOrder = placeHolderOrder;
        SubmitOrderUnmanaged(1, OrderAction.Buy, OrderType.Market, 1, 0, 0, string.Empty, entryName);
        }

        2, for the ProfitChaseStopTrailExitOrdersExample
        else if (!exitOnCloseWait && entryOrder == null && profitTarget == null && stopLoss == null)
        {
        Print(string.Format("ProfitChaseStopTrailExitOrder sExample:: tradeCount {0}", tradeCount++));

        suppressOco = false;
        entryOrder = placeHolderOrder;
        EnterLong(1, 1, "entry");
        }

        3, for the ProfitChaseStopTrailSetMethodsExample
        else if (!exitOnCloseWait && Position.MarketPosition == MarketPosition.Flat)
        {
        // Reset the stop loss to the original distance when all positions are closed before placing a new entry

        currentPtPrice = Close[0] + ProfitTargetDistance * TickSize;
        currentSlPrice = Close[0] - StopLossDistance * TickSize;

        if (UseProfitTarget)
        SetProfitTarget(CalculationMode.Price, currentPtPrice);

        if (UseStopLoss)
        SetStopLoss(CalculationMode.Price, currentSlPrice);

        Print(string.Format("ProfitChaseStopTrailSetMethod sExample:: tradeCount {0}", tradeCount++));

        EnterLong(1, 1, string.Empty);
        }
        Last edited by billythekid72; 07-20-2020, 09:44 AM.

        Comment


          #5
          Hi billythekid72, thanks for your reply.

          You will need to use Print methods in the strategies to see what exactly is different here.



          One thing I know right away: the SetTrailStop method updates based on the Calculate property. So if the strategy runs OnBarClose then the trailing stop would only update every bar close as opposed to a stop loss order that is placed in OnOrderUpdate/OnExecutionUpdate, which can be called sooner than the close of every bar if an order gets filled.

          I look forward to assisting.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Hello Chris,

            I have no problem with the print, that's how I got the count result printed out in the output in the first place. The three counts are:

            ProfitChaseStopTrailSetMethodsExample:: tradeCount 34266

            ProfitChaseStopTrailExitOrdersExample:: tradeCount 55308

            ProfitChaseStopTrailUnmanagedExample:: tradeCount 55367

            I did not make any changes to the examples provided by NinjaTrader support, simply printed out the number of trade calls (be it EnterLong() for managed or SubmitOrderUnmanaged() for unmanaged).

            Again, my assumption is regardless of the Managed or Unmanaged examples, the number of trade calls should have been identical under the SAME conditions, in this case ALL 3 examples ran in StrategyAnalyzer using 2000 ticks ES instrument, starting date 1/1/20, end date 7/18/20. The calls of EnterLong() or SubmitOrderUnmanaged() in each 3 example happened in OnBarUpdate() and they should have been identical in counts.

            Please read the question carefully, I await your insight.

            Comment


              #7
              Hello billythekid72, thanks for your reply.

              Can you try the same thing on minute data? I suspect its data related. Tick bars require 1 tick data to build, so the data feed must be able to pull 1 tick data back to 1-1-2020. Also, it's not sufficient to look at only the total number of trades. You must look at the individual trades. To make it easier to test use a shorter time frame to see if the same issue comes up on a smaller set of data (test tick and minute bars). I'm currently running the backtests on 2000 tick bars on the same time frame, so Ill let you know what I get on these backtest results once they are done.

              Kind regards.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Hello,

                I ran the same back test conditions using one minute data as suggested, and again the counts for the calls to EnterLong() and SubmitOrderUnmanaged() are different between the 3 examples:

                ProfitChaseStopTrailExitOrdersExample:: tradeCount 65645

                ProfitChaseStopTrailSetMethodsExample:: tradeCount 48539

                ProfitChaseStopTrailUnmanagedExample:: tradeCount 65707


                My data provider Continuum guarantees one year worth of historical data, when using the 3 examples for back testing under the SAME instrument with IDENTICAL settings, the SAME number of calls for EnterLong() should have been the same for the managed calls, and I would expect the same number of calls to SubmitOrderUnmanaged() for unmanaged calls too. They have to be the same because there should be no different between them except for HOW the calls were managed, as the three examples were intended to show. I would like to request that you have the developer or whomever wrote the codes dive deeper into the reason, because the results do not agree with your reasoning.

                Comment


                  #9
                  Hi billythekid72, thanks for your patience.

                  We should not assume they should behave exactly the same. If you are interested in why it's different you need to print the time, condition values, trace orders, and order object info if you want to know exactly what is different, not just the total number of trades. Each and every execution must be analyzed to see where the difference is coming from.

                  Kind regards.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello,

                    Let me rephrase the question, NinjaTrader provided 3 examples on managing Orders, namely ProfitChaseStopTrailSetMethodsExample, ProfitChaseStopTrailExitOrdersExample and ProfitChaseStopTrailUnmanagedExample. As far as I can tell from the code, they are doing EXACTLY the same thing, making Long order in the OnBarUpdate(). My question is, what makes them different, besides the way the orders are managed, which will cause DIFFERENT number of Long calls counts? Each long call represents a trading opportunity, if less call were made, less trading opportunities, so you can understand why I am interested in exactly what caused the different in number of long calls being made.
                    Last edited by billythekid72; 07-21-2020, 03:47 PM.

                    Comment


                      #11
                      Hi billythekid72, thanks for your reply.

                      The examples are just to demonstrate how to move stop in various ways, they were never meant to replicate each other. By using Print statements, and only testing one day of data, I noticed the unmanaged script is trading sooner than the managed script (this can be seen more easily by switching to the "Chart" view of the strategy analyzer at the top left). That's where the difference is coming from. The code would need to be further unraveled for a more specific answer.

                      Best regards.
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        Thank you for confirming my observation, I await your unraveling.

                        Comment


                          #13
                          Hello billythekid72,

                          We should clarify here:

                          Each approach is different. Results are going to be different.

                          The three strategies use different approaches all with different rules behind them. There is no guarantee that Managed Exits will match Managed Set methods or the Unmanaged approach because these are not apples to apples scenarios. We do not deliver a guarantee that these scripts will match either.

                          These scripts are only meant to demonstrate how to use each approach. Trying to compare and contrast their performance results would exceed the scope of their demonstration.

                          You may review the charts and grid created in the Strategy Analyzer to compare performance, but we want to be clear that this may not be a beneficial study. If you want simplicity, use Set methods, if you want more control, use Exit methods. If you want full control, use the Unmanaged Approach. Each script will show how those approaches can be taken.

                          Please let us know if you have any questions.
                          JimNinjaTrader Customer Service

                          Comment


                            #14
                            The three method examples, regardless of how Orders are managed, ONLY made Long order or the equivalent of it. How do you explain the different between them? What are the differences between them? There is no strategy in the long call except how the orders were managed. Awaiting your insight. Thanks.

                            Comment


                              #15
                              It appears to me that "ProfitTargetDistance" on Line 215 of the "ProfitChaseStopTrailUnmanagedExample" should be "StopLossDistance". That mistake could cause a large result discrepancy if "ProfitTargetDistance" and "StopLossDistance" were set to different values as they commonly would be in real trading. Of course, that doesn't explain the large difference between "ProfitChaseStopTrailExitOrdersExample" and "ProfitChaseStopTrailSetMethodsExample" results.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by samish18, 04-17-2024, 08:57 AM
                              17 responses
                              64 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by rocketman7, Today, 02:12 AM
                              2 responses
                              17 views
                              0 likes
                              Last Post rocketman7  
                              Started by briansaul, Today, 05:31 AM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by PaulMohn, Today, 03:49 AM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by frslvr, 04-11-2024, 07:26 AM
                              6 responses
                              106 views
                              1 like
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X