PureBytes Links
Trading Reference Links
|
Hi Guys,
I've been able to get AB to plot On a Chart a line indicating my Buy
Price, Highest Price since bought, AND a percentage of Max profit
price that I'm willing to give back. Using a trendline (BP) I start at
the Buy price AND Date AND adjust it up as the price increases.
This works great, as long as I have a trendline with ID Of "BP", if
NOT, AB goes beserk trying to rescale the Chart to make it all fit
from a price Of zero.
Now my problem is, is there any way to Check for the existence of
trendline "BP" AND How would I disable this part Of the formula for
stocks without a trendline.
Any ideas please,
Peter
_SECTION_BEGIN("Test");
/* Display Percentage of highest profit */
profit = Param("Profits",0.5,0.05,1,0.01);
Y=Study("BP", GetChartID()); // set the name of trendline here
P=BarIndex();
STARTX=ValueWhen(IsTrue(Y) AND IsEmpty(Ref(Y,-1)),P); // barnumber at
begin of trendline
STARTY=ValueWhen(IsTrue(Y) AND IsEmpty(Ref(Y,-1)),Y); // price at
begin of trendline
ENDX=LastValue(ValueWhen(IsTrue(Y),P)); // barnumber at end of trendline
ENDY=LastValue(ValueWhen(IsTrue(Y),Y)); // price at end of trendline
take =(endy - starty) * profit + starty;
gain = Prec((C - STARTY )/STARTY * 100,2);
Plot(HHV(starty,200), "Buy Price" , colorBlack ,styleDots + styleNoLine) ;
Plot(HHV(endy,200), "Highest", colorPaleGreen ,styleDots + styleNoLine);
Plot(take,"Myprofit",ParamColor("Profit" , colorRed ,styleDots +
styleNoLine);
Plot(C,"",1,64);
_SECTION_END();
------------------------ Yahoo! Groups Sponsor --------------------~-->
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/
|