[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] PlotText & Formatting Decimals?



PureBytes Links

Trading Reference Links

Thanks Guys.

The code below looks great and I might have to use some of that!!

NUMTOSTR is what I was looking for!

Cheers.

Peter

 

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Terry
Sent: Tuesday, 2 May 2006 7:56 a.m.
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] PlotText & Formatting Decimals?

 

Peter,

 

Mark has another idea I did not consider. I'm sure it works as well. I can't explain why you're getting 4 decimals if your default is set to 2.

 

Here's a title statement from some of my code. It allows complete customization of the chart titles. It is surround by _N(code goes here); to suppress it from printing garbage in the Interpretation window:

 

//Some encode colors in shorthand

green = EncodeColor(colorGreen);

red = EncodeColor(colorRed);

blue = EncodeColor(colorBlue);

black = EncodeColor(colorBlack);

violet = EncodeColor(colorViolet);

 

_N(Title = "{{DATE}} | Symbol: " + Name()

               + "  |  Open: " + O + Green

               + "  |  High: " + H  + Red

               + "  |  Low: " + L  + Blue

               + "  |  Close: " + C + black + " - Actual Close: " + OI/100 + Violet

               + "  |  H-L Range: " + (H - L)

               + "{{VALUES}}"

               + black + "\n---------------| "

               + WriteIf(Buy,green + "Buy " + NumToStr(tradeLot,1.0) + " shares @ Tomorrow's OPEN",WriteIf(Sell,red + "Sell @ Tomorrow's OPEN",

                 WriteIf(Ref(Buy,-1),green + "Buy @ Open!",WriteIf(Ref(Sell,-1),red + "Sell @ Open!",black + "No Trade Today"))))

               + WriteIf(Buy," - (Max " + NumToStr(tradeLmt,1.0) + ")","")

               + black + " |-----------------"

               + red + "\n<<<<<<<<<<<< Error checks follow >>>>>>>>>>> "

               + WriteIf(Liquid,green + "\nLiquid: ","\nNot Liquid: ")

                                      + "MA $Volume = " + NumToStr(dollarVolMA ,1.0,1)

                                      + "\n" + WriteIf(dollarVolNOW >= requiredVol * .75,green,red) + "$Volume today = " + NumToStr(dollarVolNOW ,1.0,1)

                                      + black + " , (need = " + NumToStr(requiredVol * .75,1.0,1) + ")"

               + WriteIf(PositionScore < 1,"\nPositionScore < 1",blue + "\nPositionScore = "+ NumToStr(PositionScore,1.0))

               + red

               + WriteIf(dn,"","\nPrice is not down")

               + WriteIf(Active,"","\nInactive Stock")

               + WriteIf(Watchout,"\nBig Gap Down","")

               + WriteIf(ErraticVol,"\nErratic Volume","")

               + WriteIf(Price < MinPriceLong,"\nPrice too Low",WriteIf(Price > MaxPriceLong,"\nPrice too High","")));

 

--

Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Mark H
Sent: Monday, May 01, 2006 13:31
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] PlotText & Formatting Decimals?

 

Peter:

 

If I understand your question, why don't you use numToStr() ?

Something like

PlotText("Standard Deviation is " + numToStr(StandardDeviationInTheRange, 1.2)......)

 

- Mark

----- Original Message -----

From: Peter

Sent: Monday, May 01, 2006 3:06 PM

Subject: RE: [amibroker] PlotText & Formatting Decimals?

 

Terry.

I have the preferences set to 2 decimal places but the below plot gives 4 decimal places. I’m not sure what you mean with your remarks about Title. How do you use Title and or printf to format decimal places in the PlotText function?

Thanks

Peter

 

// Calculates Standard Deviation

Period = EndValue( BarIndex() ) - BeginValue( BarIndex() );

StandardDeviationInTheRange = EndValue( StDev( Close, Period ) );

 

PlotText( "Standard Deviation is " + StandardDeviationInTheRange, PlotTextxCoordinate , PlotTextyCoordinate , PlotColour , colorWhite );

 

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Terry
Sent: Tuesday, 2 May 2006 2:37 a.m.
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] PlotText & Formatting Decimals?

 

Right. You either change the default number of decimal places in Tools->Preferences OR you use the Title = statement and then your printf formatting will work.

--

Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Peter
Sent: Monday, May 01, 2006 03:30
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] PlotText & Formatting Decimals?

 

Hi

Is there a way to format a number to a set number of decimal places. E.g. In the below example round the number to 2 decimal places.

 

PlotText( "Buy @ "+ 1234.5678, xCoordinate , yCoordinate , PlotColour , colorWhite );

 

It seems that formatting used in printf

e.g. printf ("2 decimal = %0.2f",  1234.5678);  doesn’t work in PlotText

 

Thanks

Peter

 





Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS