PureBytes Links
Trading Reference Links
|
This is great work. I tried to create something similar (on your work) But
there seems to be something wrong with the stop orders. Maybe someone can
take a look at it. I would like to implement a trailing stop, like
yesterday low and the first day use the RISK amount as stop. It is not
coded that way now because I still can't figure it out jet.
Mickey
Commission := Input("Commision Cost for round turn",0,30,20);
TradeSize := Input("Trade size",25,1000,100);
TickSize := Input("Tick Size",0.0625,0.5,0.125);
Risk := Input("Amount to Risk in points",0.5,5,1);
Trade := IF(Ref(CLOSE,-1) > Ref(Mov(CLOSE,50,S),-1) AND {actual trade
trigger}
Ref(VOLUME,-1) > Ref(Mov(VOLUME,50,S),-1) AND HIGH >=
Ref(HIGH,-1) + TickSize,
TRUE,FALSE);
Sell := Mov(CLOSE,25,VOL);
Buy := IF(Trade = TRUE,Ref(HIGH,-1) + TickSize,0);
Stop := IF(Buy > 0 AND LOW < Buy - Risk,LOW,Buy - Risk);
HitStop := IF(Stop < LOW, TRUE,FALSE);
Profit := IF(Trade = TRUE, TradeSize * Buy - Commission,0);
Profit := IF(HitStop = TRUE, Tradesize * Stop, IF(Trade AND HitStop =
FALSE,Tradesize * Sell,0));
Win := IF(Profit >0,1,0);
Loss := IF(Profit <0,1,0);
Cum(Profit)
> -----Original Message-----
> From: owner-metastock@xxxxxxxxxxxxx
> [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of Sean Taylor
> Sent: vrijdag 21 juli 2000 10:06
> To: Metastock List
> Subject: Re: Entry/Exit at specified price
>
>
> Lionel,
>
> This is what I've come up with so far.
>
> Create an indicator called 'System - Volatility Breakout'.
> Then copy this crude code in:
> *************************************************
> {Volatility Breakout System - returns Profit}
> Commission:=21; {for Buy+Sell+Stop}
> TradeAmt:=10000;
> Buy:=O+((Ref(H,-1)-Ref(C,-1))*.7);
> Sell:=C;
> Stop:=O;
> Trade:= O<Ref(C,-1) AND H>Buy AND Ref(C,-1)<Ref(C,-2) AND
> Ref(C,-2)<Ref(C,-3) AND Ref(C,-3)<Ref(C,-4); {Trigger for Trade}
>
> HitStop:= If(Trade AND Stop>=Sell,TRUE,FALSE);
> {Have we hit our Stop}
> TradeSize:= TradeAmt/Buy;
> Profit:=If(Trade,-Commission-TradeSize*Buy,0);{Purchase}
> Profit:=If(HitStop=TRUE,{then}
> Profit+Stop*TradeSize,
> {else} If(Trade AND HitStop=FALSE, {then}
> Profit+Sell*TradeSize,0)); {Sale}
> Win:=If(Profit>0,1,0);
> Loss:=If(Profit<0,1,0);
> Cum(Profit)
> *****************************************************
>
> The indicator charts your profit, you just have to set the
> first 6 variables
> as per your system. The MS If structures are a pain and I'm
> sure there must
> be easier ways to do this. This is also my first attempt to
> prove if it
> works.
>
> If you then create an Expert Advisor with the following in
> the Commentary
> definition, you'll get some summary statistics for the system:
> **************************************************************
> **************
> *********
> Volatility Breakout System
> Security Name: <Name>
> Security Symbol: <Symbol>
>
> Totals: Trades writeval( Cum( FmlVar("System - Volatility
> reakout","trade") ),0.0 ), Wins
teval(cum(
> FmlVar("System - Volatility
> Breakout","WIN") ),0.0), Losses Writeval(cum( FmlVar("System
> - Volatility
> Breakout","LOSS") ),0.0)
> Percentage Wins/Losses: writeval(cum( FmlVar("System - Volatility
> Breakout","WIN") )/Cum( FmlVar("System - Volatility
> reakout","trade") )*100,2.0)%
> Profit: $Writeval(cum( FmlVar("System - Volatility
> Breakout","PROFIT") ),0.0)
> Commission: $Writeval( FmlVar("System - Volatility
> Breakout","COMMISSION"),0.0 )
> Trade Amount: $Writeval( FmlVar("System - Volatility
> Breakout","TRADEAMT"),
> 0.0)
> **************************************************************
> **************
> **********
> If you want to Highlight the Winning days in one colour and
> the Losing days
> in another, just use 'FmlVar("System - Volatility
> Breakout","WIN")' as the
> condition for a WIN etc.
>
> The above is the only way I can see to test a system in MS
> that specifies
> the entry/exit prices. I suppose the other alternativ
e is Excel!!!
>
> Sean
>
>
>
>
|