Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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, 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 benmarkal, Yesterday, 12:52 PM
    3 responses
    23 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    19 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    11 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    388 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X