Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetProfitTarget not working as expected

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

    SetProfitTarget not working as expected

    I normally deal with tick based strategies but wanted to try a new minute based strategy.

    I want to avoid the "profit target on same bar as entry" pitfall.

    In my strategy, I told it to enter a position and I did NOT set a profit target.

    Then, I told it later that if BarsSinceEntry > 1, to go ahead and set a profit target.

    My theory was this would prevent Ninja from entering and exiting on the same bar, since it doesn't know the OHLC order with minute data.

    It doesn't work. Ninja seems to read the SetProfitTarget command and immediately identify it with a target starting from the entry point, instead of only looking for targets after the command was initiated.

    I would like a work around or solution please.

    Mike

    #2
    code:

    Code:
    // trade management
    if (Position.MarketPosition != MarketPosition.Flat && BarsSinceEntry() > 1)
    {
    SetProfitTarget(signalname, CalculationMode.Price, Target);
    }
    
    // look for longs
    if
    (Position.MarketPosition == MarketPosition.Flat && condition 1...condition 2....)
    {
    
    EnterLong(DefaultQuantity, signalname);
    SetStopLoss(signalname, CalculationMode.Price, Stop, false);
    
    }
    Last edited by ctrlbrk; 03-24-2009, 03:37 AM.

    Comment


      #3
      Also,

      Failed to mention-- I cannot use a multi-time frame strategy with Add(PeriodType.Tick) to manage the trades, because Ninja crashes when backtesting tick data of any useful length.

      So I will need a solution that doesn't involve multi-time frames.

      Mike

      Comment


        #4
        Hi Mike, how long was the tickdata segment you tried backtesting with? Please try using the Exit() methods instead of the Set() methods then, for example ExitLongLimit for your ProfitTarget.

        Comment


          #5
          I've been round and round with NT over the tick backtesting. Your answer was "don't do that".

          Please, fix SetProfitTarget so it works from the point it is called from instead of going back in time to find profits.

          The Exit..() options introduce a whole slew of other issues, oco's, etc. Would be much simpler to fix SetProfitTarget to work as expected.

          To that end, another way to address this, would be for NT to have a built-in option to not allow targets to be on the same bar as entries. On the dialog box where you are asked for liberal/default, slippage, etc, a new option "Allow same bar targets?" would be nice. Would fix this as well.

          Mike

          Comment


            #6
            Hey Mike,

            Why don't you just set a profit target when you set your stop loss, but make it some excessively large value. This way, it is very very unlikely to be reached. After the first bar, you can modify it to the real value you want to use.
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Was first thing I tried. Doesn't work. You can wait 500 bars into the trade, and once you call SetProfitTarget, it will revert back to bar 0 if bar 0 would have hit the target.

              Comment


                #8
                what about computing the target price based on your target, and using that rather than a static value in the calling of SetProfitTarget?

                Even if it refers to your entry bar, you should be able to compute the target price based on your entry price / current price. Unless I'm misunderstanding what you're trying to accomplish.
                mrlogik
                NinjaTrader Ecosystem Vendor - Purelogik Trading

                Comment


                  #9
                  Thanks for the suggestions in your post Mike, you can take a look at this reference sample for modifying the Set order prices as you go - http://www.ninjatrader-support2.com/...ead.php?t=3222

                  Comment


                    #10
                    Originally posted by NinjaTrader_Bertrand View Post
                    Thanks for the suggestions in your post Mike, you can take a look at this reference sample for modifying the Set order prices as you go - http://www.ninjatrader-support2.com/...ead.php?t=3222
                    This needs to be logged as a bug. Your post seems to suggest SetProfitTarget works as expected, it does not. It does not work the same as SetStopLoss.

                    Comment


                      #11
                      Originally posted by mrlogik View Post
                      what about computing the target price based on your target, and using that rather than a static value in the calling of SetProfitTarget?

                      Even if it refers to your entry bar, you should be able to compute the target price based on your entry price / current price. Unless I'm misunderstanding what you're trying to accomplish.
                      That is what I am doing. Using Exit() instead of SetProfitTarget. But, it has a lot of downsides.

                      SetProfitTarget is bugged and needs to be fixed. It is incorrect behavior to have this code:
                      Code:
                      if (BarsSinceEntry() > 100) SetProfitTarget(signalname, CalculationMode.Ticks, 4);
                      And have the profit target be reached on anything less than bar 100. Again, it is bugged. It goes back in time. The behavior is not the same as SetStopLoss, and is not as expected. There is a problem with the function.

                      Mike

                      Comment


                        #12
                        Bertrand,

                        Please let me know once you've duplicated this. Should only take a minute.

                        Then, please let me know when you can deliver a fix. Preferably before .10 is out, I'd like to get a beta fix that addresses this issue.

                        I am a paying customer.

                        Mike

                        Comment


                          #13
                          Hi ctrlbrk, please provide me with a as simple as possible sample code demonstrating your issue, I will then try to reproduce this on my end here. Also you always wanted to reset your SetStopLoss and SetProfitTarget values when flat, as mentioned in the reference sample I posted. Thanks!

                          Comment


                            #14
                            EnterLong(DefaultQuantity, "buy");

                            if (BarsSinceEntry() > 10) SetProfitTarget("buy", CalculationMode.Ticks, 1);

                            You will see NT will show the profit target on the same bar as entry. The correct behavior would be to only start looking for the profit target after bar #10.

                            Mike

                            Comment


                              #15
                              Mike, please post a complete zipped strategy that we can test to reproduce this - thanks!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              574 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X