MetaStock -> Tools -> Indicator Builder -> New -> Copy and paste complete formula between "---8<---" lines. ======================= EntryPrice related exit ======================= ---8<----------------------------- { ProfitStop/StopLoss code example for use in self-referenced EntryPrice-related exit. ©Copyright 2005~2006 Jose Silva. The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com } { User inputs } ProfitPer:=1+Input("ProfitStop %",0,100,25)/100; StopPer:=1-Input("StopLoss %",0,100,10)/100; x:=Input("EntryPrice: [1]Open, [2]High, [3]Low, [4]Close",1,4,3); plot:=Input("[1]Signals, [2]Stops",1,2,1); { Sample system Entry Long } entry:=Mov(C,5,S)>Mov(C,15,S); { Entry 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 ProfitStop/StopLoss } trade:=If(PREV=0,If(entry,prc,0), If(C>PREV*ProfitPer OR C0 AND Alert(trade=0,2); { New exit signal } NuExit:=trade=0 AND Alert(trade>0,2); { Final Entry/Exit signals } signals:=NuEntry-NuExit; { True entry price } EntryPrice:=ValueWhen(1,NuEntry,prc); { ProfitStop } ProfitStop:=EntryPrice*ProfitPer; { StopLoss } StopLoss:=EntryPrice*StopPer; { Plot signals in own window, stops on price chart } If(plot=1,0,ProfitStop); If(plot=1,signals,StopLoss) ---8<----------------------------- http://www.metastocktools.com