Quick help required for modifying an idicator, that is almost there...

 

Hi

I have an EA that uses bands, and for what I believe to be better accuracy I am modifying the bands idicator so that I can be read by my EA, I have already done the Atr but as bands has two buffers to be looked at it has thrown me out a bit:

I have added this to indicator, near the top:

double MovingBuffer[];
double UpperBuffer[];
double LowerBuffer[];// already part of file
string gvName    = "BandsForAntony";
string gvSetting = "EaForBandsSetting";
string gvReqwest = "EaForBandsRqwest";

This before int start():

//----
   if(!GlobalVariableCheck(gvName)){GlobalVariableSet(gvName,0);}
   if(!GlobalVariableCheck(gvSetting)){BandsPeriod = GlobalVariableGet(gvSetting);}
   return(0);
  }
//+------------------------------------------------------------------+
void deinit(){GlobalVariableDel(gvName);return;}
//+------------------------------------------------------------------+

And of course this:

     MovingBuffer[i]=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);// already part of file
       if(!GlobalVariableCheck(gvReqwest)){
      int shift  = GlobalVariableGet(gvReqwest);
      GlobalVariableSet(gvName,UpperBuffer[shift]);
      GlobalVariableSet(gvName,LowerBuffer[shift]);
      }

Now I am trying to work out the EA side of things,a need to define the upper and moving buffer to be used in condition statements, this is what I have so far, is this right?:

double BB(string up_dn, int barback){int tf = 0;
   string gvName    = "BandsForAntony";
   string gvSetting = "EaForBandsSetting";
   string gvReqwest = "EaForBandsRqwest";

int theBandsPeriod;
if(Period() == PERIOD_M1)
      theBandsPeriod = BandsPeriod2;
   else
      theBandsPeriod = BandsPeriod;
  
   GlobalVariableSet(gvSetting,theBandsPeriod);
   if(!GlobalVariableCheck(gvName)){
      Comment("You forgot to to set indicator BANDS!");
      //defualt to below if I forgot to add the idicator...
   double hi = iBands(Symbol(),Period(),theBandsPeriod,BandsDeviation,0,PRICE_CLOSE,MODE_UPPER,barback);
   double lo = iBands(Symbol(),Period(),theBandsPeriod,BandsDeviation,0,PRICE_CLOSE,MODE_LOWER,barback);
   double md = iMA   (Symbol(),Period(),theBandsPeriod,0,0,PRICE_CLOSE,barback);
   }
   if(BandsSetArrow){    
      SetArrow(4,Teal,hi,"BB hi",Time[barback]);
      SetArrow(4,Teal,md,"BB midle",Time[barback]);
      SetArrow(4,Teal,lo,"BB lo",Time[barback]);
   }
   if(up_dn == "up"){
      return(hi);
   }
   if(up_dn == "dn"){
      return(lo);
   }
   return(md);
}

Thanks

Antony

 

Not quite following you.

If you are modifying the Bands.mq4 file, you must call it with iCustom()...

In your EA code you are calling the built-in function - it already has the capability of doing the uppper and lower as you have coded it.

sn

Reason: