Drawing a Line on Chart

micke81
88
micke81  

Hi all

I have managed to produce a code to draw two horizontal lines on a chart at the highest and lowest candle. This is what I want but only want to check the candles between 10am and 11am. this needs to reset the next day at 9:30. Please could someone help with this.

thanks in advance

void OnTick()  
  {
  
datetime TenAM=iTime(NULL,PERIOD_M5,0)+ 36000;
datetime ElevenAM =iTime(NULL,PERIOD_M5,0)+39600;



   MqlRates PriceInformation[];  //create an array for the price data
     
   ArraySetAsSeries(PriceInformation,true);  //sort the array current candle downwards  
   int Data = CopyRates(Symbol(),Period(),0,40,PriceInformation); //fill the array with price data
   
   
   int HighestCandle;      //create variable for highest price
   double High[];           //create array for price data
   ArraySetAsSeries(High,true);     //sort array from current candle downwards
   CopyHigh(Symbol(),Period(),0,20,High);    //fill the array with the high prices
   HighestCandle = ArrayMaximum(High,0,20);  //get the highest candle price

 
         ObjectCreate(0,"High",OBJ_HLINE,0,0,PriceInformation[HighestCandle].high); //set object properties
         ObjectSetInteger(0,"High",OBJPROP_WIDTH,2);              //set object width
         ObjectSetInteger(0,"High",OBJPROP_COLOR,clrIndigo);      //set object colour
      
         ObjectMove (0,"High",0,0,PriceInformation[HighestCandle].high);    //move the line
 
 
   int LowestCandle;      //create variable for highest price
   double Low[];           //create array for price data
   ArraySetAsSeries(Low,true);     //sort array from current candle downwards
   CopyLow(Symbol(),Period(),0,20,Low);    //fill the array with the high prices
   LowestCandle = ArrayMinimum(Low,0,20);  //get the lowest candle price

 
         ObjectCreate(0,"Low",OBJ_HLINE,0,0,PriceInformation[LowestCandle].low); //set object properties
         ObjectSetInteger(0,"Low",OBJPROP_WIDTH,2);              //set object width
         ObjectSetInteger(0,"Low",OBJPROP_COLOR,clrIndigo);      //set object colour
      
         ObjectMove (0,"Low",0,0,PriceInformation[LowestCandle].low);    //move the line
 
   
Comment ("Highest candle: ",HighestCandle, "Highest Price ",PriceInformation[HighestCandle].high,"\n",
         "Lowest candle: ",LowestCandle, "Lowest Price ",PriceInformation[LowestCandle].low);
 
  }
//+-------------------------------
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
When a graphical object is created using the ObjectCreate() function, it's necessary to specify the type of object being created, which can be one of the values of the ENUM_OBJECT enumeration. Further specifications of object properties are possible using functions for working with graphical objects.
Michael Quinatadcan Macasil Macasil
303
Michael Quinatadcan Macasil Macasil  
micke81:

Hi all

I have managed to produce a code to draw two horizontal lines on a chart at the highest and lowest candle. This is what I want but only want to check the candles between 10am and 11am. this needs to reset the next day at 9:30. Please could someone help with this.

thanks in advance


if ((TimeLocal()
 >= TenAM

) && (TimeLocal()
 <= ElevenAM))

{

//your code...

}
William Roeder
25064
William Roeder  
micke81Please could someone help with this.

Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help 2017.04.21

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum 2018.05.12

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
          No free help 2017.04.21