//+------------------------------------------------------------------+ //| Fibo.mq4 | //| ziadmail7@gmail.com | //| https://www.facebook.com/ziadmail7 | //+------------------------------------------------------------------+ #property copyright "ziadmail7@gmail.com" #property link "https://www.facebook.com/ziadmail7" #property version "1.00" #property strict #property indicator_chart_window input string InpName="FiboLevels"; // Object name input int InpDate1=10; // 1 st point's date, % input int InpPrice1=65; // 1 st point's price, % input int InpDate2=90; // 2 nd point's date, % input int InpPrice2=85; // 2 nd point's price, % input color InpColor=clrRed; // Object color input ENUM_LINE_STYLE InpStyle=STYLE_DASHDOTDOT; // Line style input int InpWidth=1; // Line width input bool InpBack=false; // Background object input bool InpSelection=true; // Highlight to move input bool InpRayRight=false; // Object's continuation to the right input bool InpHidden=true; // Hidden in the object list input long InpZOrder=0; // Priority for mouse click //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| 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[]) { if(InpDate1<0 || InpDate1>100 || InpPrice1<0 || InpPrice1>100 || InpDate2<0 || InpDate2>100 || InpPrice2<0 || InpPrice2>100) { Print("Error! Incorrect values of input parameters!"); return(0); } //--- number of visible bars in the chart window int bars=(int)ChartGetInteger(0,CHART_VISIBLE_BARS); //--- price array size int accuracy=1000; //--- arrays for storing the date and price values to be used //--- for setting and changing the coordinates of Fibonacci Retracement anchor points datetime date[]; double price[]; //--- memory allocation ArrayResize(date,bars); ArrayResize(price,accuracy); //--- fill the array of dates ResetLastError(); if(CopyTime(Symbol(),Period(),0,bars,date)==-1) { Print("Failed to copy time values! Error code = ",GetLastError()); return(0); } //--- fill the array of prices //--- find the highest and lowest values of the chart double max_price=ChartGetDouble(0,CHART_PRICE_MAX); double min_price=ChartGetDouble(0,CHART_PRICE_MIN); //--- define a change step of a price and fill the array double step=(max_price-min_price)/accuracy; for(int i=0;i