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

Re: [EquisMetaStock Group] indicator showing market position



PureBytes Links

Trading Reference Links

Luis

> I'm building my first mechanical system and I'm facing the following
> problem:
>
> how can an indicator use the current long, flat or short position on
> the market to perform calculate some formula.
>
> example:
>
> if("I'm long", do this, do that)
>
> how do I express that "I'm long" in metastock language?
>
> thanks in advance,
>
> Luis

Use one or more "latches". A latch is a memory device to remember a state or value. Remembering a
value is a little more complicated and requires a PREV based latch. PREV will also be required if
you want to manage an exit using the state of an existing position.

For a pair of simple latches that merely keep track of the state of your long and short positions
the following code will work nicely once you have entered the appropriate formulas. This "simple
latch" concept is one of the most useful tools you'll come across in MS so think twice before you
toss it as being unhelpful.

EL:=Fml("enter long"); {your enter long code}
CL:=Fml("closer long"); {your closer long code}
ES:=Fml("enter short"); {your enter short code}

CS:=Fml("close short"); {your close short code}

I:=Cum(EL+CL+ES+CS>-1)=1; {simulated starting reference signal}
Long:=BarsSince(EL+I)<BarsSince(CL+I);

Short:=BarsSince(ES+I)<BarsSince(CS+I);



Here are some more exercises to demonstrate the principles further

  {Exercise} {simple latch with Init}

Set:=Cross(Mov(C,15,E),Mov(C,25,E));

Reset:=Cross(Mov(C,25,E),Mov(C,15,E));

Init:=Cum(Set+Reset>-1)=1;

Trade:=BarsSince(Init+Set)<BarsSince(Init+Reset); {Init simulates first signal}

Trade;





  {Exercise} {price latch}

Set:=Cross(Mov(C,15,E),Mov(C,25,E));

Reset:=Cross(Mov(C,25,E),Mov(C,15,E));

Trade:=If(PREV=0,If(Set,CLOSE,0),If(Reset,0,PREV));

Trade;





  {Exercise}{price latch with entry related exit}

Set:=Cross(Mov(C,15,E),Mov(C,25,E));

Reset:=Cross(Mov(C,25,E),Mov(C,15,E));

Trade:=If(PREV=0,If(Set,C,0),If(Reset OR C>=PREV*1.2,0,PREV));

Trade;




Roy




------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/BefplB/TM
---------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/equismetastock/

<*> To unsubscribe from this group, send an email to:
     equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/