PureBytes Links
Trading Reference Links
|
Eric, you'll need an exit before MetaStock can determine the first
true entry signal.
Take a look at this example:
---8<--------------------------
{ EntryPrice reference, stoploss code example
for use in EntryPrice-related exit }
{ http://www.metastocktools.com }
{ User inputs }
x:=Input("EntryPrice: [1]Open, [2]High, [3]Low, [4]Close",1,4,4);
plot:=Input("[1]true EntryPrice, [2]System signals",1,2,1);
Stoploss:=1-Input("StopLoss %",0,100,4)/100;
{ Original system Entry & Exit logic }
entry:=Cross(BBandBot(C,10,S,2),C);
exit:=Cross(C,BBandBot(C,10,S,2));
{ Reference Open/High/Low/Close choice }
prc:=If(x=1,O,If(x=2,H,If(x=3,L,C)));
{ Reference system entry price,
and apply to exit as a stoploss }
trade:=If(PREV=0,If(entry,prc,0),
If(exit OR C<PREV*Stoploss,0,PREV));
{ New entry signal }
NuEntry:=trade>0 AND Alert(trade=0,2);
{ New exit signal }
NuExit:=trade=0 AND Alert(trade>0,2);
{ True entry price }
EntryPrice:=ValueWhen(1,NuEntry,prc);
{ Plot on price chart }
If(plot=1,EntryPrice,NuEntry-NuExit)
---8<--------------------------
jose '-)
http://www.metastocktools.com
--- In Metastockusers@xxxxxxxxxxxxxxx, "Eric and Chris"
<ericandchristy@xxxx> wrote:
>
> Hello,
>
> I am trying to code in my exit the first profitable exit after
> entry.
> My entry is simple close < bbandbot(c,10,s,2) (buy on close).
> I want to exit on the first profitable open after that entry so I
> use :
>
> open > valuewhen(1,close < bbandbot(c,10,s,2),close)
>
> and this works most of the time. However, when there are 2
> consecutive closes below the lower bollinger band and it opens below
> the entry then it exits on the open if the close of the 2nd bar is
> below the lower bollinger band. Which obviously isn't a profitable
> opening.
>
> I tried to use a simple if() statement but it will only let me put
> data arrays in it and not functions.
>
> Help
>
> Thanks
> Eric
------------------------ Yahoo! Groups Sponsor --------------------~-->
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/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/
|