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.Ticks100  );    
        
    SetStopLoss(CalculationMode.Ticks17 );  
        
    EnterLong(); 
    }
                

    if( 
    is_flat && Is_Short_Signal_Entry 
    {  
        
    SetProfitTarget(""CalculationMode.Ticks100  );    
        
    SetStopLoss(CalculationMode.Ticks17 );  
        
    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.TicksClose[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, 06: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).
    https://drive.google.com/file/d/0B40...V6UzNyTm8/view

    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 sidlercom80, Today, 02:40 AM
    0 responses
    11 views
    0 likes
    Last Post sidlercom80  
    Started by b16_aln, Today, 01:52 AM
    0 responses
    11 views
    0 likes
    Last Post b16_aln
    by b16_aln
     
    Started by junkone, Yesterday, 08:55 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by adaeiqendqw, 01-16-2021, 02:56 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by [email protected], Yesterday, 06:10 PM
    5 responses
    16 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Working...
    X