Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Missing something very simple

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

    Missing something very simple

    Hi everyone , I know I'm missing something very simple here but I'm trying to print the result of a simple calculation and it always prints zero... can anyone help please:

    here's my snippet:

    Code:
    int countWins;
    int countAllTrades;
    countWins = 10;
    countAllTrades = 20;
    winPct = 100*(countWins/countAllTrades);
    Print("---- probabilities :-) ");
    Print("# countAllTrades = " + countAllTrades.ToString() + 
          ", countWins = " + countWins + " (" + winPct.ToString() + ")" );
    and here's what is printing..

    ---- probabilities :-)
    # countAllTrades = 20, countWins = 10 (0)

    not sure why I'm getting zero for the winPct...

    Can anyone help please?

    #2
    tradinghumble,

    You likely need to get your variable declaration out of OnBarUpdate(). Please declare your variables in the variable region of your code above the Initialize() method.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      tradinghumble,

      You likely need to get your variable declaration out of OnBarUpdate(). Please declare your variables in the variable region of your code above the Initialize() method.

      Josh, I did that... put all the variable declarations outside of OnBarUpdate() using private ... still does not print. All the variables that I assign value they print ok but if there is calculation involved they won't print... very weird.

      Can you please shed a light?

      Comment


        #4
        Got the answer:

        winPct = 100*((float)countWins/(float)countAllTrades);

        thanks !!!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        331 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        550 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X