Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Print()

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

    Print()

    trying to print the diff between the upper and lower bands

    Code:
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] upperValue = Bollinger(bbdev, bbperiod).Upper[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]; [/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"The current Bollinger upper value is "[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + upperValue.ToString());[/SIZE][/FONT]
     
    [FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] lowerValue = Bollinger(bbdev, bbperiod).Lower[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]; [/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"The current Bollinger lower value is "[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + lowerValue.ToString());[/SIZE][/FONT]
     
    [SIZE=2][FONT=Courier New][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] DiffValue = Bollinger(bbdev, bbperiod).Upper[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]-Bollinger(bbdev, bbperiod).Lower[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]];[/SIZE][/FONT]
    [SIZE=2][FONT=Courier New]Print([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"diff is"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + DiffValue.ToString());[/SIZE][/FONT]
    [/FONT][/SIZE]
    result in output window is
    Code:
    The current Bollinger upper value is 6816.24026757241
    The current Bollinger lower value is 6806.98195464981
    diff is9.25831292260227
    Last edited by duck_CA; 03-06-2009, 12:42 AM. Reason: Print("diff is " + DiffValue.ToString("0.00"));

    #2
    This is because you use doubles for storing your values. You could use Math.Round to round those to the nearest integer.

    Comment


      #3
      Originally posted by duck_CA View Post
      trying to print the diff between the upper and lower bands
      You do a doublevalue.ToString() call in your code. In C#, ToString can take a specific format string that shows how it should be output.

      So:
      double mynumber = 1.234567890;

      Print("my number is: " + mynumber.ToString("F2", CultureInfo.InvariantCulture);

      ... will output a fixed point number with two decimal places to the right of zero. (F3 = 3 decimal places, etc, etc.)

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      22 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      120 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      63 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      41 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      45 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X