Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1800
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
What is the DecreaseFactor in the standard MT advisor on mashcats?
It's strange, the buttons are there now. And the code clutter, because it's a draft. Anyway, I've already made a working version, the last thing left is to delete the buttons, here again this shit started: the delete function doesn't find any of the 4 objects.
Clicking on the button creates all the lines:
If the button is pushed - delete:
What a load of crap is written, I'm sorry to say.
And you don't need to watch the events. They don't work at all in the tester. You have to watch the status.
UPD. Not modest of course, but if you had listened to my hints for once, you would have done everything long ago. Properly and without the crutches of a multi-storey.
But everyone chooses the abyss they want to plunge into.
To use the debug in the tester, learn to write in MQL5. Everything works there.
There's no such thing as renaming an object. Think of it as replacing an existing object with a new one.
This cannot be. Your code looks like a mess of things. That's probably why you are experiencing lags with the buttons. Like I told you before, start with something simple. Don't overcomplicate things. And gradually complicate it when the simple starts to work and you're confident in it.
And how do I see the states if they are triggered by event (by click)? Yes, but I'm writing in mql4, it's the same as saying "learn to write in c# where debug works".
"Correct and without multi-storey crutches. "So hiding objects is just crutches.
All in all I've done, everything works https://gist.github.com/satorkain/0cf7a8df8ec1f4b3191defd04c94a418
By clicking on button all lines are created at once, then they are hidden and only one is left depending on button panel location. Further lines are hidden/shown depending on the location of the cursor relative to the price.
P.S.
If it wasn't for crooked mql4 I wouldn't have had to come up with this nonsense about hiding objects, everything should have worked the first time with deleting/renaming objects.
And how do I see states if they are triggered by event (by click)? Yes but I write in mql4, it's the same as saying "learn to write in c# where debug works".
"Correct and without multi-storey crutches. " So hiding objects is just crutches.
All in all I've done, everything works https://gist.github.com/satorkain/0cf7a8df8ec1f4b3191defd04c94a418
By clicking on button all lines are created at once, then they are hidden and only one remains depending on button panel location. Further lines are hidden/shown depending on the location of the cursor relative to the price.
P.S.
If it wasn't for the crooked mql4, I wouldn't have had to come up with this nonsense about hiding objects, everything should have worked the first time with deleting/renaming objects as well.
Hiding an object is just the method recommended by the developer. And there is a special property for it. To see the state, you need to look at the "State" property of the button.
What's crooked here is your logic and substitution of notions - you take developer's recommended means as a crutch, and you take constant voracious object creation/deletion as pure code, but that's exactly what's a crutch, bypassing recommended fast method.
By the way, to quickly make an object on top of all the others, you have to make it invisible, and immediately visible - this will override its position in the object list, and it will be at the top.
ZS. And even there, on the git, you published the code with a C-minus. Totally error-prone. Once one line is not created, your whole thing collapses. That was immediately apparent. You create lines in the event handler - what for? What do you need OnInit() for? You created it, checked its success, set a flag and hide it. In OnDeinit() you have deleted objects created by your program. You also need the name prefix for this.
You only show and hide in the event handler - there should be no building. For your case - exactly.
I would be ashamed to publish such thing in public domain on git. But that's for me.
What about you? Is it okay for people to take advantage of it?
Hiding an object is exactly the developer's recommended method. And there is a special property for it. To see the state, you need to look at the "State" property of the button.
What's crooked here is your logic and substitution of notions - you take developer's recommended means as a crutch, and you take constant voracious object creation/deletion as pure code, but that's exactly what's a crutch to bypass the recommended quick method.
By the way, to quickly make an object on top of all the others, you have to make it invisible, and immediately visible - this will redefine its position in the object list, and it will be at the top.
ZS. And even there, on the git, you published the code with a C-minus. Totally error-prone. Once one line is not created, your whole thing collapses. That was immediately apparent. You create lines in the event handler - what for? What do you need OnInit() for? You create it, check its success, set a flag and hide it. In OnDeinit() you have deleted objects created by your program. You also need the name prefix for this.
You only show and hide in the event handler - there should be no building. For your case - exactly.
I would be ashamed to publish such thing in public domain on git. But that's for me.
What about you? Is it okay for people to take advantage of it?
Voracious to create 1 line of 4 as needed? :) What if there are 200 lines? Will it be economical to create them all at once according to your logic? And how it was conceived by the developers is known only to them, and conceived in a very non-intuitive way. As if nothing incredible or illogical was required. How could I have known that I should work with objects only in this way and not any other way? Maybe from a textbook on mql4? I doubt that this point is explained there.
At least, it works as it was intended :) It's in brackets in the title (public), so it's not complete yet, but yes, there is no check to create objects, let's fix it. And I posted it on git only because I couldn't remember paste bin. Ashamed? The Git was created for people to learn, exchange experiences, share code, working or not, makes no difference, anyone can make a fork and make changes if they are not happy with something.
Here you are, 250 objects have been created and stored in memory for the duration of the Expert Advisor. All right, well, thank you, I'll know. This is what I mean by "non-intuitive logic". For example, in the tutorial about OnInit(), you can read only that the function is processed during initialization of the Expert Advisor/indicator.
Let me tell you a secret. You can create as many as 1,000 objects or more, as long as you don't have a 'calculator'. But it can do it too. A calculator is a computer with 4GB RAM. Anything below that is "grandma's calculator"... :) So you can create objects all at once or one at a time. It makes no difference. But without fanaticism.
That way, everything works for everyone if you do it wisely!...
Voraciousness to create 1 line of 4 as needed? :) What if there are 200 lines? Would it be economical to create them all at once according to your logic? And how it was conceived by the developers is known only to them, and conceived in a very non-intuitive way. As if nothing incredible or illogical was required. How could I have known that I should work with objects only in this way and not any other way? Maybe from a textbook on mql4? I doubt that this point is explained there.
At least, it works as it was intended :) It's in brackets in the title (public), so it's not complete yet, but yes, there is no check to create objects, let's fix it. And I posted it on git only because I couldn't remember paste bin. Ashamed? The Git was created for people to learn, exchange experiences, share code, working or not, makes no difference, anyone can make a fork and make changes if they are not happy with something.
Here you are, 250 objects have been created and stored in memory for the duration of the Expert Advisor. All right, well, thank you, I'll know. This is what I mean by "non-intuitive logic". You can read in the tutorial, for example, about OnInit(), that the function is processed during initialization of an EA/indicator.
You can create as many objects as you need at the same time. At the time MT was not very developed in terms of drawing of indicator buffers, we had to draw 400 visible candlesticks with trend lines, for one candlestick we need 5 lines, 400*5=2000, plus one object for each one and so on. Altogether we got about 2500 objects. It worked without any dullness.
You do not quite understand the logic of working with objects, but you know how to argue. It's better to do the opposite.
Voraciousness to create 1 line of 4 as needed? :) What if there are 200 lines? Would it be economical to create them all at once according to your logic? And how it was conceived by the developers is known only to them, and conceived in a very non-intuitive way. As if nothing incredible or illogical was required. How could I have known that I should work with objects only in this way and not any other way? Maybe from a textbook on mql4? I doubt that this point is explained there.
At least, it works as it was intended :) It's in brackets in the title (public), so it's not complete yet, but yes, there is no check to create objects, let's fix it. And I posted it on git only because I couldn't remember paste bin. Ashamed? The Git was created for people to learn, exchange experiences, share code, working or not, makes no difference, anyone can make a fork and make changes if they are not happy with something.
Here you are, 250 objects have been created and stored in memory for the duration of the Expert Advisor. All right, well, thank you, I'll know. This is what I mean by "non-intuitive logic". For example, in the tutorial about OnInit(), you can read only that function is processed during initialization of the Expert Advisor/indicator.
Welcome. I will try to explain it in simple Russian.
You are going on a fishing trip.
Or you can take everything you need from the pantry (OnInit) straight away, fish without running around and, when you get home, put everything in the pantry and the fridge (OnDeinit).
You may have known about it here on the forum. You just need to listen and hear what you are told sometimes.
Otherwise you get a question, get an answer, say "bullshit" and do as you think.
You must first think over the question, ask questions, and then start editing.
Are you aware that the simplest thing in programming is printing code? And the lion's share of development is thinking about the logic.
I'm sorry to bring this up a second time.
But there is a problem that I cannot solve yet, namely
opening a series of orders (one after the other) on the same candlestick.
I need to prevent the EA from opening a new order on the same candlestick.
I thought about solving it using Sleep(), but Makar said it would be better not to stop the process.
The code now looks like this:
I need the EA not to be able to open a new order on the same candle.