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

[amibroker] Visual Problems from Looping Code



PureBytes Links

Trading Reference Links

Problem:
When I implement the code below in Amibroker, sometimes the output slightly changes value and/or flatlines to one value on the chart when I am scrolling across the chart (in less than maximum zoom out, while looking carefully as I scroll). Yet when I zoom out completely to look across all the data on the chart, the line and values look fine. Note, I only have this problem with an Open, High, Low, or Close array (the volume array does not seem to be affected by this problem).

What am I doing wrong? What is going on? Is it just a visual thing?

Thanks.

CODE:

// Parameters
Period = 15;
Input = Close;
SF = 2 / (Period + 1);

// Initialization of first and second values prior to start of loop
NInput[0] = Input[0]; MMA[0] = Input[0]; STD[0] = Null;
NInput[1] = Input[1]; MMA[1] = (Input[1] + Input[0]) / 2;
STD[1] = (((Input[1] - MMA[1]) ^ 2 + (Input[0] - MMA[1]) ^ 2) / 2) ^ (1/2);

for( i = 2; i < BarCount; i++ )
{    
// Normalize input to mitigate outliers
NInput[i] = IIf(Input[i] >= MMA[i-1], Min(Input[i], MMA[i-1] + 3 * STD[i-1]), Max(Input[i], MMA[i-1] - 3 * STD[i-1]));

// Moving average from normalized input
MMA[i] = SF * NInput[i] + (1 - SF) * MMA[i-1];

// Moving standard deviation from normalized input
STD[i] = (SF * (NInput[i] - MMA[i]) ^ 2 + (1 - SF) * (STD[i-1]) ^ 2) ^ (1/2);
}

Plot( MMA, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); __._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___