Where is the code?
long chartID = ChartOpen(SymbolName(0,1),PERIOD_H1);
Where is the code?
Your code is exactly the same as one of my iterations. I figure you don't need my code because I have tried so MANY variations. It is just an EA and I am trying to use ChartOpen in the OnInit() stage.
I was about to use it during the OnTick() function but that seemed a waste of time because I can get a new chart to open by creating an Indicator with a different period than the main chart.
Can we just use ChartOpen(SymbolName(0,1),PERIOD_H1) ANYPLACE we like?? Is it just supposed to work anyplace anytime?? Or is there a secret to it??? Anymore documentation I can read??? Because using it just like you put up there does NOT WORK for me.
I did look through the object oriented lib (CChart object) code and saw that in essence it is still just using ChartOpen. CChart just looks like an OOP wrapper around the old MT4 code.

- www.mql5.com
//+------------------------------------------------------------------+ //| ChartOpen.mq5 | //| Copyright 2020, Marco vd Heijden, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, Marco vd Heijden, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" long chartID = ChartOpen(SymbolName(0,1),PERIOD_H1); // this works //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- long chartID = ChartOpen(SymbolName(0,1),PERIOD_H1); // this works //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- long chartID = ChartOpen(SymbolName(0,1),PERIOD_H1); // this works (upon exit) } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- long chartID = ChartOpen(SymbolName(0,1),PERIOD_H1); // bad idea } //+------------------------------------------------------------------+I guess you can do that but i personally never use it and i wonder why you would.
I guess you can do that but i personally never use it and i wonder why you would.
I will copy your code and try it out, minus the ChartOpen in the OnTick() function. It is simple and if it works, I can work backwards from there.
Thanks!!!
I guess you can do that but i personally never use it and i wonder why you would.
Is there an issue with running it in the debugger?? I ran it from the MetaEditor and the Strategy Tester Vizualization window only had ONE Chart. It was the 5 min chart set in the Strategy Tester Settings. If it worked, it should have also have added a 1 hr chart from the global declaration and a 3 hr chart from the OnInit() function.
Did you try yours??? Did it work?? Or am I still missing something???

- www.mql5.com
ChartOpen does not work in strategy tester.
You can do lots of function calls where you pass the timeframe as a parameter so that you do not need a chart.
ChartOpen does not work in strategy tester.
You can do lots of function calls where you pass the timeframe as a parameter so that you do not need a chart.
Whaaaaaaaaaaaaaat!!!? Seriously!!!??? That is completely retarded!
I absolutely need multiple charts. I need them because I annotate them with decisions my EA is making. Each module is like a separate brain that is looking at something specific and I need it to tell me what it is doing. I need it for debugging purposes for my trades. I need to see WHY I may have made a bad trade or a good one. I am just a simple trader and I can hardly see how you can survive with less.
And just the fact that I can accidentally create another chart just by creating an instance of an Indicator with a different period tells me that an MT5 EA should be allowed to open up another chart tab. And the function works when just running as an EA attached to a chart, so it seems extremely inconsistent.
There are so many things about the architecture of MT5 platform that seems contrary to expert trading. It is almost like they want you to fail.
SMH
Yes so it's your job to make it work.
There are usually always work arounds but it takes time and effort to make these things work and the real question is if it will be worth the hassle in the end.
For example, you won't see me investing time in anything related to strategy tester, but i will draw complete charts on live feeds even in HTML and Javascript so that i can load them in a browser thereby completely escaping the chart limitations in MetaTrader itself.
There are always multiple solutions but you have to implement them yourself.
- www.mql5.com
Yes so it's your job to make it work.
There are usually always work arounds but it takes time and effort to make these things work and the real question is if it will be worth the hassle in the end.
For example, you won't see me investing time in anything related to strategy tester, but i will draw complete charts on live feeds even in HTML and Javascript so that i can load them in a browser thereby completely escaping the chart limitations in MetaTrader itself.
There are always multiple solutions but you have to implement them yourself.For now I have figured out a coding work around but circuitous route looks so stupid when one line should have worked. It is an obvious and egregious bug.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have been trying to open a chart (CChart) during the "int OnInit()" phase of my EA. It doesn't work. I tried using the old MT4, non object oriented, version of this function, ChartOpen, and still no joy. I get an error ID. I can't find any more documentation or example code on this anywhere. This should be a fundamental function for this kind of platform so I would think there should be more information on the subject.
I am a long time C++, Java, Object Oriented software engineer. I have been evaluating this platform for over a year, trying to get it to do some basic trading. I am not a noob by any means. I don't get how this platform can be taken seriously. WHAT am I missing here!!!!