Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
From MetaStockTools.com:
Quote:
Combined Bollinger Band breakout signals & profit curve indicator
Plot this indicator three times on:
1) Price chart - with [4]BBands option;
2) Own window below price chart - [1] Clean signals option;
3) Own window below - [3] %Profit option.
This indicator uses a simplified version of the risk-normalized profit Long & Short indicators available with the URSC & MACDH Divergence kits.
These proprietary profit indicators can be a powerful part of any system development. They include risk normalization parameters, which allow rapid and valid comparisons between systems with markedly different risk profiles. They also include a Buy & Hold option and an annualized %pa function, for comparing a system's performance to a risk-normalized benchmark.
MetaStock -> Tools -> Indicator Builder -> New ->
Copy and paste complete formula between "---8<---" lines.
[code:1:5263c1ed3e]
===================================
Bollinger breakout signals & profit
===================================
---8<-----------------------------------------
{ SMA Bollinger Band breakout signals
& profit % curve.
©Copyright 2004~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 }
dev:=Input("BB Std Dev",.001,10,1);
pds:=Input("BB periods",2,252,21);
swap:=Input("Swap BB top/bot for signals? [0]No, [1]Yes",0,1,0);
cost:=Input("Total Transaction costs (Brokerage + Slippage) %:",0,100,.2)/200;
plot:=Input("Signals: [1]Clean, [2]All, [3]%Profit, [4]BBands",1,4,1);
{ Bollinger Bands }
BBtop:=BBandTop(C,pds,S,dev);
BBbot:=BBandBot(C,pds,S,dev);
{ BB signals }
entry:=If(swap,Cross(C,BBtop),Cross(C,BBbot));
exit:=If(swap,Cross(BBbot,C),Cross(BBtop,C));
allSignals:=entry-exit;
{ Profit Long % - fixed trade size - v2.2
Basic code - Entry/Exit on Close of signal }
{ Trade Binary & clean Entry/Exit signals }
init:=Cum(IsDefined(entry+exit))=1;
flag:=ValueWhen(1,entry-exit<>0 OR init,entry);
entry:=flag*(Alert(flag=0,2)
OR entry*Cum(entry)=1);
exit:=(flag=0)*(Alert(flag,2)
OR exit*Cum(exit)=1);
signals:=entry-exit;
{ Profit % curve }
EntryVal:=ValueWhen(1,entry,C*(1+cost));
Profit:=C*(1-cost)/EntryVal-1;
ProfitPer:=(flag*Profit+Cum(exit*Profit))*100;
{ Plot signals in own window }
If(plot=1,signals,If(plot=2,allSignals,
If(plot=3,ProfitPer,BBtop)));
If(plot=1,signals,If(plot=2,allSignals,
If(plot=3,ProfitPer,BBbot)))
---8<-----------------------------------------
[/code:1:5263c1ed3e]
jose '-)
|