• 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

Profit (and Loss) Targets question

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

    #16
    Thanks Paul,
    So If I get it, you are saying that the Setting the state to Real Time means that it only looks at current data and not historical data when evaluating the situation. If so, then prior trades are not taken into account before the strategy is engaged... so my theory about why things are not working (not taking any trades) based on the targets already being met in historical data is not correct if indeed the state is set to Real Time, does that sound correct?

    In other words setting the state to Real Time means that "the RealizedPNL is the accumulated total of all trades made, historical and real time, by the strategy." is not the case, it is only verifying Real Time trades, correct?

    Comment


      #17
      Hello RonnieB,

      Thanks for your reply.

      When using State.Realtime as an entry condition, the strategy will not perform any historical trades, it will only perform trades in real time (or playback with market replay data). This means that the strategy will not have any RealizedPNL prior to when the strategy begins live trading and that means when you check the value of RealizedPNL in the strategy, it would be of the trades your strategy performed today in live trading, which is what you wished to do.
      Paul H.NinjaTrader Customer Service

      Comment


        #18
        My Session stop loss and profit targets are 'mostly' working now, but they have an issue if I use a different chart type (not 377 tick but 2-range for one test) it seems. Any advice as to how to make them work regardless of chart type would be appreciated.


        A different question re. Trailing stops. If you prefer, I can make a different post on this...
        How do I add a trailing stop to my strategy so that:
        1. the user can add a different trigger number (user input) as to Number of Ticks past break even to trigger the Trailing Stop and
        2. the trailing stop can move to a certain amount past break even based on the user's input (i.e. +4 ticks after trailing stop is triggered at +6 ticks)
        3. the trailing stop can continue to adjust (trail) a certain amount for each additional tick based on the user's input (i.e. when price moves 2 more ticks in the desired direction after trailing stop has been triggered we want the trailing stop to adjust 1 tick for every 2 ticks in the desired direction)
        I've tried finding answers to these questions via the help search but can't figure it out from what I've found so far.

        Thanks in advance for your help here Paul (or anyone else who knows the answers).
        Ronnie

        Comment


          #19
          Hello RonnieB,

          Thanks for your reply.

          Regarding, "...but they have an issue if I use a different chart type ...", you'll have to define what you mean and provide specific examples of what the issue is specifically.

          Regarding a trailing stop: The trailing stop in the strategy builder is a simple one and would not provide the functionality you seek. You can specify the trail distance and that would be all. You also cannot use both the strategy builder trail stop and the strategy builders fixed stop on the same order, if so, the strategy will only use the fixed stop.

          You may be able to find the functionality for your own trailing stop in the examples presented by my colleague Chelsea in this thread, post #2: https://ninjatrader.com/support/foru...rategy-builder

          From your description, in my opinion, it would be very difficult to do in the strategy builder. You may want to consider working in Ninjascript for this functionality and possibly consider using a script that works with an ATM strategy (The strategy builder cannot). There are special methods in Ninjascript that would allow a strategy to place entries and when filled the ATM template would take over, using the full functionality embedded in the template.

          An alternative at any time would be to hire a 3rd party programmer to create what you are looking for.



          Paul H.NinjaTrader Customer Service

          Comment


            #20
            Paul,
            Thanks again for the helpful information.
            Re. Session Targets:
            When I use a 377 tick chart (with CL or ES) my "Session Stop" which looks at RealizedPNL functions mostly as expected and stops entering new trades when the Profit or Loss targets have been breached, but when utilizing a 2-Range chart with the CL it did not stop taking new trades once the Stop Target had been breached (target was -$500 and it kept taking new trades when the account showed RealizedPnL at -$500, then -$700, then -$1,000 - see attached pics for reference).

            Re. TrailingStops
            Can you please describe what happens with the Strategy Builder choice called Trailing Stop when the number is set to 5 for example?

            Next,
            re: You may want to consider working in Ninjascript for this functionality and possibly consider using a script that works with an ATM strategy (The strategy builder cannot). There are special methods in Ninjascript that would allow a strategy to place entries and when filled the ATM template would take over, using the full functionality embedded in the template.

            Can you point me to how using NinjaScript a Strategy can then utilize an ATM strategy?
            I have a programmer that I can hire to work with NinjaScript at the proper time and I'd like to point them in the right direction for this desired functionality when appropriate.

            Thanks, I'll also take a look at the referenced post by Chelsea, post #2: at https://ninjatrader.com/support/foru...rategy-builder

            Thanks again in advance.
            Ronnie
            Attached Files

            Comment


              #21
              Hello RonnieB,

              Thanks for your reply.

              For the strategy performing improperly, you would need to review your conditions to ensure that your have a check of the realized PNL in each entry set. I would also suggest adding a print statement, in its own set, so that on each new bar, it will print out the value of the strategies Realized PNL. Here is a short video on how to use the print statement in the strategy builder: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw (You would need to go to New>Ninjascript output, to see the print output).

              For the trail stop, you didn't mention what 5 represents so in my example, and recommendation, would be to use ticks as this is straightforward. In the strategy builder trailing stop, when an entry order is filled (long for example), the stop will be placed 5 ticks below the entry price. If you are using calculate.OneachTick (or CalculateOnPriceChange) (recommended for trailing stop), then for each tick in profit that the trade goes the stop will move up a tick. If price goes down, the stop does not move. If price goes 3 ticks into profit and then reverses 5 or more ticks the stop would exit with a 2 tick loss. If you use Calculate.OnBarClose then what happens is the stop is moved at the end (time) of the bar, using the previous example if the bar goes 3 ticks into profit and then reverses 5 or more ticks before closing the trail stop would be submitted to the 2 tick below the entry price but will now be above the current price and the strategy would be disabled.

              For a script to work with an ATM template, you have to use special methods outside of the normal strategy methods, these are detailed here: https://ninjatrader.com/support/help...gy_methods.htm Also, a good resource is the SampleATMstrategy that is in your NinjaTrader. The source code file of that strategy is well commented to explain the functionality.
              Paul H.NinjaTrader Customer Service

              Comment


                #22
                Paul, Please see the annotated screenshot attached.
                My Session Loss targets are not being respected. I've tested using Calc=bar close vs. tick, vs price change and all till have issues not closing the Per Session StopLoss Target properl, they seem to respect the Per Session Profit Target fairly well however.

                I check each entry with verification of the "OKtoTrade" bool... if set to False it is not supposed to enter the trade.
                Perhaps it enters the trade in the opposite direction too fast to verify the bool state. Is there a way I can have a double check and verify that if in a trade, yet the Bool=False, then to exit that trade immediately and it will hopefully not enter another trade per the bool=false status?

                My Bool Variable name is "OKtoTrade" and it does a check on the RealizedPnL to see if it has exceeded limits set by user inputs "PerSessionStopLoss" or "PerSessionProfitTarget" variables which are calculated via the Acct. Realized PnL plus or minus the Inputs
                Attached Files

                Comment


                  #23
                  Hello RonnieB,

                  Thanks for your reply.

                  It sounds like you have some logic that isn't quite working right.

                  I would suggest debugging by using print statements. In Post 13 of this thread I posted a video link to help with this.

                  If that does not show anything, please post either your strategy itself or screenshots of your strategy conditions.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #24
                    How do I post my strategy here should it come to that?
                    is it uploading the .cs file here or is there another way to "share" my strategy?

                    Also, should I not find the issue, is there a way to do what I last requested? (verify if in an active trade what the bool value is and if it is "False" then to immediately exit that trade but keep the strategy running for the next trigger to trade)?
                    Is there a way I can have a double check and verify that if in a trade, yet the Bool=False, then to exit that trade immediately and it will hopefully not enter another trade per the bool=false status?

                    Comment


                      #25
                      Hello RonnieB,

                      Thanks for your reply.

                      Debugging is necessary when you are not getting expected results. Please use the print statements to help you identify the values of the variables that are involved with the unexpected results. Trying to add other conditions to counteract what you think is happening will likely only lead to further incorrect or confusing results. You would do best to keep your strategy as simple as possible and develop a good understanding of how it is working as is before making changes. Debugging takes time and effort but it is the only way to develop your understanding of how the strategy you create is working.

                      To post a script you could attach the source code (.cs) file. Alternately, you could export a zipped file according to the help guide, you would follow the section titled, " Exporting NinjaScript as Source Files " on this page: https://ninjatrader.com/support/help...t8/?export.htm

                      Paul H.NinjaTrader Customer Service

                      Comment


                        #26
                        I will dig into making print statements, etc. but here is the most basic way I can explain what seems to be happening and ask an important question,

                        The Session Stop Loss is calculated apparently only when the bar closes (due to my "calc on bar close" choice for the entire strategy). For some reason yet to be determined Even after the bar closes and the Bool ("OKtoTrade") is set to False the strategy still enters new trades.

                        Main Question: Is there a way to let the main part of the strategy use Calc on Bar Close but have the Realized PNL used to calculate the Account totals (i.e. PerSession values) calculate "per price change" or "per tick" (different calculation triggers in the same strategy at the same time)?

                        To me it seems to be a BIG missing element that we don't have the ability in the "Stops and Targets" area to include a Target that is based on the Account Realized PnL similar to what we have for a "SetProfitTarget(CalculationMode.Currency,ProfitTa rgetPerTrade)" that calculates the stopping of a trade position when it reaches a target amount. My strategy requires multiple smaller "wins" to be successful rather than relying on only 1 BIG win.

                        My Goal it seems is to allow the Per Trade Targets (profit and loss) to be calculated based on Bar Close, but have the Account ("per session") value be calculated per tick or per price change so it can exit the trade and stop taking trades (i.e. using the bool variable "OKtoTrade") for that iteration of the Strategy.

                        I'll try to show what is going on via the debugging options you have pointed me to earlier, but my main question still remains as outlined above.
                        For the strategy performing improperly, you would need to review your conditions to ensure that your have a check of the realized PNL in each entry set. I would also suggest adding a print statement, in its own set, so that on each new bar, it will print out the value of the strategies Realized PNL. Here is a short video on how to use the print statement in the strategy builder: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw (You would need to go to New>Ninjascript output, to see the print output).

                        Comment


                          #27
                          I've made some print strings as per your instructions in the video you made for me (thank you), but I'm not sure if my definitions are correct to show me the values I am looking for.
                          See attached screenshot for details of the print statements Click image for larger version

Name:	2019-11-14_4-19-03 print strings v1.png
Views:	12
Size:	32.2 KB
ID:	1077730 & set 3 conditions that change the OKtoTrade bool from the default True to be False... Click image for larger version

Name:	2019-11-14_4-20-02 set bool to false conditions.png
Views:	11
Size:	32.0 KB
ID:	1077731
                          1. My goal was to see if the value was True or False for 'string 9' but I'm not sure how to add the statement (see screenshot for 2 conditions that would set the bool to False). I'm currently only focused on the Stop Loss side of things.
                          2. My goal is to show the perTrade unrealized value to verify if the "OKtoTrade" bool=false yet there is still an active trade going on - see 'string 11' which may or may not be set up properly.

                          Comment


                            #28
                            Hello RonnieB,

                            Thanks for your reply.

                            The strategy builder calculate mode can only be one of the three selections. (Note: In Ninjascript it is possible to create a strategy where some parts operate per tick and other parts run once per bar).

                            Set 3 uses thee "If any" so you really have no way to know which one is triggering it. For string nine, all you can do is to print the bool OkayToTrade (which you have in string 3) and then print the value as you have in string 7.

                            An alternative here would be in Set three to draw a dot (or other marker or color the back ground, etc) so that on the chart you would see when the bool is being set false.

                            In any event, the print statements should be the first help to see that the bool is or is not being set false when compared to the PNL value.



                            Paul H.NinjaTrader Customer Service

                            Comment


                              #29
                              Paul,
                              Thanks for the reply.
                              I assume from what you wrote that I can not get the Print information to tell me things I asked for in my message to you so I will edit the items it is showing and limit it to what you say I can display, then let it run for a while to see what I see.

                              Is it safe to assume that If I had 2 different sets defining when to set the bool to false but using the same expressions I have in the current set 3 that I would still not be able to determine va Print techniques which PerSession expression Triggered the change from True to False?

                              I'd like to explore the color dot idea of displaying On the Chart when the Bool is True vs. when it is False. Info on the actual chart would be helpful for me to see.

                              Comment


                                #30
                                Hello RonnieB,

                                Thanks for your reply.

                                You could indeed split the set that sets the bool to false into two if that helps, you can then add a print statement in each set (or a different colored dot at a different price level) when the sets condition is true. This is a fairly common debug technique when trying to isolate the issue. However before doing that (making changes tot your strategy) I would encourage you to work with what you have, get the first set of prints and try to understand bar by bar what is happening. In my view it may be that the bool is being set to false correctly but perhaps there is something else in another set resetting it to true incorrectly.
                                Paul H.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by brunoviveiros, Today, 04:26 AM
                                1 response
                                4 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by dkbyond, Yesterday, 03:52 PM
                                1 response
                                7 views
                                0 likes
                                Last Post NinjaTrader_PaulH  
                                Started by Erhard, Today, 04:24 AM
                                2 responses
                                17 views
                                0 likes
                                Last Post Erhard
                                by Erhard
                                 
                                Started by rontronimous, Yesterday, 05:55 PM
                                2 responses
                                20 views
                                0 likes
                                Last Post rontronimous  
                                Started by StevenNelson, 11-19-2019, 05:39 AM
                                4 responses
                                22 views
                                0 likes
                                Last Post NinjaTrader_PatrickG  
                                Working...
                                X