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

Re: Entry/Exit at specified price



PureBytes Links

Trading Reference Links

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 writeval(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 alternative is Excel!!!

Sean