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

Re: [EquisMetaStock Group] Writing an Indicator



PureBytes Links

Trading Reference Links


This inicator is for long only (there is a short version too) and has several plots and many
options. Slippage/brokerage costs can also be entered. I admit this is overkill for what you want
but that's probably better than something that doesn't work at all. This stop was designed to be
used in tandem with Trade Equity LE (long, equal position sixe) to give percentage profit and
stop-loss targets that can easily be read directly off the indicator. These roughly equate to
similar stops in the pre-8.0 System Tester, and give exit prices adjusted to realistically tradeable
ASX prices.

Entry and exit prices can be intrabar (any legitimate price in the HIGH/LOW range).

This example is set to enter and exit on the CLOSE of the bar on which the signal is derived, no
delays. Entry and exit commissions are set to zero so the trade capital value 'Cp' is of no
consequence. Profit and loss targets are both set to 10%.

Roy

  {Trade Stop LE V4} {V4.1 long equal}
  {Copyright© 2003 Roy Larsen}
No:=Input("Entry 1=O 2=C 3=H 4=L 5=Stop",1,5,2);
Xo:=Input("Exit 1=O 2=C 3=H 4=L 5=Stop" ,1,5,2);
Nd:=Input("Entry Delay",0,3,0);
Xd:=Input("Exit Delay" ,0,3,0);
Cm:=Input("Entry Commission $",0,99,00);
Cx:=Input("Exit Commission $" ,0,99,00);
Cp:=1000;  {* trade capital, 0 = points only *}
Xa:=2;  {* profit/loss trigger/price options *}
Xc:=2;  {* 1=C/Next-O 2=C/C 3=Stop/C 4=Stop *}
Pt:=10; {* profit target % *}
Ls:=10; {* stop loss % *}
N:= Cross(Mov(C,15,E),Mov(C,25,E));
Ns:=0;
X:= 0;
Xs:=0;
  {* end of user area *}
Pt:=Pt/100; Ls:=Ls/100;
N:=N AND Alert(N=0,2);X:=X AND Alert(X=0,2);
N:=If(Nd=0,N,Alert(N,Nd+1) AND Alert(N,Nd)=0);
N:=If(N>0,If(No=1,O,If(No=3,H,If(No=4,L,C))),0);
N:=If(No=5,If(Ns>0,Max(L,Ns),0),N);
X:=If(Xd=0,X,Alert(X,Xd+1) AND Alert(X,Xd)=0);
X:=If(X>0,If(Xo=1,O,If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Cm<.1,PREC(Cm,3),PREC(Cm*2,2)/2)),0);
Cm:=If(Xc=4 AND Cm>0,Max(L,Min(If(Tr<0,H,O),Cm)),Cm);
Cm:=If((Xc=2 OR Xc=3) AND Cm>0,C,If(Xc=1 AND Xo<5,Ref(Cm,-1),Cm));
Cm:=If(Xc=1 AND Cm>0 AND Xo<5,O,Cm);
Cx*Alert(Tr<>0,2); Cx*Pf*Alert(Tr<>0,2); Cx*Lf*Alert(Tr<>0,2);
If(Cm>0,Cm,If(Cp>0,Cp,If(Xs>0 AND Xo=5,X,0)));


----- Original Message ----- 
From: "mickie_pitts" <jaguarvp@xxxxxxxxxxxxxxxx>
To: <equismetastock@xxxxxxxxxxxxxxx>
Sent: Thursday, January 29, 2004 11:37 AM
Subject: [EquisMetaStock Group] Writing an Indicator


> I would like to write an Indicator for stock entry price.
>
> I would like for it to ask the "Entry Price", "Long or Short" and
> then plot a horzional green line for LONGS and a red line for
> Shorts.  Also display a yellow line as a stop indicator.  The stop
> indicator would be a % of the Entry price.  Would need to program
> that in say a 5%.
>
> Thanks for anyones help.
>
>
>
>
>
> 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/
>
>
>
>



 

------------------------ 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/