Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 12-01-2011, 07:46 AM   #1

Join Date: Jun 2009
Location: hemel
Posts: 87
Ignore this user

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
chrisleonard is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick MA zdo Trading Indicators 17 04-06-2009 10:05 AM
Two Quick Questions? tomar2515 Brokers and Data Feeds 0 12-08-2008 09:44 PM
Quick TS Code Help Please ephi144 Coding Forum 1 11-10-2008 01:15 PM
MP tick increment - esginal Trader_JG Market Profile 0 07-23-2007 12:20 PM
A quick hello BlowFish Introduce Yourself 4 03-25-2007 03:42 PM

All times are GMT -4. The time now is 11:10 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.