Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Printing in a Private Bool

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

    Printing in a Private Bool

    If the following Custom Method tested as FALSE, should the "ManyThingsCount" counter iterate and the print statement print to the output window?
    Code:
    private bool BarRises()
    {
            if ((Highs[2][1] - Lows[2][1]) < (Lows[2][1] * 0.13))
                return true;
        else
            return false;
            ManyThingsCount++;
            Print (Instrument.FullName + "  "+Times[0][0].ToString("MM/dd/yy  HH:mm:ss")+" : "+ManyThingsCount);
    }
    My goal is try to get a running count of my Custom Methods that are testing FALSE as they are calculated. (In this case, tick-by-tick.)

    If all of my custom methods iterate to the "ManyThingsCount", will this give tick-by-tick count I am looking for? If not, could you suggest a working version?

    Thanks in advance.
    Last edited by ArmKnuckle; 05-10-2019, 03:22 AM.

    #2
    Hello ArmKnuckle,

    Thanks for your post.

    When the code hits either return statement the counter would not be updated and the print statement would not be executed.

    When you have an if/else condition and you want to process multiple actions in one state of the other (or both), you would need to enclose those actions in "{ }". Any action to perform would have to be done before the return statement is hit. For example:

    private bool BarRises()
    {
    if ((Highs[2][1] - Lows[2][1]) < (Lows[2][1] * 0.13)
    {
    return true; // when true do not increment counter, do not print.
    }
    else
    {
    ManyThingsCount++; // Increment only when false
    Print (Instrument.FullName + " false "+Times[0][0].ToString("MM/dd/yy HH:mm:ss")+" : "+ManyThingsCount); // Print only when false
    return false;
    }
    }

    Comment


      #3
      I have constructed the Custom Method as you specified. The print statement to check on the counter total is not working when FALSE.

      I have also placed a counter and print statement for when the Custom Method is TRUE. The print statement is not working there, either.

      Being that the Custom Method is being evaluated on every tick, I should have numerous prints in the output window. FWIW, Custom Methods are placed outside of OnBarUpdate().

      Why isn't it working?
      Last edited by ArmKnuckle; 05-10-2019, 07:10 PM.

      Comment


        #4
        Originally posted by ArmKnuckle View Post
        I have constructed the Custom Method as you specified. The print statement to check on the counter total is not working when FALSE.

        I have also placed a counter and print statement for when the Custom Method is TRUE. The print statement is not working there, either.

        Being that the Custom Method is being evaluated on every tick, I should have numerous prints in the output window. FWIW, Custom Methods are placed outside of OnBarUpdate().

        Why isn't it working?
        Have you accounted for escaping the first bar? You need an escape for CurrentBars[2] < 1.
        What is the error in your log?
        Last edited by koganam; 05-10-2019, 10:56 PM.

        Comment


          #5
          Hello ArmKnuckle,

          Thanks for your reply.

          As member koganam asks, in the OnBarUpdate() are you checking for at least 2 bars to be loaded, in the 2nd added data series) before processing further? (Do you have any errors in the "log" tab of the NT8 control center).

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          53 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X