Question: I ' m currently working on developing an MQL 5 Expert Advisor script. In this script, I ' m implementing a functionality where I initially
Im currently working on developing an MQL Expert Advisor script. In this script, Im implementing a functionality where I initially set the end time for a graphical object, specifically a rectangle, to the current time TimeCurrent Later, I need to dynamically update this end time based on certain conditions.
In a 'Gap up scenario, if any subsequent bar closes below the lower boundary pricedn of the rectangle, I must adjust the end time of the rectangle to the time of that bar.
Similarly, in a 'Gap down' scenario, if any subsequent bar closes above the upper boundary priceup of the rectangle, I need to update the end time of the rectangle to the time of that bar.
Provide the updated complete code to incorporate these functionalities? Ensure all components of my current code are retained during the update process.
Donot use Chatgpt. Accuracy of the code will determine the rating. Take note of this.
My current MQL EA Script is
#property indicatorchartwindow
#property indicatorplots
Expert Advisor input parameters
input color InpColorToUP clrLime; Color of the gap up
input color InpColorToDN clrDeepPink; Color of the gap down
input int maxbars ; how many bars to Look back
string prefix;
double price;
Expert Advisor initialization function
int OnInit
Expert Advisor buffers mapping
prefixMQLInfoStringMQLPROGRAMNAME;
returnINITSUCCEEDED;
Expert Advisor deinitialization function
void OnDeinitconst int reason
ObjectsDeleteAllprefix;
ChartRedraw;
Expert Advisor iteration function
int OnCalculateconst int ratestotal,
const int prevcalculated,
const datetime &time
const double &open
const double &high
const double &low
const double &close
const long &tickvolume
const long &volume
const int &spread
ifratestotal return ;
price close;
ArraySetAsSeriesopentrue;
ArraySetAsSerieshightrue;
ArraySetAsSerieslowtrue;
ArraySetAsSeriesclosetrue;
ArraySetAsSeriestimetrue;
int limitratestotalprevcalculated;
iflimit
limitratestotal;
forint imaxbars; i && IsStopped; i
iflowihighi
double upfminhighilowi;
double dnfmaxhighilowi;
DrawAreaiupdntime,InpColorToUP,;
iflowihighi
double upfminhighilowi;
double dnfmaxhighilowi;
DrawAreaiupdntime,InpColorToDN,;
iflowiup : dnTimeToStringtimeindex;
ifObjectFindname
ObjectCreatename,OBJRECTANGLE,;
ObjectSetIntegername,OBJPROPSELECTABLE,false;
ObjectSetIntegername,OBJPROPHIDDEN,true;
ObjectSetIntegername,OBJPROPFILL,true;
ObjectSetIntegername,OBJPROPBACK,true;
ObjectSetStringname,OBJPROPTOOLTIP,"
;
ObjectSetInteger name, OBJPROPTIME, timeindex ;
ObjectSetInteger name, OBJPROPTIME, TimeCurrent; Set end time to current time
ObjectSetDouble name, OBJPROPPRICE, priceup;
ObjectSetDouble name, OBJPROPPRICE, pricedn;
ObjectSetInteger name, OBJPROPCOLOR, colorarea;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
