self updating/refreshing grid, compare two groups of trades
-
My last posting was placed in the beginning of the thread. I don't know why. Is it not allowed to edit or delete postings any more?
I hope this time it will be placed at the end of this thread. My question was:
It seems there is a problem with a block. After compiling my EA "Grid-EA SF full-auto v2.4" there are some errors. Could you look over please.
-
I don't know why the post is placed at the beginning, this forum is a mystery for me, but it works fine most of the time

The problem is in block 1728, something with Constants. Similar problem happened before few times and I fixed them... now I don't know what is the problem exactly, I need to investigate. But some Constant named "manual_trade_mode_01" appears in the MQL4 and such Constant doesn't exist in the list.
I downloaded copy of the project for investigation, but if you want to fix the problem quickly, just replace that block.
-
Hi,
back again...my last attempt to add a link of an example for someone was not working. Could you please explain how to do that now, after the update? Or where to find instructions?
-
You want to say that you can't produce shared copy of the project? I can see people showing such links around, but maybe there is something specific in your project that doesn't work well. Can you do that with another project?
-
I have created an example for an answere to someones question. I have klicked the link symbol and pasted the shared link.
now I have pasted the whole url after double klicked the created link. Maybe that is working. Ah... the preview on the right is nice...
-
I would like to close position after profit is dropping below 90 percent of its highest profit.
Or in other words: I want to close position after position looses 10 percent of its highest profit.How to do that? Is there a block?
-
Hello fxdreema,
are you there? I wasn't active in this forum for a while. Is this thread still active?
If so, I would like to know how to round a variables value after 2 digits?
The problem is, after a substraction of two double variables (i. g. 0.06 - 0.03) there is sometimes a result like 0.02999999999991 but I need the value 0.03.
How to solve that problem? -
use NormalizeDouble function in custom code block ...
NormalizeDouble(0.06-0.03,2) ... -
Thanks miro1360.
The values are stored in variables. The following seems not to work: NormalizeDouble(net_lot_size,2); -
save it into your variable:
variable1 = NormalizeDouble(net_lot_size,2);
-
Thanks, that was working but sometimes not... I have to observe that issue...
I have an another question regarding the colour of the draw object block. How to set the colour of a line as a constant to change it from the properties. Replacing the value by a string constant "Yellow" was not working. How to do that?
-
it is not string, but color, as this:
color yourColor = clrGreenwhere color is type
your color is name
and clrGreen is value -
All colors are available here: https://www.mql5.com/en/docs/constants/objectconstants/webcolors When you need them again, just search for "Web Colors" in the documentation.
All color constants start with "clr", but in MQL4 you should be able to use only color names, for example Yellow instead of clrYellow. Initially "clr" didn't existed in MQL4, but they used it in MQL5, so then they also added "clr" in MQL4.
-
Thanks. The colour issue is solved.
But the NormalizeDouble(net_lot_size,2) issue is still a confusing thing.
I try to explain it in more details:
I am trying to visualize the current lot size and the net lot size like iexposure is doing. I am using the "for each trade" block an the "variables" block for calculations. I have replaced everywhere where the variables are appeareing the variables by theNormalizeDouble(variable,2) funktion. For instance the expression V3+V1 was replaced by NormalizeDouble(sum_buy_lot,2)+NormalizeDouble(buy_lot,2). But sometimes there are still values shown like 0.059999999999 or 0.070000000001 but I need just something like 0.06 or 0.07.Any suggestions to normalize or remove that "anomaly"?
-
Unfortunately this is not anomaly. Floating numbers work like that in those C languages. I don't understand why, I only know that it's normal. And that's why NormaliseDouble() exists - to normalize those weird numbers. But I also noticed that sometimes this function doesn't work, and I don't know what would work. Well, If I remove "#property strict", those weird numbers will appear like normal numbers, but I think that in general working in strict mode is better. Although the strict mode in MQL4 is crazy - if you remove it now, you will see fatal error. We are supposed to see more errors in strict mode, not in normal mode, but MQL4 is always a little bit broken.
-
I don't know what "#property strict", normal and strict mode is. Could you explain please or refer to further info. As I understand you, that issue is not "curable" but about iexposure, it is providing lot-size and net-lot-size without any problems...
Is mt5 working better? Is hedging possible on mt5 (in the beginning of mt5 it was not possible).
-
Strict mode is when you set the programming language to be more strict on the rules => it allows less freedom and shows more errors. So, in strict mode more errors are expected. As a result the code should be better. But in MQL4 for some reason it shows more errors in non-strict mode, which is strange for me
I basically set this property only because I think that strict mode is good in general, but I'm confused by the actual results.What can I say... maybe I will just remove that strict mode again. Every time I enable it, people start reporting those long numbers. Unfortunately sometimes even I don't know how to fix them. But in normal mode it's not that those numbers are not long, they only appear short when you print them, but in reality they are still long and inaccurate.
-
Thanks for the above.
A new question:
usually the constants are shown in the tab "input" of EAs properties but is it possible to show some constants in an another tab for instance "colours and lines"?Is it possible to make a pulldown menue with predefined values similar to a bool constant where I can choose between true and false?
-
Those Constants are actually global variables for which the "input" keyword is used. I only know that they go in "Inputs" tab, I am not aware of any possibility to create new tabs somehow.
Pulldown menus are possible, but only those from the built-in types. If you set the data type to ENUM_TIMEFRAMES for example, it will show all timeframes. Or you can use any other ENUM... type... Of course the problem is that those are part of MQL and you must know how to find them and what they mean

-
the enum... type is working fine, thanks.
But what about the Tab or folder in EAs properties? What it can be seen is that Indicators have tabs like "input", "levels", "lines", "colours"... . Isn't that possible on EAs?