Affichage des articles dont le libellé est Plot line without the loop. Afficher tous les articles
Affichage des articles dont le libellé est Plot line without the loop. Afficher tous les articles

lundi 10 octobre 2016

Plot line without the loop

I am trying to plot the stop line. The following code works but because of the loop it slows down the afl. Can anyone suggest a LOOPLESS solution?

Quote:

startBarBuy = IIf( Buy == 1 OR Short==1, BarIndex() - BarsSince( BuyStopInitial != Ref( BuyStopInitial, -1 ) )-10, Null );
startBarShort = IIf( Buy == 1 OR Short==1, BarIndex() - BarsSince( ShortStopInitial != Ref( ShortStopInitial, -1 ) -10), Null );

endBar = IIf( Buy == 1 OR Short==1, BarIndex()+10, Null );
stopline = 0;

for ( s = 0;s < BarCount - 1;s++ )
{
if ( Buy[s] == 1 ){
stopline = LineArray( startBarBuy [s], BuyStopInitialConfirmed [s], endBar[s], BuyStopInitialConfirmed[s], 0 );
Plot(stopline, "trailing stop level", colorBlue, styleDots + styleThick + styleNoTitle + styleNoLabel );
}
else if (Short[s]==1)
{
stopline = LineArray( startBarShort [s], shortStopInitialConfirmed [s], endBar[s], shortStopInitialConfirmed[s], 0 );
Plot(stopline, "trailing stop level", colorBlue, styleDots + styleThick + styleNoTitle + styleNoLabel );
}

}

Attached Images
File Type: png plot_stopline.png (29.7 KB)


Plot line without the loop