How to draw a horizonal line

Indicators coded by community members
Message
Author
gglamonakis
Posts: 23
Joined: Sun Jun 19, 2011 10:19 am

How to draw a horizonal line

#1 Postby gglamonakis » Sun Jun 19, 2011 10:27 am

Hi,

I am trying to draw a horizontal lines at a fixed level with my indicator using the AddLevel function but 1) the double value always seems to truncate at 2 decimal places and 2) I dont see a line drawn on the chart when I add the indicator.

This is my code

double dBaseLine;

EXPORT void __stdcall Init()
{

IndicatorShortName("AbsFib");
SetOutputWindow(ow_ChartWindow);

RegOption("Highest Baseline Value", ot_Double, &dBaseLine);

AddLevel(dBaseLine, psSolid, 2, clRed);



}

If this is not the right way to draw a horizontal line on the chart can you give me an example of how this should be done.

Thanks,
Greg

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#2 Postby FT Support » Mon Jun 20, 2011 10:45 am

Hello,

You can only use constant levels in "Init" procedure because this procedure is called before the user can enter level value.

If you need to have dynamic levels then please use objects, for example:

Code: Select all

EXPORT void __stdcall Calculate()
{
...
ObjectCreate('HLine', obj_HLine, 0, 0, Close(0));
...
}


See more info about objects in Forex Tester -> Help -> Indicators API
Check our other product here:
http://www.forexcopier.com

gglamonakis
Posts: 23
Joined: Sun Jun 19, 2011 10:19 am

#3 Postby gglamonakis » Mon Jun 20, 2011 3:22 pm

Hi,

Thanks for your help. I appreciate your time. I dont need dynamic hoizontal lines. I would just like to add static horizontal lines at a fixed prices on the chart in the Init method and they would remain at that level until the indicator is removed (or the chart window is closed).

Can I use AddLevel() to add a static horizontal line at a fixed price in the Init method of an indicator? If so can you tell from my code sample why 1) the double value always seems to truncate at 2 decimal places and 2) I dont see a line drawn on the chart when I add the indicator.

Or will I have to use Objectxxx methods to add these lines?

Thanks very much for your help,
Greg

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#4 Postby FT Support » Wed Jun 22, 2011 9:50 am

Hello Greg,

In Init procedure you have to use constant values only. So please try to add levels like this:

AddLevel(1.5555, psSolid, 2, clRed);
Check our other product here:
http://www.forexcopier.com


Return to “Indicators”

Who is online

Users browsing this forum: No registered users and 11 guests