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

Re: [amibroker] AFL help please: linearray.



PureBytes Links

Trading Reference Links

The LineArray function generates array equivalent to " trend line " drawn from point (x0, y0) to point (x1, y1). x coordinates are in bars (zero based), y coordinates are in dollars.

Calculates linear regression line slope from the ARRAY using periods range

new code with "linregslope( ARRAY, periods ) " looks ok

Buy = Cross ( Close, EMA(C,30));

//price = ValueWhen(Buy,1);

x0 = ValueWhen(Buy,BarIndex(),1);

y0 = BuyPrice;

x1 = BarsSince(Buy) == 260;

//x1 = x0 + 260;

y1 = BuyPrice * 1.1;

Line = LinRegSlope(x0 AND y0 AND x1 AND y1,1);

Plot(C,"",1,64);

Plot(EMA(C,30),"",1,1);

PlotShapes(shapeUpArrow * Buy,colorBlue,0,L,-15);

Plot(Line, "line", colorGreen,1);



kris45mar <kris45mar@xxxxxxxxx> wrote:
Could someone please check I am using Linearray
correctly?

I want to plot a line from the buyprice indicating a
certain annualised percent gain, eg 10 % gain after
260 bars.

If I use this code 

******************

Buy = Cross ( Close, EMA(C,30));

//price = ValueWhen(Buy,1);


x0 = ValueWhen(Buy,BarIndex(),1);
y0 = BuyPrice;
x1 = BarsSince(Buy) == 260;
//x1 = x0 + 260;
y1 = BuyPrice * 1.1;

Line = LineArray(x0,y0,x1,y1, 0, 1);

Plot(C,"",1,64);
Plot(EMA(C,30),"",1,1);
PlotShapes(shapeUpArrow * Buy,colorBlue,0,L,-15);

Plot(Line, "line", colorGreen,1);

*******************

I get the following error:

x1 = BarsSince(Buy) == 260;
y1 = BuyPrice * 1.1;

Line = LineArray(x0,y0,x1,y1, 0, 1);
-------------------------------------------^

Error 2.
Bad argument(s)

I think I am using the LineArray function correctly.
Is there an error in my x0,x1,y0,y1 initialising?

Regards

ChrisB



           
__________________________________
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250


Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html




Do you Yahoo!?
The all-new My Yahoo! – Get yours free!

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Yahoo! Groups Sponsor
ADVERTISEMENT


Yahoo! Groups Links