Period_Open_Line Indicator For MT5
The Period_Open_Line Indicator For MT5 displays a line at the opening price of a period specified in the indicator settings. It gets overlaid as a Crimson line on the price chart. The indicator can be a handy tool for intraday traders to detect the bias of a market. Day traders can create a D1 open Period_Open_Line Indicator For MT5. This will display the opening price for the daily session under consideration. If prices manage to consistently trade above the indicator line, the underlying market bias is bullish, and traders can look to initiate long positions by employing additional technical confirmation tools. Conversely, if prices manage to stay below the indicator line for an extended period of time, the underlying market bias is bearish in nature, and traders may look to initiate short positions by applying additional technical confirmation tools. The Period_Open_Line Indicator For MT5 can be used on any liquid financial instrument; not just for intraday trading, but for swing and momentum trading also.
Installing the Period_Open_Line Indicator For MT5
After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file Period_Open_Line.mq5 into the folder MQL5\Indicators of your MT5 installation. After that please restart MT5 and then you will be able to see the indicator in the list of indicators.
Parameters of the Period_Open_Line Indicator For MT5
The Period_Open_Line Indicator For MT5 has 1 parameters to configure.
input ENUM_TIMEFRAMES InpTimeframe=PERIOD_D1; // Timeframe
Buffers of the Period_Open_Line Indicator For MT5
The Period_Open_Line Indicator For MT5 provides 1 buffers.
SetIndexBuffer(0,BufferOPN,INDICATOR_DATA);
Main Parts Of The Code
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[])
{
//--- @ gt 25@:0 =0 lt 8=8 lt 0;L= gt 5 : gt ;8G5AB2 gt 10@ gt 2 4;O @0AGQB0
if(rates_total lt 4) return 0;
//--- #AB0= gt 2:0 lt 0AA82 gt 2 1CD5@ gt 2 :0: B09 lt A5@89
ArraySetAsSeries(time,true);
//--- @ gt 25@:0 8 @0AGQB : gt ;8G5AB20 ?@ gt AG8BK205 lt KE 10@ gt 2
int limit=rates_total-prev_calculated;
if(limit gt 1)
{
limit=rates_total-1;
ArrayInitialize(BufferOPN,EMPTY_VALUE);
}
//--- 0AGQB 8=48:0B gt @0
int index=WRONG_VALUE;
for(int i=limit; i gt =0; i--)
{
index=(InpTimeframe lt PERIOD_MN1 ? BarShift(Symbol(),InpTimeframe,time[i]) : BarShift(Symbol(),InpTimeframe,BeginOfYear(time[i])));
if(index==WRONG_VALUE) return 0;
BufferOPN[i]=Open(InpTimeframe,index);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//| gt 72@0I05B A lt 5I5=85 10@0 ? gt 2@5 lt 5=8 |
//| https://www.mql5.com/ru/code/1864 |
//+------------------------------------------------------------------+
int BarShift(const string symbol_name,const ENUM_TIMEFRAMES timeframe,const datetime time,bool exact=false)
{
datetime last_bar;
if(!SeriesInfoInteger(symbol_name,timeframe,SERIES_LASTBAR_DATE,last_bar))
{
datetime array[1];
if(CopyTime(symbol_name,timeframe,0,1,array)==1)
last_bar=array[0];
else
return WRONG_VALUE;
}
if(time gt last_bar)
return(0);
int shift=Bars(symbol_name,timeframe,time,last_bar);
datetime array[1];
if(CopyTime(symbol_name,timeframe,time,1,array)==1)
return(array[0]==time ? shift-1 : exact && time gt array[0]+PeriodSeconds(timeframe) ? WRONG_VALUE : shift);
return WRONG_VALUE;
}
//+------------------------------------------------------------------+
//| gt 72@0I05B Open C:070== gt 3 gt 10@0 |
//+------------------------------------------------------------------+
double Open(const ENUM_TIMEFRAMES timeframe,const int index)
{
double array[];
ArraySetAsSeries(array,true);
if(CopyOpen(Symbol(),timeframe,index,1,array)==1) return array[0];
return 0;
}
//+------------------------------------------------------------------+
//| gt 72@0I05B 40BC =0G0;0 3 gt 40 C:070== gt 9 40BK |
//+------------------------------------------------------------------+
datetime BeginOfYear(const datetime time)
{
MqlDateTime tm;
if(!TimeToStruct(time,tm)) return WRONG_VALUE;
tm.mon=1;
tm.day=1;
return StructToTime(tm);
}
//+------------------------------------------------------------------+