mercredi 9 novembre 2016

How to Plot volume in a loop

Hi,

I have a MT4 indicator, which I translated into AFL. While plotting volume, it gives error that I cannot use Plot for more than 500 times. I found this solution:


But I am not sure, how to make it work with my code due to my limited skills.
Any help will be highly appreciated.

Code for AFL is given below:


Code:

_SECTION_BEGIN("EMA");
P = Volume;
Periods = Param("PeriodsEMA", 100);
Plot( EMA( P, Periods ), _DEFAULT_NAME(), colorBlack, styleLine | styleThick );
_SECTION_END();

// Param( ''name'', defaultval, min, max, step, sincr = 0 ) 
period = Param("period", 2);;
//LowColor = colorLightGrey ;
//ClimaxColor = colorGreen;
//ChurnColor = colorRed;
//ClimaxChurnColor=colorBlue;
//LowChurnColor= colorBlack ;
// dynamicrsi = IIf( Close > MA(C,10), RSI(9), RSI(14) ); 



for( i = 0; i < BarCount; i++ )
{
Value2=0;
Value3=0;
HiValue2=0;
HiValue3=0;
LoValue3=99999999;
tempv2=0;
tempv3=0;
tempv=0;
Range=(high[i]-low[i]);
Value2=Volume[i]*Range;
if(Range != 0 )
        Value3 = Volume[i]/Range;
       

for( n = 0; n < period; n++ )
{
tempv2=Volume[n]*((high[n]-low[n]));
if( tempv2 >= HiValue2 )
HiValue2 = tempv2;

if(Volume[n]*((high[n]-low[n]))!=0)
          {
            tempv3=Volume[n]/((high[n]-low[n]));
            if(tempv3>HiValue3)
              HiValue3=tempv3;
            if(tempv3<LoValue3)
              LoValue3=tempv3;
          }

if(Value2==HiValue2 && close[i]>(high[i]+low[i])/2)
        {
        BarColor[i] = colorRed;
        }
//---
      if(Value3==HiValue3)
        {
        BarColor[i] = colorGreen;

        }
      if(Value2==HiValue2 && Value3==HiValue3)
        {
        BarColor[i] = colorBlue;

        }
      if(Value2==HiValue2 && close[i]<=(high[i]+low[i])/2)
        {
        BarColor[i] = colorYellow;
        }   
       
    }

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), BarColor, ParamStyle( "Style", styleHistogram | styleThick, maskHistogram ), 2 );
_SECTION_END();
}

Thanks


How to Plot volume in a loop

Aucun commentaire:

Enregistrer un commentaire