How to place Symbol on top of previous candle high

Arpit T  
rtrades:

How can we place a high in the previous candle high using code?

So I want to place an X or some character on top of the last highest candle from the past 10 candles.


Thanks!

search OBJ_TEXT and iBarShift on documentation

rtrades  
Arpit T #:

search OBJ_TEXT and iBarShift on documentation

iBarshift is by time.

I would like to find the highest bar in the last 10 candles.

Keith Watford  
Use iHighest() and iHigh()
Arpit T  
Arpit T #:

use this indicator

https://www.mql5.com/en/code/38010

use this code to place text

//+------------------------------------------------------------------+
//|                                                   Last10high.mq5 |
//|                                                   Copyright 2022 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots 0
int shift =10;
//--- input parameters of the script 
input string            InpFont="Arial";         // Font 
input int               InpFontSize=10;          // Font size 
input color             InpColor=clrRed;         // Color 
input double            InpAngle=90.0;           // Slope angle in degrees 
input ENUM_ANCHOR_POINT InpAnchor=ANCHOR_TOP;   // Anchor type 
input bool              InpBack=false;           // Background object 
input bool              InpSelection=false;      // Highlight to move 
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[]) {
//---
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(time,true);
//high[shift]=iHigh(NULL,0,shift);
   //Print(high[shift]);
   if(!TextCreate(0,"TextHigh10",0,time[shift],high[shift],DoubleToString(high[shift],Digits()),InpFont,InpFontSize,
                  InpColor,-InpAngle,InpAnchor,InpBack,InpSelection,InpHidden,InpZOrder)) {
     Print(GetLastError());
   }
//--- return value of prev_calculated for next call
   return(rates_total);
}
//+------------------------------------------------------------------+
//| Creating Text object                                             |
//+------------------------------------------------------------------+
bool TextCreate(const long              chart_ID=0,               // chart's ID
                const string            name="Text",              // object name
                const int               sub_window=0,             // subwindow index
                datetime                time=0,                   // anchor point time
                double                  price=0,                  // anchor point price
                const string            text="Text",              // the text itself
                const string            font="Arial",             // font
                const int               font_size=10,             // font size
                const color             clr=clrRed,               // color
                const double            angle=0.0,                // text slope
                const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // anchor type
                const bool              back=false,               // in the background
                const bool              selection=false,          // highlight to move
                const bool              hidden=true,              // hidden in the object list
                const long              z_order=0) {              // priority for mouse click
//--- set anchor point coordinates if they are not set
   //ChangeTextEmptyPoint(time,price);
//--- reset the error value
   ResetLastError();
//--- create Text object
   if(!ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price)) {
      Print(__FUNCTION__,
            ": failed to create \"Text\" object! Error code = ",GetLastError());
      return(false);
   }
//--- set the text
   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
//--- set text font
   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
//--- set font size
   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
//--- set the slope angle of the text
   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
//--- set anchor type
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
//--- set color
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- display in the foreground (false) or background (true)
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of moving the object by mouse
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- successful execution
   return(true);
}
//+------------------------------------------------------------------+
rtrades  

Impressive work friend!

One odd thing is it doesn't work when I switch charts.  

Also this is for mt5 I've got mt4. It worked once but not when I switched charts.