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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 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
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X