While developing a strategy, I would like to probe and tune the setup/entry separately from exits/stops. The best way I know is to plot a price profile. It shows if a setup has some predictive power, and the results are not overlayed with exit logic.

What I am missing is a quick way to test parameter zones. Currently I do it with sliders as shown on the screenshot. Is there a way to call optimize() and plot every loop the plotPriceProfile()? Or, may be somebody has a suggestion how to override objective() function in the manner that optimize() considers as "good" tall & broad peaks on the price profile?


Just to be complete, here's the pseudo-strategy. It consists of setup, entry is immediately, no stops, exit after X bars, full hedging to see the predictive power of setup. Which is: after MACD signal line crosses zero (trend direction), wait until MACD line crosses the signal line in opposite direction (correction) and enter the position in the trend direction.
Code:
#include <profile.c>
#define PROFILEDEPTH 30
function run()
{
	int fastlen = slider(1, 12, 8, 14,  "FastMA", "FastMA");
	int slowlen = slider(2, 26, 16, 32, "SlowMA", "SlowMA");
	int signallen = slider(3, 9, 7, 11, "SignalMA", "SignalMA");
	vars Price = series(priceClose());
	vars FastMA = series(EMA(Price,fastlen));
	vars SlowMA = series(EMA(Price,slowlen));
	vars Macd = series(FastMA[0] - SlowMA[0]);
	vars MacdSignal = series(EMA(Macd, signallen));
	static int pbctr; //pullback counter
	StartDate = 20130501;
	Hedge = 2; //enter and open long and short positions simultaneously
	if (is(INITRUN)) {
		pbctr = 0;
	}
	for (open_trades) {
		if (TradeTime > PROFILEDEPTH) {
			exitTrade(ThisTrade);
		}
	}
	if (crossOver(MacdSignal, 0) || crossUnder(MacdSignal, 0)) {
		pbctr = 0;
	}
  	if ((MacdSignal[0] > 0) && crossUnder(Macd, MacdSignal)) {
  		pbctr++;
  		if (pbctr <= 1) {
  			plotPriceProfile(PROFILEDEPTH, 0);
  			enterLong();
  		}
  	}
  	if ((MacdSignal[0] < 0) && crossOver(Macd, MacdSignal)) {
  		pbctr++;
  		if (pbctr <= 1) {
  			plotPriceProfile(PROFILEDEPTH, 2);
  			enterShort();
  		}
  	}
}


Last edited by webradio; 12/12/14 20:06.