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 kugyuw, Today, 05:03 AM
        0 responses
        1 view
        0 likes
        Last Post kugyuw
        by kugyuw
         
        Started by georgeinharmony, Today, 12:06 AM
        2 responses
        12 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by Prisalice, Yesterday, 07:07 AM
        2 responses
        16 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Futurestrader00, Yesterday, 12:04 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Blairski, Yesterday, 11:26 PM
        0 responses
        9 views
        0 likes
        Last Post Blairski  
        Working...
        X