I want to display the close prices of two currency pairs in a sub-window on the MT5 chart as custom indicator.
I'm trying to implement it with the code below, but not displayed properly like image below.
How can I display it correctly?
#property copyright "Copyright 2023"
#property link ""
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots 2
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrDeepPink
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrDarkBlue
double Symbol1Buffer[];
double Symbol2Buffer[];
int OnInit()
{
SetIndexBuffer(0, Symbol1Buffer, INDICATOR_DATA);
SetIndexBuffer(1, Symbol2Buffer, INDICATOR_DATA);
return (INIT_SUCCEEDED);
}
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[])
{
int to_copy;
to_copy = rates_total - prev_calculated;
if (to_copy == 0)
{
to_copy++;
}
CopyClose("EURUSD", 0, 0, to_copy, Symbol1Buffer);
CopyClose("GBPUSD", 0, 0, to_copy, Symbol2Buffer);
return (rates_total);
}
void OnDeinit(const int reason)
{
Print("DeInit");
return;
}
