Repeat The Create Object

 

Metatrader 5 programming help

Hi master, I need your help

I have made a script to create some object,

and I am confuse how to make it for some daily before 

This is the sript:

//+------------------------------------------------------------------+
//|                                                        coba1.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window


ENUM_TIMEFRAMES Fibo_Bar0=PERIOD_D1;    

  
   
double FIBO_levels[];
double FIBO_prices[];
string fibo_txt[];
string fibo_levels0="-70 30";
string Label_prefix="Fibo_";
int    allBars;
long   chart_ID;
//+------------------------------------------------------------------+
//| 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[])
  {
//---

 
makecrossline1(); 
makecrossline2(); 

return(rates_total);

  
}

void makecrossline1(int i=0)
{   
   double High = iHigh(NULL,Fibo_Bar0,i+1);
   double Close = iClose(NULL,Fibo_Bar0,i+1);
   double Low = iLow(NULL,Fibo_Bar0,i+1);
   double Minimum = (High + Low + Close) /5;
   double Maximum = Minimum +(High - Low) /3 ;
   double Range = Maximum - Minimum;
   double price1 = Minimum;
   double price2 = Minimum + Range;

   datetime time1 = iTime(NULL,Fibo_Bar0,i)+PeriodSeconds(Fibo_Bar0)*1;
   datetime time2 = iTime(NULL,Fibo_Bar0,i);
  
   string name1 = "1line1[i]";
   string name2 = "1line2[i]";
   
   
   ObjectCreate(0,name1, OBJ_TREND, 0, time1, price1, time2, price2);
   ObjectCreate(0,name2, OBJ_TREND, 0, time1, price2, time2, price1);
     
 }

//-------------------------------------------------

void makecrossline2(int i=1)
{   
   double High = iHigh(NULL,Fibo_Bar0,i+1);
   double Close = iClose(NULL,Fibo_Bar0,i+1);
   double Low = iLow(NULL,Fibo_Bar0,i+1);
   double Minimum = (High + Low + Close) /5;
   double Maximum = Minimum +(High - Low) /3 ;
   double Range = Maximum - Minimum;
   double price1 = Minimum;
   double price2 = Minimum + Range;

   datetime time1 = iTime(NULL,Fibo_Bar0,i)+PeriodSeconds(Fibo_Bar0)*1;
   datetime time2 = iTime(NULL,Fibo_Bar0,i);
  
   string name1 = "2line1""[i]";
   string name2 = "2line2""[i]";
   
   
   ObjectCreate(0,name1, OBJ_TREND, 0, time1, price1, time2, price2);
   ObjectCreate(0,name2, OBJ_TREND, 0, time1, price2, time2, price1);
     
 }




//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+
void DeleteObjects()
  {
   ObjectsDeleteAll(chart_ID,Label_prefix,-1,-1);
   ChartRedraw(chart_ID);
  }
//+------------------------------------------------------------------+


Thank you for the help

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
One Click Close The script allows users to easily close positions if their profit/loss reaches or exceeds a value specified in pips. Please set slippage value first. Sometimes some positions do not close due to high volatility of the market. Please set larger slippage or restart the script. The free demo version is: ...