Hi
I am trying to make an indicator that wil paint the bar of a chart when a few moving averages are in a tight range. So if the 8, 13, 21 and 34ema are all in a 5 point range of each other it will color those bars. Am I writing this correctly? Any thoughts would be greatly appreciated.
Chris
I am trying to make an indicator that wil paint the bar of a chart when a few moving averages are in a tight range. So if the 8, 13, 21 and 34ema are all in a 5 point range of each other it will color those bars. Am I writing this correctly? Any thoughts would be greatly appreciated.
Chris
PHP Code:
var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
var vEMA13 = new MAStudy(13, 0, "Close", MAStudy.EXPONENTIAL);
var vEMA21 = new MAStudy(21, 0, "Close", MAStudy.EXPONENTIAL);
var vEMA34 = new MAStudy(34, 0, "Close", MAStudy.EXPONENTIAL);
var vLastAlert = -1;
function preMain() {
setPriceStudy(true);
setStudyTitle("movavgrg");
}
function main() {
if (
AbsValue(vEMA8.getValue(MAStudy.MA)-vEMA13.getValue(MAStudy.MA)) <= 5.0 &&
AbsValue(vEMA21.getValue(MAStudy.MA)-vEMA34.getValue(MAStudy.MA)) <= 5.0
) onAction1();
}
function postMain() {
}
function onAction1() {
setPriceBarColor(Color.RGB(255,0,255));
vLastAlert = 1;
}
Comment