You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am trying to get a grip on the Standard Library. One of the things I do not understand is how events are managed.
The following code of an Indicator shows a label and a vertical scrollbar.
#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#include <Controls\Label.mqh>
#include <Controls\Scrolls.mqh>
CLabel myLabel;
CScrollV myScroll;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
myLabel.Create( 0, "Label", 1, 20 ,20, 100, 40 );
myLabel.Font("Arial");
myLabel.FontSize(14);
myLabel.Color(clrRed);
myLabel.Text("Init");
myScroll.Create( 0, "Scroll", 1, 120, 20, 140, 120 );
myScroll.MinPos(0);
myScroll.MaxPos(100);
myScroll.CurrPos(20);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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[])
{
//---
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
if ( id == CHARTEVENT_OBJECT_CLICK )
{
myScroll.OnEvent(id, lparam, dparam, sparam);
}
}
//+------------------------------------------------------------------+
What I am trying to do is show the current position of the scollbar in the label when (or after) the scrollbar is clicked or dragged.
Does anyone have any tips on this?
Thank you,
Paul