Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetProfitTarget() and SetStopLoss() not triggered

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

    SetProfitTarget() and SetStopLoss() not triggered

    Hello.
    I made a code as usual.
    But, SetProfitTarget() and SetStopLoss() not triggered a all.


    PHP Code:
    if( is_flat && Is_Long_Signal_Entry ) 
    {  
        SetProfitTarget("", CalculationMode.Ticks, 100  );    
        SetStopLoss(CalculationMode.Ticks, 17 );  
        EnterLong(); 
    }
                
    
    if( is_flat && Is_Short_Signal_Entry ) 
    {  
        SetProfitTarget("", CalculationMode.Ticks, 100  );    
        SetStopLoss(CalculationMode.Ticks, 17 );  
        EnterShort(); 
    } 
    
    Result of TraceOrders - in attach.

    I tried to use CalculationMode.Ticks and CalculationMode.Price - same result.

    While this work normally:

    PHP Code:
    if( Position.GetUnrealizedProfitLoss(PerformanceUnit.Ticks, Close[0]) < -17 ) 
    {
        if( is_long ) ExitLong();
        if( is_shrt ) ExitShort();                
    } 
    

    What it can be?
    Theoretically, what can be the reason?
    Attached Files
    Last edited by fx.practic; 10-28-2017, 07:46 AM.
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello fx.practic,

    In the screenshot you have provided, it shows the stop loss and profit target are being set.

    No further information is provided such as prints that shows the order progression in OnOrderUpdate()..

    I've tested on my end with a simple script and I am finding that the stop loss and profit targets are able to fill with the provided code.

    The Profit Target is being placed 100 ticks away from the entry and this is very unlikely to fill this far from the entry.

    The Stop Loss is being placed 17 ticks away from the entry and this is much more likely to fill.

    Below is a link to a video I have recorded to show the Stop Loss is being filled in the historical data. I had to use the simulated data feed to push the price up 100 ticks to get the profit target to fill).


    Are you getting different behavior when taking the same steps as in the video?

    Can you demonstrate that there was a gain of 100 ticks without a loss of 17 ticks at any one time without the exit on close being hit?

    What steps have you taken to debug the script?

    What is the price the profit target is being placed?

    Can you show that the profit target is not entering a working state?

    Can you show that the current price has risen above the price while the profit target is in a working state?
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    75 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    146 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    79 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    50 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    54 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X