// StopPriceCalc1.AFL KSC 08/29/2006
revised 9/11/2006// This puts in a hozizontal line from the buy price and
// shows a 3% stop (adjustable via Param) line
SetChartOptions
(2,chartShowDates);LRColor = ParamColor("L/R Color", colorYellow);
LRStyle = ParamStyle("L/R Style", styleLine | styleThick, maskAll);
BPrice = BeginValue(C);//Param("BPrice",C,C-Ref(C,-1),C+Ref(C,-1),1);
StopPC = Param("StopPC",0.03,0.01,0.20,0.005);
Plot
(C,Name(),1,1);Cum1 = Cum(1);
BVCum1 = BeginValue(Cum1);
//BVCum1 = ParamDate("BuyDate","6/1/2006");
BVCum1LV = LastValue(BVCum1);
EVCum1 = EndValue(Cum1);
Periods = EVCum1 - BVCum1;
Show = Cum1 >= BVCum1 AND Cum1 <= EVCum1;
VC = BeginValue(BPrice);
VConstant = LastValue(BPrice);
StopPrice = C * (1 - StopPC);
StopPrice2 = BeginValue(StopPrice);
StopPriceCon = LastValue(StopPrice2);
initial = StopPrice2;
// ------------ Loop for Trailing Stop -----------------
// Start loop at start of range marker
stop[ 0 ] = Close[ 0 ];
bi =
BarIndex();istart =
IIf(BeginValue(bi)==0,1, BeginValue(bi) - bi[0]);for
( i = istart ; i < BarCount; i++){
if( Close[ i ] > stop[ i - 1])
{
temp = StopPrice[i];
if( temp > stop[ i - 1 ] )
stop[ i ] = temp;
else
stop[ i ] = stop[ i - 1 ];
}
else
stop[ i ] = stop[i-1];//initial[ i ];
}
Off = IIf(BeginValue(C)==0,1,0);
Plot
(IIf(Show, VConstant, -1e10), "", colorYellow, styleLine);Plot
(IIf(Show, Stop, -1e10), "", colorRed, styleLine);//Plot(Stop,"Test Stop",colorBlue,styleLine);
// -------------- Calcs for Title -----------------------------
AboveBuy = 100*(SelectedValue(C) - BPrice)/BPrice;
ColorABuy = SelectedValue(IIf(Abovebuy>0,colorGreen,colorRed));
AboveStop = 100*(SelectedValue(C) - Stop)/Stop;
ColorAStop = SelectedValue(IIf(AboveStop>0,colorGreen,colorRed));
Title
= EncodeColor(colorBlue) + Name() + " " + FullName() + " " + Date() + "\n" +"Above Buy = " + EncodeColor(ColorABuy) + WriteVal(AboveBuy) + "% " +
EncodeColor(colorBlue) + "Above Stop = " + EncodeColor(colorAstop) + WriteVal(AboveStop) +"%";
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
| Software support | Small business finance | Business finance online |
| Business finance training | Business finance course |
YAHOO! GROUPS LINKS
- Visit your group "amibroker" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___
StopPriceCalc1.afl
Description: Binary data
