Hello fellow traders,
I am new to trading and amibroker. I know a little about c++ so was trying to code the following in amibroker. But I would like to know the same logic coded using arrays (Not using for loop). I would humbly request experienced traderji members to kindly guide me.
:)
I am new to trading and amibroker. I know a little about c++ so was trying to code the following in amibroker. But I would like to know the same logic coded using arrays (Not using for loop). I would humbly request experienced traderji members to kindly guide me.
:)
Code:
_SECTION_BEGIN("My-AFL-11bc-Price");
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();
//
Array Code required
Aucun commentaire:
Enregistrer un commentaire