Hi all,
I am working on an indicator that paints the background if two moving averages are are closer than .5 Is this possible? I tried a few searches and was not able to find anything. Could someone tell me the best way to do this? I am trying to understand the best way to write up the logic. Even if this means going away from the formula wizard skeleton below.
Thank you,
Chris
I am working on an indicator that paints the background if two moving averages are are closer than .5 Is this possible? I tried a few searches and was not able to find anything. Could someone tell me the best way to do this? I am trying to understand the best way to write up the logic. Even if this means going away from the formula wizard skeleton below.
Thank you,
Chris
PHP Code:
var vSMA8 = new MAStudy(8, 0, "Close", MAStudy.SIMPLE);
var vSMA34 = new MAStudy(34, 0, "Close", MAStudy.SIMPLE);
var vLastAlert = -1;
function preMain() {
setPriceStudy(false);
setStudyTitle("marange");
setCursorLabelName("8", 0);
setCursorLabelName("34", 1);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
}
function main() {
if (
vSMA8.getValue(MAStudy.MA) <= vSMA34.getValue(MAStudy.MA)+.5
) onAction1();
return new Array(
vSMA8.getValue(MAStudy.MA)*100,
vSMA34.getValue(MAStudy.MA)*100
);
}
function postMain() {
}
function onAction1() {
setBarBgColor(Color.RGB(0,0,255));
vLastAlert = 1;
}
Comment