Hi,

I would like to present you a strategy I found on QuantConnect: https://www.quantconnect.com/tutorials/strategy-library/the-dynamic-breakout-ii-strategy, which is from the book: Building Winning Trading Systems with Tradestation.


Here is my interpretation in C-Lite. However the results are quite different, even when both use Oanda data.
On the QC homepage there are 71 trades but only 45 in my experiment.

The Rules are quite simple:
1. Calculate numdays: dynamic value between 20 and 60 to be uses in the BBand and HH / LL
2. if the priceClose is above the BB_upperBand and HH(numdays) go long
if priceClose is below BB_lowerBand and LL(numdays) go short

the trades are closed when the are below / above the SMA(numdays).

The results on both sides are not impressive, tbh.

I would be gratefull for any feedback.

Code
// Dynamic Breakout II Strategy ///////////////////////
function main(){
	set(PARAMETERS|LOGFILE|PLOTNOW|BALANCE);  
	StartDate =20100115;
	EndDate = 20160215;
	Capital = 100000;
	MaxLong=MaxShort=1; 
	Verbose=7;
	
}
  
function run() 
{  
        BarPeriod = 1440; 
	LookBack= 100;  
	
	vars prices = series(priceClose()); 
	vars vol = series(StdDev(prices,20));
	vars deltavol = series(diff(StdDev(prices,20))/vol[1]);  
	vars numdays = series(20);
	numdays   =  series(clamp(round(numdays[1] * (1+deltavol[0])),20,60)) ; // the number of days must be integer and restrict 20..60 days
	vars sma = series(SMA(prices ,numdays[0]));
	
	vars hh =  series(HH(numdays[0],1));
	vars ll =  series(LL(numdays[0],1));
	BBands(prices,numdays[0], 2, 2, MAType_SMA);
	
	asset("EUR/USD");     

	// Long
	if(prices[0] > hh[0]  
	  && prices[0] > rRealUpperBand
	){
		enterLong(); 
	}
	if (prices[0] < sma[0]){
		exitLong();
	}

	// Short
	if(prices[0] < ll[1]  
		  && prices[0] < rRealLowerBand
		){
		enterShort(); 
	}
	if (prices[0] >sma[0]){
		exitShort();
	}
	    
   plot("Bollinger1",rRealUpperBand,BAND1,0x00CC00);  
	plot("Bollinger2",rRealLowerBand,BAND2,0xCC00FF00);   
}