Download MetaTrader 5

I Calculated PivotPoint, Support1 and Resistance1 for EURUSD using other currencies, check this indicator and give a feedback

To add comments, please log in or register
Samih Abdelli
65
Samih Abdelli  

Hello MQL

please give a feedback on this Indicator


it calc pivot point and R1 and S1 using the standard method and this method

this method is simple math :  EURGBP*GBPUSD=EURUSD , EURJPY/USDJPY=EURUSD ...



#property indicator_chart_window
#property indicator_buffers 0
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[],
                const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[])
  {
//---
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double dpp = (iHigh(NULL,PERIOD_D1,1)+iLow(NULL,PERIOD_D1,1)+iClose(NULL,PERIOD_D1,1))/3;
DrawLine("pp", dpp, Aqua, 2 );

double dr1 = (dpp*2)-iLow(NULL,PERIOD_D1,1);
DrawLine("r1", dr1, Lime, 2 );

double ds1 = (dpp*2)-iHigh(NULL,PERIOD_D1,1);
DrawLine("s1", ds1, Red, 2 );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double egpp = (iHigh("EURGBP",PERIOD_D1,1)+iLow("EURGBP",PERIOD_D1,1)+iClose("EURGBP",PERIOD_D1,1))/3;
double gupp = (iHigh("GBPUSD",PERIOD_D1,1)+iLow("GBPUSD",PERIOD_D1,1)+iClose("GBPUSD",PERIOD_D1,1))/3;
DrawLine("gbppp", egpp*gupp, White, 1 );

double gbpr1 = ((egpp*gupp)*2)-(iLow("EURGBP",PERIOD_D1,1)*iLow("GBPUSD",PERIOD_D1,1));
double gbps1 = ((egpp*gupp)*2)-(iHigh("EURGBP",PERIOD_D1,1)*iHigh("GBPUSD",PERIOD_D1,1));
DrawLine("gbpr1", gbpr1, Lime, 1 );
DrawLine("gbps1", gbps1, Red, 1 );

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double eapp = (iHigh("EURAUD",PERIOD_D1,1)+iLow("EURAUD",PERIOD_D1,1)+iClose("EURAUD",PERIOD_D1,1))/3;
double aupp = (iHigh("AUDUSD",PERIOD_D1,1)+iLow("AUDUSD",PERIOD_D1,1)+iClose("AUDUSD",PERIOD_D1,1))/3;
DrawLine("audpp", eapp*aupp, White, 1 );

double audr1 = ((eapp*aupp)*2)-(iLow("EURAUD",PERIOD_D1,1)*iLow("AUDUSD",PERIOD_D1,1));
double auds1 = ((eapp*aupp)*2)-(iHigh("EURAUD",PERIOD_D1,1)*iHigh("AUDUSD",PERIOD_D1,1));
DrawLine("audr1", audr1, Lime, 1 );
DrawLine("auds1", auds1, Red, 1 );

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double enpp = (iHigh("EURNZD",PERIOD_D1,1)+iLow("EURNZD",PERIOD_D1,1)+iClose("EURNZD",PERIOD_D1,1))/3;
double nupp = (iHigh("NZDUSD",PERIOD_D1,1)+iLow("NZDUSD",PERIOD_D1,1)+iClose("NZDUSD",PERIOD_D1,1))/3;
DrawLine("nzdpp", enpp*nupp, White, 1 );

double nzdr1 = ((enpp*nupp)*2)-(iLow("EURNZD",PERIOD_D1,1)*iLow("NZDUSD",PERIOD_D1,1));
double nzds1 = ((enpp*nupp)*2)-(iHigh("EURNZD",PERIOD_D1,1)*iHigh("NZDUSD",PERIOD_D1,1));
DrawLine("nzdr1", nzdr1, Lime, 1 );
DrawLine("nzds1", nzds1, Red, 1 );

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double ejpp = (iHigh("EURJPY",PERIOD_D1,1)+iLow("EURJPY",PERIOD_D1,1)+iClose("EURJPY",PERIOD_D1,1))/3;
double ujpp = (iHigh("USDJPY",PERIOD_D1,1)+iLow("USDJPY",PERIOD_D1,1)+iClose("USDJPY",PERIOD_D1,1))/3;
DrawLine("jpypp", ejpp/ujpp, White, 1 );

double jpyr1 = ((ejpp/ujpp)*2)-(iLow("EURJPY",PERIOD_D1,1)/iLow("USDJPY",PERIOD_D1,1));
double jpys1 = ((ejpp/ujpp)*2)-(iHigh("EURJPY",PERIOD_D1,1)/iHigh("USDJPY",PERIOD_D1,1));
DrawLine("jpyr1", jpyr1, Lime, 1 );
DrawLine("jpys1", jpys1, Red, 1 );

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double echpp = (iHigh("EURCHF",PERIOD_D1,1)+iLow("EURCHF",PERIOD_D1,1)+iClose("EURCHF",PERIOD_D1,1))/3;
double uchpp = (iHigh("USDCHF",PERIOD_D1,1)+iLow("USDCHF",PERIOD_D1,1)+iClose("USDCHF",PERIOD_D1,1))/3;
DrawLine("chfpp", echpp/uchpp, White, 1 );

double chfr1 = ((echpp/uchpp)*2)-(iLow("EURCHF",PERIOD_D1,1)/iLow("USDCHF",PERIOD_D1,1));
double chfs1 = ((echpp/uchpp)*2)-(iHigh("EURCHF",PERIOD_D1,1)/iHigh("USDCHF",PERIOD_D1,1));
DrawLine("chfr1", chfr1, Lime, 1 );
DrawLine("chfs1", chfs1, Red, 1 );

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double ecdpp = (iHigh("EURCAD",PERIOD_D1,1)+iLow("EURCAD",PERIOD_D1,1)+iClose("EURCAD",PERIOD_D1,1))/3;
double ucdpp = (iHigh("USDCAD",PERIOD_D1,1)+iLow("USDCAD",PERIOD_D1,1)+iClose("USDCAD",PERIOD_D1,1))/3;
DrawLine("cadpp", ecdpp/ucdpp, White, 1 );

double cadr1 = ((ecdpp/ucdpp)*2)-(iLow("EURCAD",PERIOD_D1,1)/iLow("USDCAD",PERIOD_D1,1));
double cads1 = ((ecdpp/ucdpp)*2)-(iHigh("EURCAD",PERIOD_D1,1)/iHigh("USDCAD",PERIOD_D1,1));
DrawLine("cadr1", cadr1, Lime, 1 );
DrawLine("cads1", cads1, Red, 1 );
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+
void DrawLine(string name, double price, color Color, int width ){
   ObjectCreate(name,OBJ_HLINE,0,0,price);
   ObjectSet(name,OBJPROP_COLOR,Color);
   ObjectSet(name,OBJPROP_WIDTH,width);
   ObjectSet(name, OBJPROP_PRICE1, price) ;
}
Files:
whroeder1
16572
whroeder1  
  1. double dpp = (iHigh(NULL,PERIOD_D1,1)+iLow(NULL,PERIOD_D1,1)+iClose(NULL,PERIOD_D1,1))/3;
    double egpp = (iHigh("EURGBP",PERIOD_D1,1)+iLow("EURGBP",PERIOD_D1,1)+iClose("EURGBP",PERIOD_D1,1))/3;
    you must handle 4066/4073 errors. See Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum
  2. ObjectCreate(name,OBJ_HLINE,0,0,price);
    Once you create an object they will never move, because you don't check.  If moving the line fails, then create it.
Samih Abdelli
65
Samih Abdelli  

thank you, working on it

I've downladed all the history data, so I'm not facing any error

plus, lines weren't moving without the last line in the drawline function, but not they move , tested it in strategy tester 
Samih Abdelli
65
Samih Abdelli  

new version


//+------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Black
#property indicator_color2 Black

//+------------------------+
extern int period=PERIOD_D1;

extern bool boolPP=true;
//extern bool boolSR1=true;
//extern bool boolSR2=true;
//+------------------------+
int shift;
double temp;
double pivots[11];
//+------------------------+
double pcup[],pcdn[];
//+------------------------------------------------------------------+
int OnInit()
  {
//+------------------------+
   Comment("Pivot Cluster");
//+------------------------+
   SetIndexBuffer(0,pcup);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexLabel(0,"UpCluster_"+period);

   SetIndexBuffer(1,pcdn);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
   SetIndexLabel(1,"DnCluster_"+period);

//+------------------------+

//+------------------------+
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,
                const datetime &time[],const double &open[],
                const double &high[],const double &low[],
                const double &close[],const long &tick_volume[],
                const long &volume[],const int &spread[])
  {
//+------------------------+
   int Counted_bars,i;
   Counted_bars=IndicatorCounted();
   i=Bars-Counted_bars-1;
   while(i>=0)
     {
      //+------------------+
      shift=iBarShift(Symbol(),period,Time[i],0)+1;
      if(boolPP==true)
        {
         temp=(iHigh(NULL,period,shift)+iLow(NULL,period,shift)+iClose(NULL,period,shift))/3;
         if(temp!=0)pivots[0]=temp;
         if(Symbol()=="EURUSD")
           {
            double egpp = (iHigh("EURGBP",period,shift)+iLow("EURGBP",period,shift)+iClose("EURGBP",period,shift))/3;
            double gupp = (iHigh("GBPUSD",period,shift)+iLow("GBPUSD",period,shift)+iClose("GBPUSD",period,shift))/3;
            if(egpp!=0 && gupp!=0)
              {
               pivots[1]=egpp*gupp;
              }
            double eapp = (iHigh("EURAUD",period,shift)+iLow("EURAUD",period,shift)+iClose("EURAUD",period,shift))/3;
            double aupp = (iHigh("AUDUSD",period,shift)+iLow("AUDUSD",period,shift)+iClose("AUDUSD",period,shift))/3;
            if(eapp!=0 && aupp!=0)
              {
               pivots[2]=eapp*aupp;
              }
            double enpp = (iHigh("EURNZD",period,shift)+iLow("EURNZD",period,shift)+iClose("EURNZD",period,shift))/3;
            double nupp = (iHigh("NZDUSD",period,shift)+iLow("NZDUSD",period,shift)+iClose("NZDUSD",period,shift))/3;
            if(enpp!=0 && nupp!=0)
              {
               pivots[3]=enpp*nupp;
              }
            double ejpp = (iHigh("EURJPY",period,shift)+iLow("EURJPY",period,shift)+iClose("EURJPY",period,shift))/3;
            double ujpp = (iHigh("USDJPY",period,shift)+iLow("USDJPY",period,shift)+iClose("USDJPY",period,shift))/3;
            if(ejpp!=0 && ujpp!=0)
              {
               pivots[4]=ejpp/ujpp;
              }
            double echpp = (iHigh("EURCHF",period,shift)+iLow("EURCHF",period,shift)+iClose("EURCHF",period,shift))/3;
            double uchpp = (iHigh("USDCHF",period,shift)+iLow("USDCHF",period,shift)+iClose("USDCHF",period,shift))/3;
            if(echpp!=0 && uchpp!=0)
              {
               pivots[5]=echpp/uchpp;
              }
            double ecdpp = (iHigh("EURCAD",period,shift)+iLow("EURCAD",period,shift)+iClose("EURCAD",period,shift))/3;
            double ucdpp = (iHigh("USDCAD",period,shift)+iLow("USDCAD",period,shift)+iClose("USDCAD",period,shift))/3;
            if(ecdpp!=0 && ucdpp!=0)
              {
               pivots[6]=ecdpp/ucdpp;
              }
            //
            double edkkpp = (iHigh("EURDKK",period,shift)+iLow("EURDKK",period,shift)+iClose("EURDKK",period,shift))/3;
            double udkkpp = (iHigh("USDDKK",period,shift)+iLow("USDDKK",period,shift)+iClose("USDDKK",period,shift))/3;
            if(edkkpp!=0 && udkkpp!=0)
              {
               pivots[7]=edkkpp/udkkpp;
              }
            double ehufpp = (iHigh("EURHUF",period,shift)+iLow("EURHUF",period,shift)+iClose("EURHUF",period,shift))/3;
            double uhufpp = (iHigh("USDHUF",period,shift)+iLow("USDHUF",period,shift)+iClose("USDHUF",period,shift))/3;
            if(ehufpp!=0 && uhufpp!=0)
              {
               pivots[8]=ehufpp/uhufpp;
              }
            double esekpp = (iHigh("EURSEK",period,shift)+iLow("EURSEK",period,shift)+iClose("EURSEK",period,shift))/3;
            double usekpp = (iHigh("USDSEK",period,shift)+iLow("USDSEK",period,shift)+iClose("USDSEK",period,shift))/3;
            if(esekpp!=0 && usekpp!=0)
              {
               pivots[9]=esekpp/usekpp;
              }
            double enokpp = (iHigh("EURNOK",period,shift)+iLow("EURNOK",period,shift)+iClose("EURNOK",period,shift))/3;
            double unokpp = (iHigh("USDNOK",period,shift)+iLow("USDNOK",period,shift)+iClose("USDNOK",period,shift))/3;
            if(enokpp!=0 && unokpp!=0)
              {
               pivots[10]=enokpp/unokpp;
              }
            //
           }
         //+------------------+
         ArraySort(pivots);
         pcup[i]=pivots[10];
         pcdn[i]=pivots[0];
         //+------------------+
        }
      i--;
     }//end while
//+------------------------+
   return(rates_total);
  }
//+------------------------------------------------------------------+
To add comments, please log in or register