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 cmoran13, 04-16-2026, 01:02 PM
        0 responses
        36 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        23 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
        96 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        152 views
        2 likes
        Last Post CaptainJack  
        Working...
        X