Not getting any output on the screen for the indicator.

 

Here is the code of the indicator that I trying. Kindly help me to make it visible with proper result:  

#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://M2P_Design@hotmail.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum Pos
  {
   UpperLeft,
   UpperRight,
   LowerLeft,
   LowerRight
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
enum way
  {
   BidRatio,
   OpenRatio,
   BodyRatio,
  };

input way    CalculationBy =BodyRatio;
input int    InpPeriod     =1;

input Pos    Position      =UpperLeft;
input int    X_Offset      =5;
input int    Y_Offset      =20;

double BullO[],BearO[],BullC[],BearC[],BullS[],BearS[],Bulli[],Beari[];
double Bull,Bear;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

   Object();

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

   ObjectDelete(0,"VolBG1");
   ObjectDelete(0,"Text1");
   ObjectDelete(0,"Bulls1");
   ObjectDelete(0,"Bullish1");
   ObjectDelete(0,"UpPer1");
   ObjectDelete(0,"Bears1");
   ObjectDelete(0,"Bearish1");
   ObjectDelete(0,"DnPer1");

//---
   
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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 Bars = Bars(_Symbol,_Period);
   ArrayResize(BullO,Bars+InpPeriod);
   ArrayResize(BearO,Bars+InpPeriod);
   ArrayResize(BullC,Bars+InpPeriod);
   ArrayResize(BearC,Bars+InpPeriod);
   ArrayResize(BullS,Bars+InpPeriod);
   ArrayResize(BearS,Bars+InpPeriod);
   ArrayResize(Bulli,Bars+1);
   ArrayResize(Beari,Bars+1);

   for(int i=0; i<rates_total; i++)
     {
      //===================================PowerClose
      if(CalculationBy==BidRatio)
        {
         PowerClose(i);
         if(InpPeriod==0)
           {
            Bulli[i]=BullC[i];
            Beari[i]=BearC[i];
           }

         if(InpPeriod>0)
           {
            double Bull1=0,Bear1=0;

            for(int cnt=i; cnt<(i+InpPeriod); cnt++)
              {
               Bull1=Bull1+BullC[cnt];
               Bear1=Bear1+BearC[cnt];
              }
            Bulli[i]=Bull1/InpPeriod;
            Beari[i]=Bear1/InpPeriod;
           }
        }
      //===================================PowerOpen
      if(CalculationBy==OpenRatio)
        {
         PowerOpen(i);
         if(InpPeriod==0)
           {
            Bulli[i]=BullO[i];
            Beari[i]=BearO[i];
           }

         if(InpPeriod>0)
           {
            double Bull1=0,Bear1=0;

            for(int cnt=i; cnt<(i+InpPeriod); cnt++)
              {
               Bull1=Bull1+BullO[cnt];
               Bear1=Bear1+BearO[cnt];
              }
            Bulli[i]=Bull1/InpPeriod;
            Beari[i]=Bear1/InpPeriod;
           }
        }
      //===================================Sentiment
      if(CalculationBy==BodyRatio)
        {
         Sentiment(i);
         if(InpPeriod==0)
           {
            Bulli[i]=BullS[i];
            Beari[i]=BearS[i];
           }

         if(InpPeriod>0)
           {
            double Bull1=0,Bear1=0;

            for(int cnt=i; cnt<(i+InpPeriod); cnt++)
              {
               Bull1=Bull1+BullS[cnt];
               Bear1=Bear1+BearS[cnt];
              }
            Bulli[i]=Bull1/InpPeriod;
            Beari[i]=Bear1/InpPeriod;
           }
        }
     }
   Bull=Bulli[0];
   Bear=Beari[0];
   ObjectS(Bull,Bear);
//--- 
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| PowerOpen Calculations function                                  |
//+------------------------------------------------------------------+
void PowerOpen(int i)
  {
   double BidRatio=0;
   double Bulls=0,Bears=0;

   double PairH=iHigh(Symbol(),0,i);
   double PairL=iLow(Symbol(),0,i);

   double PairB=iOpen(Symbol(),0,i);
   double PRange=(PairH-PairL)*Point();
   if(PRange>0)
      BidRatio=(PairH-PairB)/(PairH-PairL);

   Bulls=BidRatio;
   Bears=1-Bulls;

   BullO[i] = MathRound(Bulls*100);
   BearO[i] = MathRound(Bears*100);
  }
//+------------------------------------------------------------------+
//| PowerClose Calculations function                                 |
//+------------------------------------------------------------------+
void PowerClose(int i)
  {
   double BidRatio=0;
   double Bulls=0,Bears=0;

   double PairH=iHigh(Symbol(),0,i);
   double PairL=iLow(Symbol(),0,i);

   double PairB=iClose(Symbol(),0,i);
   double PRange=(PairH-PairL)*Point();
   if(PRange>0)
      BidRatio=(PairB-PairL)/(PairH-PairL);

   Bulls=BidRatio;
   Bears=1-Bulls;

   BullC[i] = MathRound(Bulls*100);
   BearC[i] = MathRound(Bears*100);
  }
//+------------------------------------------------------------------+
//| Sentiment Calculations function                                  |
//+------------------------------------------------------------------+
void Sentiment(int i)
  {
   double Percent=0;
   double Bulls=0,Bears=0;
   double Length0=(iHigh(Symbol(),0,i)-iLow(Symbol(),0,i));

   double Body0=MathAbs(iOpen(Symbol(),0,i)-iClose(Symbol(),0,i));

   if(Length0>0)
      Percent=Body0/Length0;
   double Remain=1-Percent;

//DownCandle
   if(iOpen(Symbol(),0,i)>iClose(Symbol(),0,i))
     {
      Bulls = Remain/2;
      Bears = Percent + Bulls;
     }

//UpCandle
   else if(iOpen(Symbol(),0,i)<=iClose(Symbol(),0,i))
     {
      Bears = Remain/2;
      Bulls = Percent + Bears;
     }

   BullS[i] = MathRound(Bulls*100);
   BearS[i] = MathRound(Bears*100);
  }
//+------------------------------------------------------------------+
//| Object Modify function                                           |
//+------------------------------------------------------------------+
void ObjectS(double Bulls,double Bears)
  {
   ObjectSetInteger(0,"Bullish1",OBJPROP_XSIZE,Bulls);
   ObjectSetString(0,"UpPer1",OBJPROP_TEXT,(DoubleToString(Bulls,0)+" %"));

   ObjectSetInteger(0,"Bearish1",OBJPROP_XSIZE,Bears);
   ObjectSetString(0,"DnPer1",OBJPROP_TEXT,(DoubleToString(Bears,0)+" %"));
  }
//+------------------------------------------------------------------+
//| Object Creation function                                         |
//+------------------------------------------------------------------+
void Object()
  {
   int X=0,Y=0;
   if(Position==UpperLeft)
     {
      X=X_Offset;
      Y=Y_Offset;
     }
   if(Position==UpperRight)
     {
      X=555+X_Offset;
      Y=Y_Offset;
     }
   if(Position==LowerLeft)
     {
      X=X_Offset;
      Y=320+Y_Offset;
     }
   if(Position==LowerRight)
     {
      X=555+X_Offset;
      Y=320+Y_Offset;
     }
//===============BackGround====================
   ObjectCreate(0,"VolBG1",OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSetInteger(0,"VolBG1",OBJPROP_XDISTANCE,X);
   ObjectSetInteger(0,"VolBG1",OBJPROP_YDISTANCE,Y);
   ObjectSetInteger(0,"VolBG1",OBJPROP_XSIZE,225);
   ObjectSetInteger(0,"VolBG1",OBJPROP_YSIZE,100);
   ObjectSetInteger(0,"VolBG1",OBJPROP_BGCOLOR,clrBlack);

//==================Label======================
   ObjectCreate(0,"Text1",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Text1",OBJPROP_COLOR,clrGold);
   ObjectSetString(0,"Text1",OBJPROP_TEXT,"-- Trading Volume --");
   ObjectSetString(0,"Text1",OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,"Text1",OBJPROP_FONTSIZE,14);
   ObjectSetInteger(0,"Text1",OBJPROP_STYLE,STYLE_SOLID);
   ObjectSetInteger(0,"Text1",OBJPROP_XDISTANCE,(X+30));
   ObjectSetInteger(0,"Text1",OBJPROP_YDISTANCE,(Y+5));

//==================Bullish====================
   ObjectCreate(0,"Bulls1",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Bulls1",OBJPROP_COLOR,clrGreen);
   ObjectSetString(0,"Bulls1",OBJPROP_TEXT,"Bulls");
   ObjectSetString(0,"Bulls1",OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,"Bulls1",OBJPROP_FONTSIZE,14);
   ObjectSetInteger(0,"Bulls1",OBJPROP_XDISTANCE,(X+5));
   ObjectSetInteger(0,"Bulls1",OBJPROP_YDISTANCE,(Y+40));

   ObjectCreate(0,"Bullish1",OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSetInteger(0,"Bullish1",OBJPROP_XDISTANCE,(X+60));
   ObjectSetInteger(0,"Bullish1",OBJPROP_YDISTANCE,(Y+40));
   ObjectSetInteger(0,"Bullish1",OBJPROP_YSIZE,20);
   ObjectSetInteger(0,"Bullish1",OBJPROP_BGCOLOR,clrLimeGreen);

   ObjectCreate(0,"UpPer1",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"UpPer1",OBJPROP_COLOR,clrGreen);
   ObjectSetString(0,"UpPer1",OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,"UpPer1",OBJPROP_FONTSIZE,14);
   ObjectSetInteger(0,"UpPer1",OBJPROP_XDISTANCE,(X+165));
   ObjectSetInteger(0,"UpPer1",OBJPROP_YDISTANCE,(Y+40));

//==================Bearish====================
   ObjectCreate(0,"Bears1",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"Bears1",OBJPROP_COLOR,clrFireBrick);
   ObjectSetString(0,"Bears1",OBJPROP_TEXT,"Bears");
   ObjectSetString(0,"Bears1",OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,"Bears1",OBJPROP_FONTSIZE,14);
   ObjectSetInteger(0,"Bears1",OBJPROP_XDISTANCE,(X+5));
   ObjectSetInteger(0,"Bears1",OBJPROP_YDISTANCE,(Y+70));

   ObjectCreate(0,"Bearish1",OBJ_RECTANGLE_LABEL,0,0,0);
   ObjectSetInteger(0,"Bearish1",OBJPROP_XDISTANCE,(X+60));
   ObjectSetInteger(0,"Bearish1",OBJPROP_YDISTANCE,(Y+70));
   ObjectSetInteger(0,"Bearish1",OBJPROP_YSIZE,20);
   ObjectSetInteger(0,"Bearish1",OBJPROP_BGCOLOR,clrRed);

   ObjectCreate(0,"DnPer1",OBJ_LABEL,0,0,0);
   ObjectSetInteger(0,"DnPer1",OBJPROP_COLOR,clrFireBrick);
   ObjectSetString(0,"DnPer1",OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,"DnPer1",OBJPROP_FONTSIZE,14);
   ObjectSetInteger(0,"DnPer1",OBJPROP_XDISTANCE,(X+165));
   ObjectSetInteger(0,"DnPer1",OBJPROP_YDISTANCE,(Y+70));
  }
//+------------------------------------------------------------------+


double iHigh(string symbol,int tf,int index)

{
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyHigh(symbol,timeframe, index, 1, Arr)>0) 
        return(Arr[0]);
   else return(-1);
}

double iOpen(string symbol,int tf,int index)

{   
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyOpen(symbol,timeframe, index, 1, Arr)>0) 
        return(Arr[0]);
   else return(-1);
}
double iLow(string symbol,int tf,int index)

{
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyLow(symbol,timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}
double iClose(string symbol,int tf,int index)
{
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyClose(symbol,timeframe, index, 1, Arr)>0) 
        return(Arr[0]);
   else return(-1);
}
  
  
  ENUM_TIMEFRAMES TFMigrate(int tf)
  {
   switch(tf)
     {
      case 0: return(PERIOD_CURRENT);
      case 1: return(PERIOD_M1);
      case 5: return(PERIOD_M5);
      case 15: return(PERIOD_M15);
      case 30: return(PERIOD_M30);
      case 60: return(PERIOD_H1);
      case 240: return(PERIOD_H4);
      case 1440: return(PERIOD_D1);
      case 10080: return(PERIOD_W1);
      case 43200: return(PERIOD_MN1);
      
      case 2: return(PERIOD_M2);
      case 3: return(PERIOD_M3);
      case 4: return(PERIOD_M4);      
      case 6: return(PERIOD_M6);
      case 10: return(PERIOD_M10);
      case 12: return(PERIOD_M12);
      case 16385: return(PERIOD_H1);
      case 16386: return(PERIOD_H2);
      case 16387: return(PERIOD_H3);
      case 16388: return(PERIOD_H4);
      case 16390: return(PERIOD_H6);
      case 16392: return(PERIOD_H8);
      case 16396: return(PERIOD_H12);
      case 16408: return(PERIOD_D1);
      case 32769: return(PERIOD_W1);
      case 49153: return(PERIOD_MN1);      
      default: return(PERIOD_CURRENT);
     }
  }
 
jafferwilson :

Here is the code of the indicator that I trying. Kindly help me to make it visible with proper result:  

"Bars" cannot be used as a variable name.

"iHigh, iLow, iOpen , iClose" cannot be used as function names. 

 
Naguisa Unada:

"Bars" cannot be used as a variable name.

"iHigh, iLow, iOpen , iClose" cannot be used as function names. 

Why not? I m using MQL5. "iHigh, iLow, iOpen , iClose"  are not functions there. Hence I can use them.

 
jafferwilson:

Why not? I m using MQL5. "iHigh, iLow, iOpen , iClose"  are not functions there. Hence I can use them.

Is this mq5 file? I thought it's mq4 file because there is a name of "Trading_Vol.mq4" in the header.

Now I tried it on MT5 and have found that there is no matter to display without any fix.


 
Naguisa Unada:

Is this mq5 file? I thought it's mq4 file because there is a name of "Trading_Vol.mq4" in the header.

Now I tried it on MT5 and have found that there is no matter to display without any fix.


But I do not see any indicator on my screen, did you see it? Can you share the screen shot?

 

How about this?

ScreenShot

 
Naguisa Unada:

How about this?


Great is this on MT5? Can you share the code file?

 
Naguisa Unada:

How about this?


I see that my code worked too but for small time. Later on it vanished off my sight.

 
I have not corrected anything with your code.
Three warnings are out, but I ignore it.
It works well on my MT5.
Files:
Test.mq5  27 kb
Test.ex5  31 kb
 
Naguisa Unada:
I have not corrected anything with your code.
Three warnings are out, but I ignore it.
It works well on my MT5.

Thank you .. I will check and let you know.

Reason: