Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Phantom Trades

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

    Phantom Trades

    I have a bug in my script and I cant figure out whats causing it:

    I have an int variable that tracks trades set like this:

    Daily Bars in progress:
    I check some indicators in if statements, if the indicator is positive (in daily timeframe)
    set tradecounter = 1;
    end if

    Minute bars in progress:
    Once the indicator is set the tradecounter variable is checked in 10 minute timeframe the next day, if it =1 then I place an order like EnterLong(), then set tradecounter back to 0;

    The only problem is, somehow the tradecounter is set to 1 even though the indicator is not showing on the chart or is not set to positive in the script even after I check via Print statement.

    Any ideas? This results in some completely erroneous trades.

    #2
    Hello elitetradernyc,

    Thank you for your post.

    How are you setting the tradecounter when defined? Is it defined first in the Variables section of the NinjaScript Strategy code? And what value is set first, 0 or 1?

    I look forward to your response.

    Comment


      #3
      Hi sir, its defined like this in the variables section:

      private int tradeCounter = 0;

      The only other place itsset is in the code is in the dialy section where indicators are checked.

      Comment


        #4
        Disregard this, it was my mistake, I was not setting it back to 0 if trade wasnt made.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        639 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        572 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X