Download MetaTrader 5

High[x] not working.... D:

To add comments, please log in or register
Bill Brian
152
Bill Brian  

double High[];
double iHigh(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double high=0;
   ArraySetAsSeries(High,true);
   int copied=CopyHigh(symbol,timeframe,0,Bars(symbol,timeframe),High);
   if(copied>0 && index<copied) high=High[index];
   return(high);
  }

 

This doesnt work

It crashes my MT5

 Why are the old iHigh functions removed anyway

Doesnt make sense at all

Bill Brian
152
Bill Brian  

//+------------------------------------------------------------------+
//|                                                   CurrentATR.mq5 |
//|                                                              rnd |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "rnd"
#property link      ""
#property version   "1.00"
#property indicator_chart_window
//--- input parameters
input int      number=20,x=20,y=50;
input color    inputcolor=WhiteSmoke;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int a=5;
double High[];
double iHigh(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double high=0;
   ArraySetAsSeries(High,true);
   int copied=CopyHigh(symbol,timeframe,0,Bars(symbol,timeframe),High);
   if(copied>0 && index<copied) high=High[index];
   return(high);
  }

 


void CreateLabel(long   chart_id,
                 string name,
                 int    chart_corner,
                 string text_label,
                 int    x_ord,
                 int    y_ord)
  {
//---
  
   ObjectCreate(chart_id,name,OBJ_LABEL,0,0,0);
   ResetLastError();
   if(!ObjectSetInteger(chart_id,name,OBJPROP_CORNER,chart_corner))
      Print("Unable to set the angle to bind the object",
            name,", error code ",GetLastError());
   ObjectSetInteger(chart_id,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart_id,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(0,name,OBJPROP_COLOR,inputcolor);
  
   double atrstring = iATR(Symbol(), PERIOD_CURRENT , number);
   double oscstring = iMACD(Symbol(),ChartPeriod(),13,34,20,PRICE_CLOSE);
  
   Alert(High[0] + " "+ High[1]);
  
   ObjectSetString(chart_id,name,OBJPROP_TEXT, "Current ATR : "  + "  "+ DoubleToString(atrstring) + DoubleToString(oscstring));
  
  }


int OnInit()
  {
//--- indicator buffers mapping
//---
     {
//---
   int height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   int width=ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);
   string arrows[4]={"LEFT_UPPER","RIGHT_UPPER","RIGHT_LOWER","LEFT_LOWER"};
   CreateLabel(0,arrows[0],CORNER_LEFT_UPPER,"0",50,50);
  
  }
  
  

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+


  
  
   return(0);
  }
//+------------------------------------------------------------------+
//| 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[])
  {

a=a+1;
     int height=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   int width=ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);
   string arrows[4]={"LEFT_UPPER","RIGHT_UPPER","RIGHT_LOWER","LEFT_LOWER"};
   CreateLabel(0,arrows[0],CORNER_LEFT_UPPER,"0",50,50);

 
  ChartRedraw();
 
 
 
 
//---
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+-------------------------------

 

here is the ful code btw

its a bit messy but its not finished and i need High[x] to work

Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
Rashid Umarov
Admin
12700
Rashid Umarov  
Please, insert code properly.
MQL5.community - User Memo
  • 2010.02.25
  • MetaQuotes Software Corp.
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
Cym Act
192
Cym Act  

You can try this, good luck.

double iHigh(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   if(index>-1)
     {
      double high[];
      if(CopyHigh(symbol,timeframe,index,1,high)>0)
         return(high[0]);
     }
   return(-1);
  }
To add comments, please log in or register