Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitLong ignoring condition

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

    ExitLong ignoring condition

    Please see my code snipper below. I don't know what I am doing wrong and hope someone sees an obvious mistake because it is driving me up the wall.

    The problem is that the ExitLong does not take the condition in to account. The places where the system exits does not even change when I comment the "if (Close[0] < LLstop) condition out. The trades are ALWAYS closed out after 1 bar (i.e. on the second bar) even if the condition is nor true.

    I have inserted print statements to check the values of the variables and all looks fine

    Any input would be appreciated.

    // Buy trigger
    if (Position.MarketPosition != MarketPosition.Long)
    {
    HighestHighforlong = 0;
    LLstop = 0;
    if (MyDmipp[0] > MyDmimm[0] && MyDmipp[1] > MyDmimm[1])
    {
    HighestHighforlong = MAX(High,3)[0];
    if ((Close[0] + TickSize) > HighestHighforlong)
    EnterLong();
    }
    }

    if (Position.MarketPosition == MarketPosition.Long)
    {
    LLstop = MIN(Low,4)[BarsSinceEntry()];
    if (Close[0] < LLstop);
    ExitLong();
    }

    #2
    Expected, note the wrong semicolon in your code
    if (Close[0] < LLstop);

    Comment


      #3
      Thank you

      Thank you. I know it was something stupid

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmoran13, Yesterday, 01:02 PM
      0 responses
      31 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      22 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      162 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      95 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      151 views
      2 likes
      Last Post CaptainJack  
      Working...
      X