iEnveolpe trigger and settings

 

Hi,

need a little help.

i have an indicator that seems to be working fine, i just want to add an extra filter to the trigger..

I have Envelope and would like to add the bar count and price open/close eg..Bear or Bull candle..


I have the MA Filter working  (kinda),  I seem to be only getting the BUY signals and not the SELL

BarsCount is what I am trying to code as well.   

When the iEnvelope is triggered, I want to confirm the trigger by counting 1 full candle in the same direction eg( Buy trigger, followed by a full Buy Candle following.)

 
int iEnvelopes(const ENUM_TIMEFRAMES timeframe,
           const int idx)
  { 
   int signal=OP_NONE;
   double high = iHigh(_Symbol,timeframe,idx);
   double low = iLow(_Symbol,timeframe,idx);
   double close = iClose(_Symbol,timeframe,idx);
   double upperEnvel = iEnvelopes(_Symbol,timeframe,EnPeriod,EnMethod,0,EnPrice,EnDev,MODE_UPPER,idx);
   double lowerEnvel = iEnvelopes(_Symbol,timeframe,EnPeriod,EnMethod,0,EnPrice,EnDev,MODE_LOWER,idx);
   double currMA = iMA(_Symbol,timeframe,MAPeriod,0,MAMethod,MAPrice,idx);
   double prevMA = iMA(_Symbol,timeframe,MAPeriod,0,MAMethod,MAPrice,idx+1);
  
   if((high>lowerEnvel && close<lowerEnvel )&& (currMA<prevMA*pipToDouble))// && (BarCount>1)
      {signal=OP_SELL;}
   if((low<upperEnvel && close>upperEnvel)&&(currMA>prevMA*pipToDouble))  	// (BarCount>1)



      {signal=OP_BUY;}
      
//---
   return(signal);
  }                         


I hope that makes sense..


Any help would be gratefully appreciated.

Files:
envelope.png  30 kb
 

Can anyone pls help.


My trigger is also only showing sell triggers and not Buy .

When the iEnvelope is triggered, I want to confirm the trigger by counting 1 full candle in the same direction eg( Buy trigger, followed by a full Buy Candle following.)

if((high>lowerEnvel && close<lowerEnvel )&& (previous candle close>current candle close)
      {signal=OP_SELL;}
   if((low<upperEnvel && close>upperEnvel)&&(previous candle close>current candle close)


i only want the trigger to happen when the next candle is going in the same direction,