Gann MTF

 
I'm trying to retool the Gann Hi-Low indicator to MTF so that I can focus on one chart rather than 4. I've got the following two indicators:

#MTF_RSI and Gann_alert_indicator

#MTF_RSI uses an array to push timeframes thru RSI. I'd like to do the same thing with the Gann indicator. My problem is that the Timeframe array counts up while the Gann indicator counts bars down from the lookback (period). I can't get my head around this. If anybody has got a solution for this I would be greatful.

Thanks,

KJ



//+------------------------------------------------------------------+
//|                                             Gann HiLow Alert.mq4 |
//|                                                      mastermindg |
//|                                            mastermindg@yahoo.com |
//|                                    Props to Kalenzo for the code |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
//----
#property indicator_buffers 1
#property indicator_color1 Gold
extern int Lookback = 10;
extern bool prepalert = false;
double ssl[],Hld,Hlv;
#property indicator_chart_window

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,ssl);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   //Comment("Open of Previous Bar: ",Open[1]," Close of Previous Bar: ",Close[1]," Current Price: ",Bid);
   for(int i=Bars-Lookback;i>=0;i--)
     {
      if(Close[i]>iMA(Symbol(),0,Lookback,0,MODE_SMA,PRICE_HIGH,i+1))
         Hld=1;
      else
        {
         if(Close[i]<iMA(Symbol(),0,Lookback,0,MODE_SMA,PRICE_LOW,i+1))
            Hld=-1;
         else
            Hld=0;
        }
      if(Hld!=0)
         Hlv=Hld;
      if(Hlv==-1)
         ssl[i]=iMA(Symbol(),0,Lookback,0,MODE_SMA,PRICE_HIGH,i+1);
      else
         ssl[i]=iMA(Symbol(),0,Lookback,0,MODE_SMA,PRICE_LOW,i+1);
     }
   if(prepalert!=false)
      {
      if (Volume[0]==1)  // On first tick of current bar only
         {
      if((Ask>ssl[0]) && (ssl[1]>=Open[1]) && (ssl[0]<=Close[0]))
         {
            string pbuy_alerter = StringConcatenate(Symbol()," ",Period()," Gann Value: ",ssl[0]);
            Alert("Possible BUY ",Symbol()," ",Period()," Gann Value: ",ssl[0]);
            SendMail("Gann: Possible BUY",""+pbuy_alerter);
         }
      if((Bid<ssl[0]) && (ssl[1]<=Open[1]) && (ssl[0]>=Close[0]))
         {
            string psell_alerter = StringConcatenate(Symbol()," ",Period()," Gann Value: ",ssl[0]);
            Alert("Possible SELL ",Symbol()," ",Period()," Gann Value: ",ssl[0]);
            SendMail("Gann: Possible SELL",""+psell_alerter);
         }
         }
      }
   if (Volume[0]==1)  // On first tick of current bar only
    {
      if((Ask>ssl[1]) && (ssl[2]>=Open[2]) && (ssl[1]<=Close[1]))
         {
            string buy_alerter = StringConcatenate(Symbol()," ",Period()," Gann Value: ",ssl[0]);
            SendMail("Gann: BUY",""+buy_alerter);
            Alert("BUY ",Symbol(),Period()," Gann Value: ",ssl[1],Open[1],Close[1]);
         }
      if((Bid<ssl[1]) && (ssl[2]<=Open[2]) && (ssl[1]>=Close[1]))
         {
            string sell_alerter = StringConcatenate(Symbol()," ",Period()," Gann Value: ",ssl[0]);
            SendMail("Gann: SELL",""+sell_alerter);
            Alert("SELL ",Symbol(),Period()," Gann Value: ",ssl[1],Open[1],Close[1]);
         }
    }
   
//----
   return(0);
  }
//+--------------------------------------------------------------------
Files:
fmtf_rsi.mq4  4 kb
 
Figured it out....Use an MTF Moving Average in place of iMA....works like a charm..Google MTF Moving Average.
Reason: