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

SetStopLoss() problem

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

    SetStopLoss() problem

    I think I may be encountering a bug related to SetStopLoss() command while backtesting on one minute data. I am not using SetStopLoss() right after the entry, rather SetStopLoss() command is issued only after price has increased by certain points. And to achieve that I am using SetStopLoss() with Price mode and I am using it within OnBarUpdate() and not within Initialize(). Here is example of my SetStopLoss() command:

    SetStopLoss("hey", CalculationMode.Price, (MIN(Close, 10)[0]) - (25 * TickSize), false);


    After my target conditions are met my strategy exits the position by using following command:

    ExitLong("", "hey");

    Now I have found that my last SetStopLoss() order is always active even after my position is exited by 'ExitLong' command. Any position initiated below the last SetStopLoss() price is immediately exited.

    Now I do understand that a stop loss order is supposed to be automatically cancelled if the managing position is closed by another strategy generated exit order and I am not sure why I am noticing this behavior. Can anyone comment please?
    Thank you.

    #2
    Once you call SetStopLoss() it will automatically be submitted for every entry order you send. If you only want it active for certain orders you will need to provide a unique fromEntrySignal name. Your future orders need to have a different entry signal name if you don't want the SetStopLoss() to apply to them as well.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by algospoke, Yesterday, 06:40 PM
    2 responses
    19 views
    0 likes
    Last Post algospoke  
    Started by ghoul, Today, 06:02 PM
    3 responses
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    45 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    21 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    181 views
    0 likes
    Last Post jeronymite  
    Working...
    X