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

[amibroker] Line Thickness



PureBytes Links

Trading Reference Links

The were several posts recently about drawing thicker lines.

Attached is a code I wrote, using code snippets from TJ and comments from Herman.

This code draws a line of variable thickness, for this sample code. Also it can draw a line acroos entire screen of only part of it.

To see this code function, you must use a chart that covers price range of 80 to 85. (IBM)

The file suffix has been changed to ".txt". You must change it to ".afl" for the code to work.


//File: Test - Draw Thick
//
//Created by Ara Kaloustian
//December 2, 2006
//
//This code draws a line of variable thickness, specified as percent of screen
//Two lines are shown: The first across entire length of screen, the second over a specified segment.
//
//For this example code use a chart that has a price range around 85. (IBM)
//
//Use parameter to see changing thickness

thickness  = Param("Thickness",5,1,20,1);

function ThickLine(Value,percent,Color)
{
//find max and min values of chart
barvisible = Status("barvisible");

upperrange = LastValue( Highest( IIf( barvisible, High, 0 ) ) );
lowerrange = LastValue( Lowest( IIf( barvisible, Low, 1e9 ) ) ) ;

Maxheight  = (upperrange - Lowerrange) * percent / 100;

for (i=-5; i<5; i++);
{
j  = Maxheight / i;
//
//Draw line across entire screen
V2 = Value - j/2;
V3 = V2 + j;
PlotOHLC(V2,V2,V3,V3,"",Color,styleCloud);
//
//Draw line for a segment of screen
V4 = V2 - 5;
V5 = V4 + j;
V6 = IIf(BarIndex() > BarCount - 30 AND BarIndex() < BarCount-10,V4,Null);
V7 = IIf(BarIndex() > BarCount - 30 AND BarIndex() < BarCount-10,V5,Null);

//
PlotOHLC(V6,V6,V7,V7,"",Color,styleCloud);

} 
}

PlotOHLC(O,H,L,C,"",colorBlack,styleCandle);
thickline(85,thickness,colorBlack);
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.15.4/563 - Release Date: 12/2/2006 9:59 AM