Hi guys,
I'm trying this code below that i found on mql5's website, but nothing happens on the chart when i attach the indicator. No error occur either.
There should be a Buy button that i should be able to move around on the chart, but the button is not there.
What do i miss?
I'm trying this code below that i found on mql5's website, but nothing happens on the chart when i attach the indicator. No error occur either.
There should be a Buy button that i should be able to move around on the chart, but the button is not there.
What do i miss?
Inserted Code
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
int framex, framey, chart_ID;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
//---
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);
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
if(id==CHARTEVENT_OBJECT_CLICK){
if(ObjectGetInteger(chart_ID,"Frame",OBJPROP_SELECTED)){
observeFrame();
}
}
}
//+------------------------------------------------------------------+
void observeFrame(){
while(ObjectGetInteger(chart_ID,"Frame",OBJPROP_SELECTED)){
if(framex!=(int)ObjectGet("Frame",OBJPROP_XDISTANCE) || framey!=(int)ObjectGet("Frame",OBJPROP_YDISTANCE)){
framex=(int)ObjectGet("Frame",OBJPROP_XDISTANCE);
framey=(int)ObjectGet("Frame",OBJPROP_YDISTANCE);
ObjectSet("BuyButton",OBJPROP_XDISTANCE,framex-90);
ObjectSet("BuyButton",OBJPROP_YDISTANCE,framey);
//The same for other components..
}
Sleep(25);
}
} Blindly following others will make you blind!