mardi 28 février 2017

Help required - convert to Array Code

hi,

I am new to amibroker but know a little bit about C++. I tried coding the following. Amibroker always encourages coding using Arrays and its efficient as well in performance as well as its elegant. I would like to know how to code the following using Arrays and kindly request experienced members to guide me through.

Code:

_SECTION_BEGIN("My-AFL7228");
SetBarsRequired( sbrAll, sbrAll );
TimeFrameSet( inDaily ); // switch to Daily time frame
SetChartOptions(0,chartShowArrows|chartShowDates);
m5  = MACD( 5, 10  );
m10  = MACD( 10,14  );
m14  = MACD( 14,20  );

result=0;

for( bar = 0; bar < BarCount; bar++ )
    {
        if( m5[bar] > m14[bar] )          result[ bar ] = result[ bar ]+2;
        if( m5[bar] > m10[bar] )          result[ bar ] = result[ bar ]+3;
        if( m5[bar] > 50 )                result[ bar ] = result[ bar ]+5;

        if( m5[bar] < m14[bar] )          result[ bar ] = result[ bar ]-2;
        if( m5[bar] < m10[bar] )          result[ bar ] = result[ bar ]-3;
        if( m5[bar] < 50 )                result[ bar ] = result[ bar ]-5;
        }

Pdynamic_color = Null;
_N(Title = StrFormat(" - Open %g, Hi %g, Lo %g, Close %g (%.1f%%) My-AFL-11bc", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Pdynamic_color = TimeFrameExpand(        IIf( result>7, colorGreen,
                                IIf( result>5, colorBrightGreen,
                                IIf( result<-7, colorDarkRed,
                                IIf( result<-5, colorRed, colorWhite)))), inDaily);

TimeFrameRestore(); // restore time frame to original 
Plot( MACD(12,26), "MACD", Pdynamic_color , styleNoTitle | styleHistogram );
_SECTION_END();

//



Help required - convert to Array Code

Aucun commentaire:

Enregistrer un commentaire