Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Invalid expression term ')'

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

    Invalid expression term ')'

    I have been trying again and again to figure out what this error is but I can not seem to figure out what is wrong with it.

    I am getting the error in that is mentioned in the title.

    When I double click on the error, I am taken to the following line of code:
    Code:
    if (SMA(sMAPeriod)[0] - ((SignalHigh - SignalLow)*StopPerc) > LongStopB.StopPrice))
    Here is where it is in context:
    Code:
    protected override void OnExecution(IExecution execution)
    {
    if (LongLimit != null && LongLimit == execution.Order)
    {
    if (execution.Order.OrderState == OrderState.Filled)
    {
    ExitLongStop(AvgPrice-(execution.Price - AvgPrice),"LongStopB","LongEntryB");
    }
    if (SMA(sMAPeriod)[0] - ((SignalHigh - SignalLow)*StopPerc) > LongStopB.StopPrice))
    {
    ExitLongStop(SMA(sMAPeriod) - ((SignalHigh - SignalLow)*StopPerc),"LongStopB","LongEntryB");
    }
    }
    }
    LongStopB is an IOrder variable that is in the global variables section

    It is then defined in the OnBarUpdate() section as:
    Code:
    LongStopB = ExitLongStop(StopPriceLong,"LongStopB","LongEntryB");
    I then have an if statement that then uses this to set my stop Loss

    Code:
    if ("series of conditions")
    {
    ExitLongStop(StopPriceLong,"LongStopB","LongEntryB");
    }
    Is that enough information to help me figure out what is causing this error?

    Incidentally, I also receive " ; expected " and when I click on that, it takes me to the same line of code.

    Thank you for any help that anyone is able to provide.

    #2
    Hello jg123,

    Thank you for your post.

    Change the line that the error references to the following:
    Code:
    if (SMA(sMAPeriod)[0] - ((SignalHigh - SignalLow)*StopPerc) > LongStopB.StopPrice)
    You had an additional ')' in the line.

    Comment


      #3
      Thank you, Patrick

      That did fix it, but it then opens up an entire new can of worms. I will discuss this in a new thread.

      Comment

      Latest Posts

      Collapse

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