I am trying to have a line connect the close value every quarter hour on a 1 minute chart. The line shows on 15 minute charts and above but not on the 1 minute chart.
Below is the code I use. I believe the problem may be in the section labeled //Block for calculating indicator values.
I have also tried this and it just gives me a crazy line going everywhere:
#property indicator_chart_window#property indicator_buffers1#property indicator_plots1//--- Line properties are set using the compiler directives#property indicator_label1 "Line"// Name of a plot for the Data Window#property indicator_type1 DRAW_LINE// Type of plotting is line#property indicator_color1 clrRed// Line color#property indicator_style1 STYLE_SOLID// Line style#property indicator_width1 1// Line Width//--- An indicator buffer for the plotdouble LineBuffer[];
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- Binding an array and an indicator bufferSetIndexBuffer(0,LineBuffer,INDICATOR_DATA);
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
//--- Block for calculating indicator valuesfor(int i=0;i<rates_total;i++)
{
if(TimeMinute(Time[i])==00 || TimeMinute(Time[i])==15 || TimeMinute(Time[i])==30 || TimeMinute(Time[i])==45)
{
LineBuffer[i]=close[i];
}
}
//--- Return the prev_calculated value for the next call of the functionreturn(rates_total);
}
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.
I am trying to have a line connect the close value every quarter hour on a 1 minute chart. The line shows on 15 minute charts and above but not on the 1 minute chart.
Below is the code I use. I believe the problem may be in the section labeled //Block for calculating indicator values.
I have also tried this and it just gives me a crazy line going everywhere: