Hi,
I'm trying to create a simple Donchian entry code. However when I load the following code I encounter two problems;
a) For some reason it does not show up in the price study...even though it is set to true.
b) When I try and backtest this entry code no trades are generated at all.
Any ideas?
var vDonch = null;
var vDonch2 = null;
function preMain() {
setPriceStudy(true);
setStudyTitle("Donchian");
setCursorLabelName("Upper");
setCursorLabelName("Lower");
setDefaultBarFgColor (Color. blue, 0);
setDefaultBarFgColor (Color. red, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
function main() {
if (Strategy.isInTrade() == false);
if (vDonch == null) vDonch = new DonchianStudy (20);
if (vDonch2 == null) vDonch2 = new DonchianStudy (20);
if(high() > vDonch.getValue (DonchianStudy.UPPER,-1)
&&!Strategy.isLong()) {
Strategy.doLong("Long", Strategy.MARKET,Strategy.NEXTBAR);
setPriceBarColor(Color.blue);
}
if (low() <vDonch2.getValue (DonchianStudy.LOWER,-1)
&&!Stategy.isShort()) {
Strategy.doShort("Short", Strategy.MARKET,Strategy.NEXTBAR);
setPriceBarColor(Color.red);
}
return new Array
(vDonch.getValue (DonchianStudy.UPPER),
vDonch2.getValue (DonchianStudy.LOWER));
}
}
I'm trying to create a simple Donchian entry code. However when I load the following code I encounter two problems;
a) For some reason it does not show up in the price study...even though it is set to true.
b) When I try and backtest this entry code no trades are generated at all.
Any ideas?
var vDonch = null;
var vDonch2 = null;
function preMain() {
setPriceStudy(true);
setStudyTitle("Donchian");
setCursorLabelName("Upper");
setCursorLabelName("Lower");
setDefaultBarFgColor (Color. blue, 0);
setDefaultBarFgColor (Color. red, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
function main() {
if (Strategy.isInTrade() == false);
if (vDonch == null) vDonch = new DonchianStudy (20);
if (vDonch2 == null) vDonch2 = new DonchianStudy (20);
if(high() > vDonch.getValue (DonchianStudy.UPPER,-1)
&&!Strategy.isLong()) {
Strategy.doLong("Long", Strategy.MARKET,Strategy.NEXTBAR);
setPriceBarColor(Color.blue);
}
if (low() <vDonch2.getValue (DonchianStudy.LOWER,-1)
&&!Stategy.isShort()) {
Strategy.doShort("Short", Strategy.MARKET,Strategy.NEXTBAR);
setPriceBarColor(Color.red);
}
return new Array
(vDonch.getValue (DonchianStudy.UPPER),
vDonch2.getValue (DonchianStudy.LOWER));
}
}
Comment