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

Re: [amibroker] Visual Problems from Looping Code



PureBytes Links

Trading Reference Links

Hello,

I don't understand AFL code, but your indicator looks like this one 
without loop.

//priceOscillator

priceOscillator = EMA( C, 39 ) - EMA( C, 189 ) ;
Plot( 0, "", colorBlack, 4 );
up = IIf( LastValue( priceOscillator ) <= Ref( LastValue( 
priceOscillator ), -1 ), 1, 0 );
down = IIf(  priceOscillator  >= Ref( priceOscillator , -1 ), 0, 1 );
_TRACE( "up = " + up + " down = " + down );
Title = "PriceOscillator - " + Name() + "[PrOsc 39 , 189= " + WriteVal( 
priceOscillator, 4.2 ) + "";
Plot(priceOscillator,"",IIf(priceOscillator >=0, colorGreen, colorRed),4);


Best regards

searnp a écrit :
>
> 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

*********************************
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/