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 ); } } |
Plot line without the loop
Aucun commentaire:
Enregistrer un commentaire