Hoi,
Vandaag stel ik vast dat de funktie CMO niet meer werkt! Waarom???
----------------Funktie CMO--------------
value function CMO(value xSeries[]=Close, value xNumberOfBars=10, ?value xInclZeros=true) begin
{--- Declare the local variables ---}
?value xSumUp,xSumDown;
{--- Initialize the variables ---}
?xSumUp:=0;
?xSumDown:=0;
{--- Calculate the value based on this parameter InclZeros ---}
?if xInclZeros=true then ?begin
? ?xSumUp := Summation((xSeries-xSeries[1])>>0, xNumberOfBars);
? ?xSumDown := -(Summation((xSeries-xSeries[1])<<0, xNumberOfBars)); ? ?
?end
?else begin
{--- Declare the variables, only needed for current scope ---}
? ?value xCounterUp,xCounterDown,xI;
{--- Initialize the variables ---}
? ?xI := 0;
? ?xCounterUp := 0;
? ?xCounterDown := 0;
{--- Loop to calculate the quantities - BarsUp and BarsDown ---}
? ?while (xCounterUp+xCounterDown < xNumberOfBars) do
? ?begin
? ? ?if (xSeries[xI] > xSeries[xI+1]) then
? ? ?begin
? ? ? ?xSumUp:=xSumUp + (xSeries[xI] - xSeries[xI+1]);
? ? ? ?xCounterUp := xCounterUp + 1;
? ? ?end
? ? ?else if (xSeries[xI] < xSeries[xI+1]) then
? ? ?begin
{--- Momentum is subtracted since it is negative and we want a positive sum ---}
? ? ? ?xSumDown := xSumDown - (xSeries[xI] - xSeries[xI+1]);
? ? ? ?xCounterDown := xCounterDown + 1;
? ? ?end;
? ? ?xI := xI + 1;
? ?end;
{--- Now both sums are calculated. ?Assign CMO to return ---}
?CMO := 100 *((xSumUp - xSumDown) / (xSumUp + xSumDown));
-----------Indicator----------
value function zCMO(value xSeries[]=Close, value xNumberOfBars=10,value xInclZeros=true)
begin
plot1(CMO( xSeries,xNumberOfBars,xInclZeros),'CMO');
end;
Kan iemand helpen??,
Jo