Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Kensonprib, 04-28-2021, 10:11 AM
        5 responses
        191 views
        0 likes
        Last Post Hasadafa  
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,229 views
        0 likes
        Last Post xiinteractive  
        Started by andrewtrades, Today, 04:57 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        7 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        441 views
        0 likes
        Last Post Delerium  
        Working...
        X