[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] the ema calculation does not add up



PureBytes Links

Trading Reference Links

In my code, i am trying to figure out when the 9 ema value and output 
it. it does not add up. here is the code and i have the _trace output 
also in the log.

As it is evident below the 9 ema value is way above the close 
numbers. 


function CheckIfHeldThroThreshold(em9, 
inputLow,em,noOfDaysofThreshold){
	bHeldAboveThreshold="Holding Good";		
	
			for( i = 0; i  < BarCount; i++ ) 	
			{

						_TRACE(" close" + em9
[i] + " low " + inputLow[i] + "ema 9" + em9[i]); 		
				
					if (em9[i] >inputLow[i])
            		{
            				bHeldAboveThreshold="Broke 
early";
					}
			}
	return bHeldAboveThreshold;
}

em=EMA(C,9);
didItHoldAbove=CheckIfHeldThroThreshold(C, L,em,5);



The actual trace data

[4028]  close5.35 low 5.29164ema 95.35
[4028]  close5.47 low 5.34844ema 95.47
[4028]  close5.47 low 5.34844ema 95.47
[4028]  close5.47 low 5.34844ema 95.47
[4028]  close5.35 low 5.10682ema 95.35
[4028]  close5.11 low 4.86667ema 95.11
[4028]  close4.74 low 4.49692ema 94.74
[4028]  close4.74 low 4.37538ema 94.74
[4028]  close4.74 low 4.37538ema 94.74
[4028]  close4.38 low 4.38ema 94.38
[4028]  close4.62 low 4.37684ema 94.62
[4028]  close4.74 low 4.37538ema 94.74
[4028]  close4.86 low 4.7385ema 94.86
[4028]  close5.23 low 4.98674ema 95.23
[4028]  close5.35 low 4.98523ema 95.35
[4028]  close5.23 low 4.98674ema 95.23
[4028]  close5.23 low 5.23ema 95.23
[4028]  close5.47 low 5.22689ema 95.47
[4028]  close5.71 low 5.40385ema 95.71
[4028]  close5.71 low 5.46702ema 95.71
[4028]  close5.47 low 5.34844ema 95.47
[4028]  close5.84 low 5.35333ema 95.84
[4028]  close5.84 low 5.59667ema 95.84
[4028]  close5.59 low 5.46848ema 95.59
[4028]  close5.84 low 5.475ema 95.84
[4028]  close5.84 low 5.475ema 95.84
[4028]  close5.96 low 5.47347ema 95.96
[4028]  close5.96 low 5.71673ema 95.96
[4028]  close5.96 low 5.71673ema 95.96
[4028]  close5.59 low 5.59ema 95.59
[4028]  close5.84 low 5.475ema 95.84
[4028]  close5.47 low 5.47ema 95.47
[4028]  close5.84 low 5.475ema 95.84
[4028]  close5.84 low 5.475ema 95.84
[4028]  close5.9 low 5.59818ema 95.9
[4028]  close5.96 low 5.5951ema 95.96
[4028]  close5.65 low 5.65ema 95.65
[4028]  close5.96 low 5.47347ema 95.96
[4028]  close5.96 low 5.5951ema 95.96
[4028]  close5.96 low 5.5951ema 95.96
[4028]  close6.57 low 5.59667ema 96.57
[4028]  close6.57 low 6.32667ema 96.57
[4028]  close6.32 low 6.32ema 96.32
[4028]  close6.44 low 6.31849ema 96.44
[4028]  close6.44 low 6.19698ema 96.44
[4028]  close6.81 low 6.20196ema 96.81
[4028]  close7.17 low 6.6839ema 97.17
[4028]  close6.69 low 6.44673ema 96.69
[4028]  close6.93 low 6.32211ema 96.93
[4028]  close7.05 low 6.68534ema 97.05
[4028]  close6.93 low 6.68684ema 96.93
[4028]  close6.81 low 6.68839ema 96.81
[4028]  close7.05 low 6.68534ema 97.05
[4028]  close6.93 low 6.68684ema 96.93
[4028]  close6.93 low 6.93ema 96.93
[4028]  close6.81 low 6.81ema 96.81
[4028]  close7.05 low 6.8069ema 97.05
[4028]  close6.93 low 6.56526ema 96.93
[4028]  close6.93 low 6.56526ema 96.93








Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.16/582 - Release Date: 12/11/2006 4:32 PM