I've shortened the code a little.
It creates the chart, and I can open it and see it. But the data is all wrong and it doesn't constantly update. Can anyone assist?
//+------------------------------------------------------------------+ //| Currency LIVE.mq4 | //| Copyright 2021, Nondisclosure007 | //| https://no.link.yet | //| Indicator draws nothing. Creates chart Constant "Waiting for update" //+------------------------------------------------------------------+ #property copyright "Copyright 2021, Nondisclosure007" #property link "https://no.link.yet" #property version "1.00" #property strict #property indicator_chart_window #include <winuser32.mqh> #include <stdlib.mqh> #include <stderror.mqh> #include <Files\FileHistory.mqh> #include <Charts\Chart.mqh> CFileHistory oFile; CChart oChart; MqlRates rateinfo; int hwnd = 0; //--- input parameters input string inpCurrency = "USD"; input int inpPeriod = 3; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- int ver = 401; string cr = "copyleft"; string symbol = "USD"; int digits = Digits; int unused[13]; int hf = oFile.OpenHistory(inpCurrency+IntegerToString(inpPeriod)); if(hf < 0) { Print("Opening USD failed! Not initialized!"); return(INIT_FAILED); } if(oFile.Size() <=0) { oFile.WriteInteger(ver); oFile.WriteString(cr,64); oFile.WriteString(symbol,12); oFile.WriteInteger(inpPeriod); oFile.WriteInteger(digits); oFile.WriteInteger(0); oFile.WriteInteger(0); oFile.WriteArray(unused,0,13); } else // go to end of existing history file { oFile.Seek(0, SEEK_END); } long chartid = 0; if ((chartid = oChart.Open(symbol,0)) == 0) { Print("Init failed!"); return(INIT_FAILED); } hwnd = (int)oChart.GetInteger(CHART_WINDOW_HANDLE); //,0); //--- 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[]) { //--- int i,limit; limit = rates_total - prev_calculated; if(prev_calculated > 0) { limit++; } string sym = "EURUSD"; int ibarshift = 0; for(i = 0; i < limit; i++) { GetRates(sym,i); oFile.WriteStruct(rateinfo); oFile.Flush(); } PostMessageA(hwnd, WM_COMMAND, 33324, 0); return(rates_total); } //+------------------------------------------------------------------+ void OnDeinit(const int reason) { oFile.Close(); oChart.Close(); } void GetRates(string sym, int index) { rateinfo.close = iClose(sym,0,index); rateinfo.high = iHigh(sym,0,index); rateinfo.low = iLow(sym,0,index); rateinfo.open = iOpen(sym,0,index); rateinfo.spread = (int)SymbolInfoInteger(sym,SYMBOL_SPREAD); rateinfo.tick_volume = iVolume(sym,0,index); rateinfo.time = iTime(sym,0,index); }

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
So bear with me.
When I run the following code, I get an offline chart but when I open the offline chart, all I get is a "waiting for update". Anyone know why?
I know, I'm just copying EURUSD data, but like I said; I'm learning.
The sub class:
The code of the indicator:
Yes, I "borrowed" from period converter.
Target is MT4.