Good Morning,
Why does the following test code correctly produce a solid thick line as per the logic when applied to a 1 min chart while the thick line oscillates between thick and thin during the same period when applied to a 50 tick chart?
Best Regards,
Alan
Why does the following test code correctly produce a solid thick line as per the logic when applied to a 1 min chart while the thick line oscillates between thick and thin during the same period when applied to a 50 tick chart?
Best Regards,
Alan
PHP Code:
var xMA1 = null;
var xMA2 = null;
var xMA3 = null;
var xMA4 = null;
var aa1 = null;
var aa11 = null;
var ww = null;
var pp = null;
var qq = null;
function preMain() {
setPriceStudy(false);
setStudyTitle("CROSSOVER");
setCursorLabelName("MA1", 0);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarStyle(PS_SOLID, 3);
setDefaultBarStyle(PS_SOLID, 4);
setDefaultBarFgColor(Color.red, 0);
setDefaultBarFgColor(Color.blue, 1);
setDefaultBarFgColor(Color.black, 2);
setDefaultBarFgColor(Color.black, 3);
setDefaultBarFgColor(Color.black, 4);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(3, 2);
setDefaultBarThickness(1, 3);
setDefaultBarThickness(1, 4);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
setPlotType(PLOTTYPE_LINE, 2);
setPlotType(PLOTTYPE_LINE, 3);
setPlotType(PLOTTYPE_LINE, 4);
Symbol1 = "YM U6";
Interval1 = "1";
}
function main() {
if(getBarStateInterval("1")==BARSTATE_NEWBAR){
var vSymbol1 = Symbol1+","+Interval1;
xMA1 = offsetSeries(eval(sma)(3,eval(low)(sym(vSymbol1))),0);
xMA2 = offsetSeries(eval(sma)(3,eval(high)(sym(vSymbol1))),0);
xMA3 = offsetSeries(eval(sma)(15,eval(low)(sym(vSymbol1))),0);
xMA4 = offsetSeries(eval(sma)(15,eval(high)(sym(vSymbol1))),0);
var MA1 = xMA1.getValue(0);
var MA2 = xMA2.getValue(0);
var MA3 = xMA3.getValue(0);
var MA4 = xMA4.getValue(0);
pp = -1;
qq = 1;
ww = 0;
if(MA1 >= MA3) {
aa1 = 0.5;
setBarThickness(2,0);
}
if((MA1 >= MA4)) {
setBarThickness(6,0);
}
if(MA3 > MA1) {
setBarThickness(1,0);
aa1 = 0;
}
if(MA4 >= MA2) {
aa11 = -0.5;
setBarThickness(2,1);
}
if(MA3 >= MA2) {
aa11 = -0.5;
setBarThickness(6,1);
}
if(MA2 > MA4) {
aa11 = 0;
setBarThickness(1,1);
}
}
return new Array (aa1, aa11, ww, pp, qq);
}
Comment