Just a quick question about something. Can I create, using the formula wizard, a backtesting strategy using a study that is not built in (take for example the DiNapoli Stoch).
There is a backtesting example using a stochastic oscillator in eSignal which looks like this:
The stochastic study I'd like to use (Dinapoli) looks like this:
I'm thinking that it's not possible through the formula wizard, and if it is correct me, but if not... what's a relativley painless way to get that stoch into that backtesting study?
Thanks for all of the suggestions. I'll be working on it, but if I haven't posted again in this thread, you can reasonably assume I haven't figured it out.
Happy Thanksgiving!!!
There is a backtesting example using a stochastic oscillator in eSignal which looks like this:
PHP Code:
var study = new StochStudy(14,1,3);
function preMain() {
setPriceStudy(false);
}
function main() {
var vFast = study.getValue(StochStudy.FAST, 0, -2);
if(vFast == null)
return;
if(vFast[0] > 20 && vFast[1] <= 20) {
if(!Strategy.isLong()) {
Strategy.doLong("Over Sold", Strategy.CLOSE, Strategy.THISBAR);
}
} else if(vFast[0] < 80 && vFast[1] >= 80) {
if(!Strategy.isShort()) {
Strategy.doShort("Over Bought", Strategy.CLOSE, Strategy.THISBAR);
}
}
if(Strategy.isLong()) {
setBarBgColor(Color.green);
} else if(Strategy.isShort()) {
setBarBgColor(Color.red);
}
return vFast[0];
}
PHP Code:
function preMain()
{
setStudyTitle("Preferred Stochastic");
setCursorLabelName("percentK", 0);
setCursorLabelName("percentD", 1);
setDefaultBarFgColor(Color.lime, 0);
setDefaultBarFgColor(Color.red, 1);
}
var MAVt = null;
var MAVt1 = null;
var MAVt_1 = 0;
var MAVt1_1 = 0;
function main(nLength, nSmoothing, nSmoothings) {
if(nLength == null)
nLength = 8;
if(nSmoothing == null)
nSmoothing = 3;
if(nSmoothings == null)
nSmoothings = 3;
var percentK;
var ll = 0, hh = 0;
var sum = 0;
var vHigh = getValue("High", 0, -nLength);
var vLow = getValue("Low", 0, -nLength);
var temp = 0;
if(vHigh == null || vLow == null)
return;
for(j = 0; j < nLength; j++) {
if(j == 0) {
ll = vLow[j];
hh = vHigh[j];
} else {
hh = Math.max(hh, vHigh[j]);
ll = Math.min(ll, vLow[j]);
}
}
percentK = ((close() - ll) / (hh - ll)) * 100;
if (isNaN(percentK) == false) MAVt = MAVt_1 + (percentK - MAVt_1) / nSmoothing;
if (getBarState() == BARSTATE_NEWBAR) MAVt_1 = MAVt;
if (isNaN(percentK) == false) MAVt1 = MAVt1_1 + (MAVt - MAVt1_1) / nSmoothings;
if (getBarState() == BARSTATE_NEWBAR) MAVt1_1 = MAVt1;
return new Array(MAVt,MAVt1);
}
Thanks for all of the suggestions. I'll be working on it, but if I haven't posted again in this thread, you can reasonably assume I haven't figured it out.
Happy Thanksgiving!!!
Comment