Hi all

We've put a simplistic trade idea into code. Intuitively the description seems to make sense, but for some reasons, we get funny outputs when we train it. In particular, the first parameter never goes beyond 1.0 when we plot the charts for the parameters. Also,we only get very few trades, which seems strange.

We think that it's more of a problem on how we put it into code, rather than the idea itself, but maybe we are just sitting on a bad trade idea itself.

Would you mind taking a look at this and give some feedback and improvement suggestions?
Here's where we think that we might have problems:
- Lookback period?
- Time frame?
- the parameters in general?
- stop loss/ take profit rules could maybe be useless the way we've done it?
- unknown other issues?

Short description of the trade idea itself:

We want to identify that there is a trend, and then trade in direction of that trend based on a temporary retrace.
The trend is identified by using either (1) the rate of change of the moving average or a bandpass filter looking back a certain amount of time or (2) the rate of change of the price looking back a certain amount of time.
Once a certain rate of change is "achieved", we consider this as a threshold to say that "yes, we are in an up/downtrend".
The actual trade is triggered by a rather fast RSI on close.
Example: Say the threshold for an uptrend is that the rate of change of the moving average over the last x closing prices is -1.2, then we know that we are in a downtrend. A trade would then be triggered if the e.g. RSI (3) on close is overbought by closing e.g. above 70. (remember we want to trade in direction of the trade on a temporary weakness of the trend itself, basically assuming, that the trend will continue.)
By filtering the environment for "trending" vs. "not trending", we though we could eliminate thy typical whipsaw one gets if one purely trades based on RSI being overbought or oversold, no matter the environment.
We've thought that the stop loss could be some multiple of an ATR, and the take profit to be a trailing stop, again based on ATR. Suggestions are very welcome on this part.


Thanks in advance for your feedback. Don't hesitate to tell us that we are fooling ourselves and this is not worth pursuing any further. eek


Code
// Strategy template ///////////////////////





function run()
{
set(PARAMETERS|LOGFILE);  // generate and use optimized parameters
BarPeriod = 60; // 4 hour bars
LookBack = 500;
StartDate = 2005;
EndDate = 2017; // fixed simulation period
NumWFOCycles = 10; // activate WFO
NumCores = -1; // multicore training

asset("EUR/USD");

if(ReTrain) {
UpdateDays = -1; 
SelectWFO = -1; 
}

// calculate the buy/sell signal
vars Prices = series(price());
//var RoCValue = ROC(Prices,optimize(100,2,400,2)); // maybe use rate of change of the price or even a bandpass filter instead of the rate of change of moving averag as below???
var RoCValue = ROC(series(SMA(Prices,50)),5);
var RSIValue = RSI(Prices,optimize(2,2,40,1));

// buy and sell
var upperLimit = optimize(1.6,1,10,0.1); 
var lowerLimit = -1 * upperLimit;
var RSIoverSold = 30;
var RSIoverBought = 100 - RSIoverSold; 

Stop = optimize(1,1,20,1) * ATR(optimize(21,2,200,2)); //
Trail = optimize(1,1,20,1) * ATR(optimize(21,2,200,2)); //

if(RoCValue > upperLimit)
{
//uptrend and look out for RSI oversold
if(RSIValue < RSIoverSold)
enterLong();
}

if(RoCValue < lowerLimit)
{
//downtrend and look out for RSI overbought
if(RSIValue > RSIoverBought)
enterShort();
}

// plot signals and thresholds
PlotWidth = 1600;
PlotHeight1 = 800;
set(PLOTNOW);
}





Last edited by Smallz; 11/03/19 09:30.