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 vantojo, Today, 01:39 PM
    0 responses
    16 views
    0 likes
    Last Post vantojo
    by vantojo
     
    Started by Rubens_2020, Today, 01:48 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by kempotrader, Today, 01:34 PM
    1 response
    23 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by bc24fl, Today, 01:50 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by bosajin, 01-21-2021, 09:15 AM
    7 responses
    61 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X