I have started this code to draw 2 horizontal line across the chart for the highest and lowest candle for 20 candles this works fine but I want to only find the highest and lowest candle between the times of 10am to 11am. At the start of a new day these lines need to reset ready for the new 10am - 11am lines.
I will add the buy signal and functions later.
void OnTick() { // MqlDateTime TimeInformation[]; // ArraySetAsSeries(TimeInformation,true); // double TimeData = CopyBuffer(Symbol(),Period(),0,20,TimeInformation); 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 if (TimeLocal() == ElevenAM) 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);