Cannot convert Y price values to pixels or Y pixels to Y price values
Author: sachmo
Creation Date: 8/27/2014 3:08 PM
profile picture

sachmo

#1
For some reason I cannot convert Y price values to pixels or Y pixels to Y price values. Using PricePane.ConvertValueToY(double value) will compile but the return is a negative integer value that bears no relationship to the Position of the price.

anyone got any ideas about how to convert y price to pixels in the PricePane?
profile picture

Eugene

#2
Please provide a sample code sufficient to demonstrate the problem, which ChartStyle is applied, and chart scale (Linear/Log).
profile picture

sachmo

#3
ChartStyle = WealthLab.Chartstyles.CandleChartstyle. Linear Axis Scale


Price High BarNumber 1998 = 36.40
Price Range Shown on Chart top to bottom = 36.44 to 36.37

Code:
CODE:
Please log in to see this code.


Output: Pixel -36
profile picture

sachmo

#4
if I Use the following it will not compile with the error message

CODE:
Please log in to see this code.


"WealthLab.ChartPane does not contain a definition for PricePane
profile picture

Eugene

#5
QUOTE:
"WealthLab.ChartPane does not contain a definition for PricePane

That's right, because this statement makes no sense.

P.S. We'll take a look at your sample code in reply #3.
profile picture

sachmo

#6
I am not sure what you mean by non sense. WealthScript documentation Indicates that WealthLab ChartPane Object represents one of the panes of the current chart. One of the Panes on the current chart is in fact "PricePane" and the program will compile accordingly.

Moreover, it the documentationsindicates that The Class ConvertValueToY converts the specifiec numeric value to y pixel coordinate on the chart pane.

Finally when I use an object Browser @ WealthLab.ChartPane there is a class named "ConvertValueToY(double)"

Where Have I gone wrong?
profile picture

Eugene

#7
QUOTE:
I am not sure what you mean by non sense.

For two reasons:

a) ChartPane doesn't have a PricePane property
b) PricePane is a ChartPane itself.

ChartStyle.PricePane makes sense, as well as your code in reply #3. I just don't have an explanation yet as to why that happens but I will investigate. The thing is, ConvertValueToY is not used in Strategies but in ChartStyles. Could you tell us what are you trying to do by using it?
profile picture

sachmo

#8
I am trying to place messages from a separate thread on the right hand side of the chart at the price level. So I am using DrawText(ChartPane pane, string text, int x, int y, Color color, Color backgroundColor, Font font); Int x and int y are pixels. I have Can draw everything to the right of chart by converting the bar value to x . I can only Plug in an integer to for the value of y.

I tried to write a method to develop an estimate of the pixel value for the given price. An additional problem is that the PricePane.Height property will not register. Consider the following :

Code:
CODE:
Please log in to see this code.


OutPut = "0"


CODE:
Please log in to see this code.


OutPut=0


CODE:
Please log in to see this code.


OutPut=38.5
profile picture

sachmo

#9
In response to your comment:

QUOTE:
" The thing is, ConvertValueToY is not used in Strategies but in ChartStyles"


It may be that I have a misunderstanding of the scope and purpose of WealthLabs. I have been trying to write a trading system that incorportates the dynamic chart able to provide decision information to the trader. I believe that chart style and its various panes, are an integral parts of trade decision making. Is It possible that am expecting too much??? I see charts as a presentation of strategy. Should I be looking at something else. I would appreciate your advise.

By the way, in spite of the limitations that I run into, I really do like the program.

Best Regards
Chuck



profile picture

Eugene

#10
QUOTE:
Consider the following :

These properties (Height and Top) have no real value in Strategy code while the Strategy is executing. The same may apply to ConvertValueToY. They're useful when developing custom ChartStyles but their usage in Strategies is not supported.

QUOTE:
I am trying to place messages from a separate thread on the right hand side of the chart at the price level. So I am using DrawText(ChartPane pane, string text, int x, int y, Color color, Color backgroundColor, Font font); Int x and int y are pixels.

Why not simply use AnnotateBar instead of DrawText?

Note that since no bars exist past Bars.Count yet, there can't be anything plotted to the right of the last bar. No bar = no plot. And since the Bars object is locked, there's no way to add future bars to it as a workaround.
profile picture

sachmo

#11
I use PadBars to create a blank space at the right of the screen. Annotate Bar will not write in that blank screen space. It will only write @ above or below the last bar. The reason I use DrawText is to write on the screen past BarCount-1.

I think you are correct, I am trying to do something that is not supported by the current ChartStyle. Accordingly, I was confused in understanding that ChartPane, listed in the quick reference, can be used as an Object.

Eugene, I really appreciate your time and effort.

Best Regards
Chuck


This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).