Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A question about optimizing profit targets

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

    A question about optimizing profit targets

    Hi all,

    I am trying to figure out what realistic expectations should be for determining a valid profit target.

    The problem is that the default fill logic will allow entries and exits on the same bar without regard to which one got hit first.

    In other words, as I understand it the following can occur:

    Place entry limit to sell short at 100. Place profit target when filled at 99.

    Stock opens at 98 and closes at 101 on the current bar with hardly a down tick.

    The back testing will show me filled at 100 and out at my profit target of 99 when in real life I'd be holding on for dear life hoping for the stock to go down.

    The problem in determining an valid profit target is that there is an inherent bias to small (unrealistic) profit targets because the smaller the number gets, the more "impossible" favorable fills you will get and they really skew the results. FYI I can get losing trades to be less than 10 or so out of 3000 trades just by making my profit target small enough!

    What have other people done to hande this? It seems to me that one way might be to put a one bar delay in setting the profit target. Does anyone know how to do this?

    Thanks in advance for any help,

    John

    #2
    To get around the profit target on same bar as entry, do this:


    Code:
    // ----------------
    // trade management
    // ----------------
                                
    // set profit after entry bar (historical purpose)
                                
    if (Position.MarketPosition != MarketPosition.Flat && BarsSinceEntry() != -1)
           {
           SetProfitTarget(signalname, CalculationMode.Ticks, Target1);  
            }
    
    // ------------------------
    // look for setups to trade
    // ------------------------
    
    if (Position.MarketPosition == MarketPosition.Flat)
          {     
    
             if (
                Close[0] > SuperTrend(STrend, STrendatr).UpTrend[0]
                ... other stuff ...
                )
                      {
                            signalname = "["+ CurrentBar + "] long supertrend";
                            
                            EnterLong(DefaultQuantity, signalname);
                            
                            // SetProfitTarget is done up top if Historical
                            if (!Historical) SetProfitTarget(signalname, CalculationMode.Ticks, Target1_minutes);
                            
                            SetStopLoss(signalname, CalculationMode.Ticks, Stop_minutes, false);
                        }
    
        }
    So, basically, if (!Historical) it set's profit target immediately after entry (for live trading).

    But, if is Historical [backtesting], then it will not set the profit target until bar #2.

    This prevents completed trades on bar #1. BTW, there is a bug in the SetProfitTarget routine so you have to give it unique signal names. You can't just name every long "long" for instance, because the SetProfitTarget will mess up. I have a thread open on this. That is why I added the CurrentBar to the signal name, so each signal name is unique.

    HTH,

    Mike

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X