How to use constant/bool with chart value
-
Good morning everyone, let me start by saying that I am trying to create a multipair EA, writing the name of the chart to be used in each constant and then using the "set current market for the next block" block, everything works fine. Here on the forum I found a lot of information that explains the possibility of adding a bool constant with True/false value that can be used in a condition block to enable or disable the possibility of enabling or not a chain such as opening a trade, or using of an indicator..
My question is: what if instead in the EA constant I wanted to insert the name of the chart as a value and next to have the possibility of making True/False? That is, to open that graph or not?
Example of input into the EA: AUDCAD | True / False
I haven't found any way, because if you use the constant bool in "value" you can only enter true or false..
-
i have done it once, if you want to make 3 pairs , then you have to repeat whole process block 3 times with its own variable each pair
-
@Byens How should I do it?
-
it is like 3 ea in 1 , put "set current market for the next block" before each
-
@Crisfx You will need custom code to do that.
-
@l-andorrà Unfortunately I imagined it, I'll leave the topic open so if anyone knows how to proceed they can write it, it would be helpful..
-
It looks like this code does it, put under your bool condition using a MQL custom block: ChartOpen(NULL, your constant name, PERIOD_M15);
-
@jstap Thanks for your comment, unfortunately I don't intend to open a chart, but to have the possibility of using a bool with the name of a chart and near the true/false to enable or disable the opening of a buy or a sell for that chart .
Input EA example:
Variable: ----- Value
AUDCAD ------ True/False
EURGBP --------- True/falseThe idea is like the one I attach in the photo, that is, if true the chain works and opens buy/sell, if false it doesn't work. The problem is that I can't do it using the name of a currency pair since using a bool in "value" must necessarily put true or false.

-
You have said exactly how to do that in your post (unless I misunderstand), a bool constant for 1 particular asset, string constant with symbol name, and blocks under the condition to complete the required actions. Let me know if I misunderstood, also I would use buttons/edit fields to achieve.
-
@jstap Yes, I have a bool constant called "EnableChart1", a string constant with the name of the chart called "Chart1" and below I inserted the custom code you sent me, unfortunately it returns the error: "ChartOpen - Wrong parameters count".

-
My bad there is only 2 parameters, remove NULL,
-
@jstap Perfect, now it works, I imagine that instead of PERIOD_M15 I have to insert the reference timeframe on which my Expert works, right?
Would it be possible to combine the 2 constants (the bool and the string with the chart name) to create a single one? Use the constant string with the chart name and the true/false from the bool constant. So you only have 1 input line into the EA settings once it is attached to the chart, this would be perfect...
EA input example:
"Chart Name" | True/False
-
Change PERIOD_ and the chart will open on whatever TF you want. You can't put it into 1, unless you use enum and quite a few variables, is a lot of work though
-
@jstap Thank you very much!