Vertical Scaling Text Placed on Chart

Moderator: admin

Vertical Scaling Text Placed on Chart

Postby Tortoise » Tue Apr 20, 2010 7:36 pm

Hi all,

I'm working on a DeMark indicator which places text above and below the price bars. Sometimes it's necessary to place a few items (e.g. a number and an arrow) one above the other.

The Problem
The TextOutput:set method allows you to specify the vertical placement of the text as a price level. A one hour chart usually has a couple of hundred pips from top to bottom, so placing one line of text roughly 5 or 6 pips above the other looks fine. However, on a one minute chart there might only be 30 pips from top to bottom, so placing one line of text 5 or 6 pips above the other looks really widely spaced. Then the daily or weekly chart has maybe 1 000 pips top to bottom, so only 5 or 6 pips between lines means that the text appears over the top of the other text.

My Thoughts for a Solution
IF I could find out the number of pips currently showing on the vertical scale of the chart then I could easily scale the spacing to be (for example) one twentieth of the chart. That way the line spacing would appear consistent on all charts.
However, I can't find any function that allows me to 'get' the vertical scaling of the chart.

Can anyone help? Is there
a) a way to find out the current vertical scaling of the chart, or
b) some other way to set the text a certain distance above or below the bar's high or low, instead of at a certain price?

As always, any help would be greatly appreciated.

Best regards.
Tortoise
FXCodeBase: Confirmed User
 
Posts: 7
Joined: Mon Apr 12, 2010 7:43 am

Re: Vertical Scaling Text Placed on Chart

Postby Nikolay.Gekht » Tue Apr 20, 2010 9:34 pm

Unfortunately, there is no way to locate the label as you wish. And... user can change scale freely, so in this way you'll have to monitor the scaling and update your indicator everytime when the scale is changed.

The only thing I can propose - use the fact that a label is a multiline object, so you can have a gap, expressed in whole in lines. This gap will be constant regardless to the current scale:
Just add "\013\010" ({CR}{LF}) to end of the label aligned above the price or the begin of the label aligned below the price. The gap will depend on the size of the label font. BTW, the label toolip is a multiline object as well.
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Vertical Scaling Text Placed on Chart

Postby Tortoise » Wed Apr 21, 2010 1:48 am

Great! That works a treat!

For example, putting the string "ABC" at the top of a bar makes it appear just above the bar. But putting "ABC\010" on top of the bar makes it appear one text line higher (i.e. with a gap below). Text from another stream (eg an arrow) can be placed in the gap. Similarly, putting windgdings "\010\010\225" below a bar places an up arrow with two lines' worth of blank space between it and the bottom of the bar.
Tortoise
FXCodeBase: Confirmed User
 
Posts: 7
Joined: Mon Apr 12, 2010 7:43 am


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 11 guests