• 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

Multiple Target profits

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

    Multiple Target profits

    Hello,

    I have searched the forum for an answer, but can't find it.
    I tried to do it with unique entrys but I don't manage to do it right.

    My strategy goes like this:
    My indicator gives a numeric value "2" of "3" at the close of a bar. The next bar the indicator is reset so the value is reset to "0"
    When I get a 2 I buy 2 futures at the open of the next candle and the target profit is +14 pips
    When I get a 3 I also buy 2 futures at the open of the next candle and the target profit is +20 pips
    I only do 1 number of trade. So when I get "2" I buy the futures and when I would get a "3" a few candles later, I won't go into that trade and just stick to the "2" until it is fully concluded.

    BUT!!! Sometimes the future goes down first and when it goes -30 pips I buy an additional future (same when the indicator value was 2 or 3) When it goes -50 I buy another one.

    So when I would have 4 futures, the targetprofit would be the average.position.price +14 pips for when it was "2" and +20 for when it was "3"

    When I use the strategy builder in NT8, I can only set 1 target profit. I cannot find the way to do this right.

    When I use unique entry's, let's say "start2" for the "2" and "start3" for the "3" and then have to buy additional futures because the futurevalue drops, how do I address this?

    Many thanks in advance.

    #2
    Hello Pladijske,

    Thank you for your note.

    If you're using unique signal names for your entries, you can absolutely set more than one profit target - you can set a different one for each entry if you like. When you add a Profit Target in the builder, the first option for it is "From Entry Signal". Just put the entry name you want it associated with there and you can set it's own value and have it only associated with that specific entry.

    I'm not certain what you mean by how do you address buying additional futures because the price dropped - if your entries are all unique, that's fine. Just give it its own profit target and stop.

    If that's not quite what you are getting at, please clarify.

    Thanks in advance; I look forward to assisting you further.

    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate,

      Thank you very much for your answer. I know I can set specific profit targets per entry but that is not quite what I want, I think.
      I am sorry if I didn't make it clear.
      I will try to explain it better.

      In the strategy builder I have now 4 "sets" of instructions.
      The first is to buy 2 futures when my indicator gives a value of "2" at the end of the candle.
      The second set is to buy 1 more future when the price drops more than 30 pips from original entry
      The thirth set is to buy 1 more future when the price drops more than 50 pips from original entry
      The fourth set is to buy 1 more future when the price drops more than 100 pips from original entry

      My profit target is the average position price +14 pips.

      So when I buy 2 futures at 1000 and the price goes up the targetprofit is 1014
      When it drops to 970 the new profit target is ((1000+1000+970)/3)+14
      and so on.

      But when my indicator gives a value of "3" I want the target profit to be +20pips in stead of +14pips

      How do I do this?

      I cannot find extra "if .... then" in the stop/target section to set the target profit value for "2" and "3" seperately.

      I tried to do it in the condition section and that didn't work eiter.

      Hope you can help.

      Many thanks.

      Comment


        #4
        Hello Pladijske,

        Thank you for your reply.

        When your indicator gives a value of 2, do you use a uniquely named entry different from the one used when the indicator gives a value of 3?

        If so, you would just need to set up the profit target in the stop/target section to use 20 instead of 14 and associate it with that specific entry with the entry signal name.

        For example, here's a mockup of what you might have:

        Click image for larger version

Name:	2020-01-16_1501.png
Views:	54
Size:	62.9 KB
ID:	1084040

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Dear Kate,

          Thank you again for your reply.

          Yes I understand this but what I don't understand is:

          Let's say my indicator gives "2" and I place a first order of 2 futures at 1000 and name this entry "order21"
          The index drops to 970 and the strategy places a second order for 1 future at 967 and name this entry "order22"
          The index drops to 945 and the strategy places a thirth order for 1 future at 948 and name this entry "order23"
          The index drops to 899 and the strategy places a fourth order at 897 and name this entry "order24"

          I now want the strategy to "sell" these five futures at the average "buy" price of these five futures (= 962,5) +14 pips.

          So when I come at the "stops and targets" section in the strategy builder, what do I have to pick then?
          If I select " SetProfitTarget(@order21,@order22,@order23,order24 ,CalculationMode.Ticks, 28) does it set a target for the average price or for each order seperately?

          I defenitely could set them all seperately per entry, but how do I define then the target profit because I never know in advance whether the future first will go further down or not
          What I mean is that when I set SetProfitTarget(@"order21",CalculationMode.Ticks, 28) will it wait for the future to go back up to 10014 in stead of the 962,5+14=976,5

          In the former platform I used, which was more visual basic type, the code was like:
          -------------------------------------------------------------------------------------------------
          CumulateOrders = true

          indicator1 = CALL "long DAX 1 beste"[28,7,35,19](close) // the indicator I now coded in Ninjascript and works super
          c1 = (indicator1 = 3)
          c2 = (indicator1 = 2)

          IF time>081000 and time<212500 AND ONMARKET = 0 then
          IF c1 or c2 THEN
          BUY 2 SHARES AT MARKET
          ENDIF
          endif

          IF longonmarket and countofposition = 2 and positionprice - close > 30 then
          buy 1 shares at market
          endif

          IF longonmarket and countofposition = 3 and positionprice - close > 50 then
          buy 1 shares at market
          endif

          IF longonmarket and countofposition = 4 and positionprice - close > 100 then
          buy 1 shares at market
          endif

          *IF c1 then
          *SET target pPROFIT(positionprice) +20
          *elsif c2 then
          *set target pPROFIT(positionprice) +14
          *endif
          -------------------------------------------------------------------------------------------------------
          So it is the last part of the code (with the *) that I try to/would like to achieve in the strategy builder.

          So it is nothing fancy or anything, but I tried it with unique entrys but I do something wrong because I am not able to "sell" the 3,4 or 5​ at the average price +14 or +20.

          Sorry for all the text!

          Kind regards,

          Ladis​​​​​​
          Last edited by Pladijske; 01-17-2020, 05:53 AM.

          Comment


            #6
            Hello Pladijske,

            Thank you for your reply.

            What you're looking for would be too complex for the Strategy Builder to use the Stops/Targets section with - you can't create a dynamic Profit Target with the builder. If you unlocked your code, this would be possible by adding a dynamic Profit Target in OnBarUpdate(). For example, you could set the price for your profit target in SetProfitTarget() after your entry methods to have that set to the Position.AveragePrice +14 or +20 ticks.

            As this involves setting a dynamic stop loss, you would not be able to use SetProfitTarget() for this if you are using the Strategy Builder, as the Strategy Builder only supports static stop losses. If you are using the Strategy Builder, I would suggest to place exits using specific exit orders instead of the SetProfitTarget() methods under Profits and Targets.

            Basically, you could set up the conditions you outlined above in new condition sets (including the level you want the profit target to fire at), then use one of the exit order options to exit the trade.

            Here's an example of how i might set this up:

            Click image for larger version

Name:	2020-01-17_1101.png
Views:	58
Size:	75.4 KB
ID:	1084135

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Hello Kate,

              Many thanks for your answer.
              I unlocked the code and added this (picture red cross)
              Is that ok?

              Comment


                #8
                Hello Pladijske,

                Thank you for your reply.

                The picture you tried to post didn't work - can you try posting it again?

                Thanks in advance; I look forward to assisting you further.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Kate,

                  I hope you can see them now.
                  And I hope you can give your opinion.
                  Kind regards
                  Ladis
                  Attached Files

                  Comment


                    #10
                    Hello Pladijske,

                    Thank you for your reply.

                    So that I may more easily test, would you be able to export this and attach it to your reply? You can do so from Tools > Export > NinjaScript Add-On. You'll want to follow the instructions for Exporting NinjaScript As Source Files here:

                    https://ninjatrader.com/support/help...tAsSourceFiles

                    You can attach the resulting .zip file to your reply.

                    Thanks in advance; I look forward to assisting you further.
                    Kate W.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Pladijske,

                      Thank you for your patience.

                      Just following up to see if you were able to export the script you'd added screenshots of above - otherwise, have you resolved you inquiry?

                      Thanks in advance; I look forward to assisting you further.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello Kate,

                        Yes I studied hard this weekend and I resolved the problem and it seems to work. Many thanks for your follow up.
                        I am allmost ready to buy the Ninjatrader software and go live, but I still have 3 questions:
                        1. When a strategy is fully autotrading, is it possible to interrupt it? i.e. The strategy has bought 2 futures, but I see a flaw and want to stop or break the strategy and sell the futures, is that possible and if so, how do I do that?
                        2. Is it possible to have a strategy running on uses an indicator running on an instrument i.e. FDAX and when this indicator gives a signal buy another instrument i.e. DAXM automaticly?
                        3. When my strategy gives a signal at the end of a 1 min bar to buy 2 futs, what kind of order do I submit best to have a value close to that last index value? And let's say that my signal price was 14000 and my target profit is +50 pips, but my order slipped up to 14005 to adjust the "sell price" to the value of the signal instead of the value of the execution?
                        Have a wonderful day and again many thanks.
                        Kind regards,

                        Comment


                          #13
                          Hello Pladijske,

                          Thank you for your reply.

                          Yes, you can always stop your strategy at any time. If you are currently in a position, the strategy may be stopped and the position closed by clicking the Close button in Chart Trader if you are running the strategy on the chart and have access to Chart Trader. You can also uncheck the Enabled box on the Strategies tab of the Control Center to stop the strategy, or uncheck the enabled box in the Strategies menu from the chart. You can then manually manage any remaining positions

                          Whether the strategy will automatically cancel any pending orders on disabling would depend on your settings under Tools > Options > Strategies.

                          It is possible to have a strategy that can place trades to two different instruments. This would require adding a secondary data series to your strategy of the second instrument and sending orders to that data series at appropriate times. Here's a link to our help guide on Multi-Time Frame and Instruments:

                          https://ninjatrader.com/support/help...nstruments.htm

                          The kind of order you'd want to use to get the closest to that last value would probably be a market order - setting a limit order might not work if the price moved. However, you would have to take potential slippage into consideration.

                          If your order does slip before filling, any profit target or stop loss will be adjusted to use that price as the average entry price and your stops/targets in most cases would be placed accordingly.

                          Please let us know if we may be of further assistance to you.

                          Kate W.NinjaTrader Customer Service

                          Comment


                            #14
                            How do you post the pictures so that are visible not as attachments to the message but rather those are visible on the topic above? So far I know how to post them only as attachments... Paste function is not working here on the text field...

                            Comment


                              #15
                              Hello Aporshnev,

                              Thank you for your reply.

                              To post a picture within a post, press the A button in the top right of the post editor. In the toolbar that appears, there will be a image icon, click that and upload the image then click ok to place it in the post.

                              Please let us know if we may be of further assistance to you.
                              Kate W.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ralett, Yesterday, 07:29 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Marco  
                              Started by bboyle1234, Yesterday, 10:46 PM
                              1 response
                              5 views
                              0 likes
                              Last Post bltdavid  
                              Started by swcooke, Yesterday, 04:29 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post swcooke
                              by swcooke
                               
                              Started by bboyle1234, Yesterday, 04:27 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post bboyle1234  
                              Started by swcooke, Yesterday, 03:31 PM
                              2 responses
                              12 views
                              0 likes
                              Last Post swcooke
                              by swcooke
                               
                              Working...
                              X