Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I fix this compile error for SetStopLoss

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

    How do I fix this compile error for SetStopLoss

    I am developing a strategy this part of my code :

    // Enter a Buy trade order
    entryPrice = Close[0];
    buyStopLossPrice = entryPrice - 10 * TickSize;
    EnterLong("BuyTrade");
    SetStopLoss("BuyTrade", CalculationMode.Price, buyStopLossPrice);
    }
    else if (difference >= 4 && CrossBelow(EMA(Closes[0], 4), EMA(Closes[0], 10), 1))
    {
    // Play an audio alert
    PlaySound("Alert1.wav");

    // Enter a Sell trade order
    entryPrice = Close[0];
    sellStopLossPrice = entryPrice + 10 * TickSize;
    EnterShort("SellTrade");
    SetStopLoss("SellTrade", CalculationMode.Price, sellStopLossPrice);
    }

    Gives me the following erros when I try to compile it:
    Click image for larger version

Name:	image.png
Views:	137
Size:	33.1 KB
ID:	1266554

    Could you help me fix the problem. Thanks!

    #2
    Hello Zardelx5152,

    SetStopLoss does not take 3 arguments. If you want to specify a signal name you need to use the second overload set that includes a from entry signal parameter. These are the two ways it can be used:

    SetStopLoss(CalculationMode mode, double value)

    SetStopLoss(string fromEntrySignal, CalculationMode mode, double value, bool isSimulatedStop)​


    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X