//+------------------------------------------------------------------ +
//| //
//| // How to draw a horizontal line with the lowest price within a given minutes ?
// and follow the PRICE change ?
//+------------------------------------------------------------------ +
#property copyright "Copyright"
#property link "MT4"
#property indicator_chart_window
extern int StartBar = 0;
extern int BarsBack = 15; // Use this indicator on M1 chart, here I want to get the lowest price in the past 15 minutes.
int init()
{
ObjectsDeleteAll();
// WindowRedraw();
return(0);
}
TempAn=DoubleToStr(Lowest_point,5);
if(ObjectFind(TempAn) != 0)
{
ObjectCreate(TempAn,OBJ_TEXT,0,Time[90],Lowest_point);
ObjectSetText(TempAn,"This is the lowest point line ",10,"Arial",Blue);
WindowRedraw();
}
return(0);
}
For instance, I want to draw a horizontal line with the lowest price in the past 15 minuts on the M1 chart,
If the trend continuely goes down on M1 chart, the line should accordingly move to the new lowest price.
My meanings is the line should be drawn with the lowest price in the past 15 minutes,if the current bar is the lowest,then the line should be drawn using this the new lowest price.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
//+------------------------------------------------------------------ +
//| //
//| // How to draw a horizontal line with the lowest price within a given minutes ?
// and follow the PRICE change ?
//+------------------------------------------------------------------ +
#property copyright "Copyright"
#property link "MT4"
#property indicator_chart_window
extern int StartBar = 0;
extern int BarsBack = 15; // Use this indicator on M1 chart, here I want to get the lowest price in the past 15 minutes.
int init()
{
ObjectsDeleteAll();
// WindowRedraw();
return(0);
}
int deinit()
{
ObjectsDeleteAll();
// WindowRedraw();
return(0);
}
int start()
{
double StartPrice;
string Temp,TempAn;
int Lowest_bar = 0;
int Highest_bar = 0;
double Highest_point = 0;
double Lowest_point = 0;
RefreshRates();
Lowest_bar = iLowest(NULL,0,MODE_LOW,BarsBack,StartBar);
Highest_bar = iHighest(NULL,0,MODE_HIGH,7*BarsBack,StartBar);
Highest_point=High[Highest_bar];
Lowest_point=Low[Lowest_bar];
// Draw line
Temp= "LowestLine";
if(ObjectFind(Temp) != 0)
{
ObjectCreate(Temp,OBJ_HLINE,0,0,Lowest_point);
ObjectSet(Temp,OBJPROP_STYLE,STYLE_DOT);
ObjectSet(Temp,OBJPROP_COLOR,Blue);
ObjectSet(Temp,OBJPROP_WIDTH,1);
WindowRedraw();
}
Temp= "HighestLine";
if(ObjectFind(Temp) != 0)
{
ObjectCreate(Temp,OBJ_HLINE,0,0,Highest_point);
ObjectSet(Temp,OBJPROP_STYLE,STYLE_DOT);
ObjectSet(Temp,OBJPROP_COLOR,Blue);
ObjectSet(Temp,OBJPROP_WIDTH,1);
WindowRedraw();
}
// Draw line ----END
// Draw text on line
TempAn=DoubleToStr(Lowest_point,5);
if(ObjectFind(TempAn) != 0)
{
ObjectCreate(TempAn,OBJ_TEXT,0,Time[90],Lowest_point);
ObjectSetText(TempAn,"This is the lowest point line ",10,"Arial",Blue);
WindowRedraw();
}
return(0);
}