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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        169 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        326 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        252 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        353 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        180 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X