Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Profit Target/Stop Loss

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

    Profit Target/Stop Loss

    Hi there, I'm a new user of NinjaTrader and I must say I am very impressed with the features, especially the ease of use for the Strategy wizard. I have just created my first strategy for testing but I have encountered a problem with the Profit Target/Stop Loss mechanism. I have set the Profit Target and Stop Loss to 5 ticks in the code but upon running the Strategy, the backtester does not close the position even if I am up or down by more than 5 ticks.

    I have inserted a screenshot to illustrate the problem.


    Below is the code for the initialize method:

    protected override void Initialize()
    {
    Add(Bollinger(BB_std_dev, BB_periods));
    Add(Bollinger(BB_std_dev, BB_periods));
    Add(Bollinger(BB_std_dev, BB_periods));
    Add(Bollinger(BB_std_dev, BB_periods));
    Add(RSI(Close, RSI_periods, 0));
    Add(Bollinger(BB_std_dev, BB_periods));
    Add(Bollinger(BB_std_dev, BB_periods));
    Add(Bollinger(BB_std_dev, BB_periods));
    Add(Bollinger(BB_std_dev, BB_periods));
    SetProfitTarget("Short Signal", CalculationMode.Ticks, 5);
    SetStopLoss("Short Signal", CalculationMode.Ticks, 5, false);
    SetProfitTarget("Long Signal", CalculationMode.Ticks, 5);
    SetStopLoss("Long Signal", CalculationMode.Ticks, 5, false);

    CalculateOnBarClose = false;
    }

    Any ideas why this is happening?

    #2
    Welcome to the forums and thanks for the kind words - please try without any custom signal names / from entry signal entries in the strategy, it might be a typo in there so it's not picked up as you would expect. If this still not works, please attach the zip export so we can take a closer look.

    Thanks

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    50 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    16 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X