12-01-2011, 07:46 AM
|
#1 |
Join Date: Jun 2009 Location: hemel Thanks: 0
Thanked 2 Times in 2 Posts
| Quick Esginal Efs Mod Please Hi
I would like to modify the standard ema in esignal so so it changes colour if the price is above to if its below in realtime. Code: function preMain() {
setPriceStudy(true);
}
var dLastMA = 0.0;
var dThisMA = 0.0;
var dPercent = 0.0;
var dCount = 0;
var bPrimed = false;
function main(nInputLength) {
if(nInputLength == null)
nInputLength = 50;
var nBarState = getBarState();
var i;
var dValue;
var dSum = 0.0;
if(nBarState == BARSTATE_ALLBARS) {
// reset!
dPercent = (2.0 / (nInputLength + 1.0));
dLastMA = 0.0;
dThisMA = 0.0;
dCount = 0;
}
if(nBarState == BARSTATE_NEWBAR) {
dLastMA = dThisMA;
}
dThisMA = dLastMA;
if(bPrimed == false) {
dValue = getValue("Close", 0, -nInputLength);
if(dValue == null)
return;
for(i = 0; i < nInputLength; i++) {
dSum += dValue[i];
}
dLastMA = dSum / nInputLength;
dThisMA = dLastMA;
bPrimed = true;
} else {
dValue = getValue("Close");
if(dValue == null)
return;
dThisMA = (dValue - dLastMA) * dPercent + dLastMA;
}
return dThisMA;
} I would like it to be bue if the price is above and red if the price is below, can you help please?
Thanks |
| |