PureBytes Links
Trading Reference Links
|
DD, you may have to think some more on the stop strategy.
Try this indicator code anyway:
---8<----------------------------
{ Date-based entry, trailing stop exit }
{ http://www.metastocktools.com }
{ AdvancedStop.dll must be in
...\MetaStock\External Function DLLs\ folder }
{ AdvancedStop.dll by Richard Dale, free from:
http://www.tradernexus.com/advancedstop/advancedstop.html }
{ User inputs }
entryDay:=Input("entry Day",1,31,1);
entryMnth:=Input("entry Month",1,12,1);
entryYear:=Input("entry Year",1800,2200,2005);
x:=Input("entry Price: [1]Open, [2]Close, [3]Weighted Close",1,3,2);
stopLoss:=
1-Input("Exit x% below entry",0,100,10)/100;
pds:=Input("EMA periods",2,260,50);
{ Entry signal }
entryPeriod:=Year()>entryYear
OR (Year()=entryYear AND (Month()>entryMnth
OR Month()=entryMnth
AND DayOfMonth()>=entryDay));
entry:=entryPeriod AND Alert(entryPeriod=0,2);
{ Entry price }
entryPrice:=If(x=1,O,If(x=2,C,WC()));
{ Trailing stop }
initialStop:=entryPrice*stopLoss;
trailStop:=Mov(C,pds,E);
stop:=ExtFml("AdvancedStop.StopLong",
entry,initialStop,0,trailStop,0,0,0,0);
{ Exit }
exit:=stop>C;
{ Initialize plot }
Init:=Cum(IsDefined(entry+exit))=1;
{ Remove redundant exits }
binary:=ValueWhen(1,entry-exit<>0,entry-exit);
exit:=
binary=-1 AND (Alert(binary>-1,2) OR Init);
{ Plot in own window }
entry-exit
---8<----------------------------
jose '-)
http://www.metastocktools.com
--- In Metastockusers@xxxxxxxxxxxxxxx, "draggiedriver" <maluabay@xxxx>
wrote:
>
> Hi everyone,
>
> I realise this may very well be reinventing the wheel: and I
> apologise in advance for the ideas I've shamelessly copied from
> Richard Dale and Jose Silva, but here it is.
>
> I want to plot a conditional indicator such that I am signalled an
> exit when c<entry*.9 or, when entry*.9< ma(c,50,e), I'll take the
> ma.
>
> I got as far as: (and this is where the plagiarism starts!)
>
> Exit Indicator
>
> entryday:=Input("Day of month",1,31,1);
> entrymonth:=Input("Month",1,12,1);
> entryyear:=Input("Year",1900,2050,2005);
> entryprice:=Input("Entry Price",0,5000,0);
> entryprice2:= If(entryprice>0,entryprice,C);
> initstop:= entryprice2 *.9;
> trailstop:= Mov(c,50,e)
>
> initstop > trailstop, initstop, trailstop
> {I'm sure my problems are in this line, because it's ALL my own
> work. HA! ;-) )
>
> entryfulldate:= (entryyear)+(entrymonth/12)+(entryday/365);
> fulldate := Year()+Month()/12+DayOfMonth()/365;
> entry:= entryfulldate > Ref(fulldate,-1) AND entryfulldate <=
> fulldate;
>
> I'd be gratified if anyone could help me on this one. It's all one
> big learning experience: and I'm sitting on the backend of the
> learning curve at the moment!
>
> Kind regards as always
>
> DD
------------------------ 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/zMEolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Metastockusers/
<*> To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|