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

Re: [amibroker] Re: Distance bewtween bars question



PureBytes Links

Trading Reference Links

Here is an example of finding the values for the left and right ends
of 2 lines, with studyID "F1" & "F2". This is fairly old one I dug up
in particular this draws lines according to fib ratios of the distance
between the 2 lines. No idea why i did this now.
But it will give you one method, albeit old, of working with lines.

Plot(C,"",colorBlack,styleBar);

Upper=ValueWhen(NOT IsNull( Study("f1",GetChartID())
),Study("f1",GetChartID()));
Lower=ValueWhen(NOT IsNull( Study("f2",GetChartID())),Study("f2",GetChartID()));

TLB = ValueWhen( Upper AND IsNull(Ref(Upper,-1)), BarIndex());
TLP = ValueWhen( Upper AND IsNull(Ref(Upper,-1)), Upper );
TRB = ValueWhen( Upper ==LastValue(Upper), BarIndex());
TRP = ValueWhen( Upper ==LastValue(Upper), Upper );

BLB = ValueWhen( Lower AND IsNull(Ref(Lower,-1)), BarIndex());
BLP = ValueWhen( Lower AND IsNull(Ref(Lower,-1)), Lower );
BRB = ValueWhen( Lower ==LastValue(Lower), BarIndex());
BRP = ValueWhen( Lower ==LastValue(Lower), Lower );

procedure FibLine(x,y)
{
LB = LastValue( BLB+(TLB-BLB)*x );
RB = LastValue( BRB+(TRB-BRB)*x );
LP = LastValue( BLP+(TLP-BLP)*x );
RP = LastValue( BRP+(TRP-BRP)*x );
Line = LineArray( LB, LP, RB, RP ,0 );
Plot( Line, "Line "+(x*100)+"%", y, styleLine);
}

FibLine(0.5,colorRed);
FibLine(0.618,colorBlue);
FibLine(0.382,colorGreen);
FibLine(1.618,colorRed);
FibLine(-0.618,colorRed);

On 8/16/05, Alex Dolaptchiev <axle_d@xxxxxxxxx> wrote:
> Graham ... thanks for the reply, however i have tried anumber of
> different variants but still cannot determine what the code would be
> to get:
> 
> 1.  First value of X or Y base on where I draw the line from
> 2.  Second value of X or Y based on where I end the line
> 
> Also,
> 
> Is there some way I can get the value to show on the beginning and end
> of the line that I draw.
> 
> Thanks for any constructive help or criticism
> 
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxxx> wrote:
> > draw the line, then open its properties window and give it a studyID
> > then use this in the code to define its prices/bars points
> >
> > On 8/11/05, Alex Dolaptchiev <axle_d@xxxx> wrote:
> > > Can anyone help with code or a method to do the following:
> > >
> > > 1. Draw a line b/w any two bars
> > > 2. Display will show:
> > >             - number of bars between the two
> > >             - price difference between the two points
> > >
> > > thank you
> > >
> > >
> > >
> > >
> > >
> > > 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
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > --
> > Cheers
> > Graham
> > AB-Write >< Professional AFL Writing Service
> > Yes, I write AFL code to your requirements
> > http://e-wire.net.au/~eb_kavan/ab_write.htm
> 
> 
> 
> 
> 
> 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
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 


-- 
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12hiuvat5/M=362131.6882500.7825259.1493532/D=groups/S=1705632198:TM/Y=YAHOO/EXP=1124184095/A=2889190/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Put more honey in your pocket. (money matters made easy) Welcome to the Sweet Life - brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

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

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/