Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 207
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
Alexei! Good afternoon!
Our communication doesn't get out of my head...... and here's why.....
I heard more than once comments about absence of logic in my coding.
Yesterday you explained to me that it means Boolean algebra. This subject is very wide and very deep.
The fact is that I am not a mathematician and certainly not an algebraic one.
I understand some not so complicated mathematical things.... , but not at once and complex things my brain does not perceive at all.
Over six months ago, before I started studying the MCL programming textbook, I was wondering
whether I could understand it without mathematical ability.
But Mr. Kozlov, in the preface to his textbook, said that it's actually much simpler than it looks at first glance.
at first glance.
And indeed 60-70% of his tutorial I think I'm now able to understand (probably not the first time) and as a result I can already code something.
Until yesterday it seemed to me that all the complex mathematical calculations (which I can not understand) do the program, and I only need to know the rules by which
the program works and does the calculations.
But our conversation yesterday led me to the idea that if I do not learn Boolean algebra, my codes will be absent logic.
If my codes will lack boolean logic, my programs will not work correctly, or will not work at all.
But I glanced at Wikipedia yesterday and realized - Boolean algebra and probably logic - is not for my mind!
Yesterday you have quickly deduced from a cursory glance at a fragment of my code that it lacks Boolean logic.
If you don't mind, could you please explain a course of your reasoning, which preceded your conclusion about absence of logic in this fragment.
If I understand it, I will move on. If I don't understand it..... I will probably conclude that programming is something that greatly exceeds my abilities.
Thank you.
if (ot==0)
if (Bid==Price)
if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))
Andrei, it's not all that tragic! Just use what you understand! Everything else will come in time!
For example, after having checked closing by stop using Kim's function, you must introduce an additional variable Lots and before opening a new position with a doubled lot you must write the following line: Lots = Lot*2.0 and that's all! And you put a normal Lot, where you don't need doubling!
Why do you need complex codes for simple things? For the sake of science, so that no one could understand them? A sort of protection against "plagiarism"!
Andrei, it's not all that tragic! Just use what you understand! Everything else will come in due time!
For example, having checked closing by stop, you must introduce an additional variable Lots, and before opening a new position with a doubled lot, you must write the following line: Lots = Lot*2.0 and that's all! And you put a normal Lot, where you don't need doubling!
Why do you need complex codes for simple things? For the sake of science, so that no one could understand them? A kind of protection against "plagiarism"!
Boris! Thanks for the encouragement. You've calmed me down a bit....
But still I`m suffering from repeated remarks on the lack of logic in my codes.
And what pisses me off most of all is that I can't understand what exactly I'm talking about.
It seems to me that absence of Boolean logic in code is important.
But how do I know if it exists or not?
Alexey told me that I may have problems because of this fragment (although the tester is OK).
if (ot==0)
if (Bid==Price)if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))
In case of a coding error, everything is clear - either MetaEditor will tell me or Terminal Log.
And if I'm missing logic ....... how can I know about it? Only with a hint from more experienced fellows.
But even after their prompting I don't understand what exactly it is about.
Studying Boolean algebra is unreal for me.
Forget about that Boolean algebra and don't bring it up again.
An anecdote:
A psychiatrist professor visited a hospital for the mentally ill and asked the head doctor how they determine whether a patient has recovered or is still ill.
- We fill the bathtub with water, put a tea cup with a spoon on the edge and offer the patient to remove the water.
- We have to assume that if the patient is well, he takes the cup and not the spoon?
- If the patient is healthy, he pulls the plug in the tub.
* * *
You should be able to answer your own question as to whether the actions you are trying to do in code are reasonable, and it's not such a difficult question.
Open[1]-Close[1] can be negative. So for the case of Close>Open there is one option, for the case of Close<Open there is another option. Or you should calculate the body size so that it does not depend on the candle's direction.
Boris! Thank you for your support. You've calmed me down a bit....
But still I've been repeatedly told that there's no logic in my codes.
And what pisses me off the most is that I can't understand what exactly I'm talking about.
It seems to me that absence of Boolean logic in code is important.
But how can I know if there is one or not?
Alexey told me that it is absent in this fragment and that I may have problems because of this fragment (although the tester is OK).
if (ot==0)
if (Bid==Price)if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))
In case of an error in coding everything is clear - either MetaEditor will tell me or Terminal Log.
But if I'm missing logic ......., how can I know about it? Only with a hint from more experienced colleagues.
But even after their prompting I don't understand what I am talking about.
To learn Boolean algebra is unreal for me.
"First, I'll make your code readable, remove unnecessary brackets and conditions, and then you can tell me why you need those conditions!
"First I'll make your code readable, remove unnecessary brackets and unnecessary conditions, and then you tell me why you need those conditions!
I'm telling you why I need these unnecessary conditions.
I need the conditions that you sent to the furnace, so the program calculates the specific parameters of the candle with a gap of 1 point.
I.e. a bearish candlestick with a specific size of its body, with a specific size between the open and low prices, with the specific size of the distance between low and close prices.
I understand that for this purpose, if I'm not mistaken, you can also use NormalizeDouble (MathAbs ()), but I haven't noticed a difference between this version and the one I used.
I'm telling you what I need those extra conditions for.
The conditions that you sent me to the furnace, I need the program to calculate the specific parameters of the candle +, - 1 point.
I.e. a bearish candlestick with a specific size of its body, with a specific size between the open and low prices, with the specific size of the distance between the low and the close price.
I understand that for this purpose, if I'm not mistaken, you can also use NormalizeDouble (MathAbs ()), but I haven't noticed a difference between this version and the one I used.
Forget about that Boolean algebra and don't bring it up again.
An anecdote:
A psychiatrist visited a hospital for the mentally ill and asked the head doctor how they determine whether a patient has recovered or is still ill.
- We fill the bathtub with water, put a tea cup with a spoon on the edge and offer the patient to remove the water.
- We have to assume that if the patient is well, he takes the cup and not the spoon?
- If the patient is healthy, he pulls the cork in the tub.
* * *
You should be able to answer your own question as to whether the actions you are trying to do in code are reasonable, and it's not such a difficult question.
Open[1]-Close[1] can be negative. So for the case of Close>Open there is one option, for the case of Close<Open there is another option. Or you should calculate the body size so that it does not depend on direction of candle.
Thanks for the anecdote.....from now on I will try to think only of the plug.
But all the same ... when reputable people from this branch repeatedly and simultaneously say about absence of logic in my code.... as it turns out later Boolean algebra - it means to spit on authority of serious professionals from this branch..... I will not immediately rise to it.... and may not rise at all..... I have not tried yet.
Then see above, corrected!
So I had a lot of extra parentheses? Are they harmful?!
Well, if the compiler didn't give me an error when I entered these brackets .... I thought everything was OK.
I thought until recently that if the compiler did not complain and the EA worked in the Strategy Tester in accordance with its code, then it was OK.
Looks like it's not quite so.....
Boris! Thank you for your support. You've calmed me down a bit....
But still I've been repeatedly told that there's no logic in my codes.
And what pisses me off the most is that I can't understand what exactly I'm talking about.
It seems to me that absence of Boolean logic in code is important.
But how can I know if there is one or not?
Alexey told me that it is absent in this fragment and that I may have problems because of this fragment (although the tester is OK).
if (ot==0)
if (Bid==Price)if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))
In case of an error in coding everything is clear - either MetaEditor will tell me or Terminal Log.
But if I'm missing logic ......., how can I know about it? Only with a hint from more experienced colleagues.
But even after their prompting I don't understand what I am talking about.
Studying Boolean algebra is unreal for me.
You don't have to be an expert in Boolean algebra to state the terms clearly...
Let me make things a little easier for you... Replace if with the usual if, else with otherwise, && with and, || with or , etc... Then you will be able to read in your own normal words what is written or decide what you want to write.
What you have written (let's skip the incorrect description of conditions for now):
1. if (ot==0) If there are no market orders (neither market orders at all, nor pending ones, nor open by this EA, another EA or manually)... If yes, then line 2 is executed, if no, then we go to line 3.
2. if (Bid==Price) If the price is equal to the opening price of the current candle... If it is, then line 3 is executed, if not, then we go to line 4.
3. if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point)) If the open price of the first candle is higher than the close price of the first candle by more than 100 points and less than 120 points... If it is, go to line 4, if not, go to line 5.
4. if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point)) If the high of the first candle is higher than the open price of the first candle by more than 40 points and less than 60 points... If it is, then we execute line 5, if not, we go to line 6.
5. if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point)) If the close of the first candle is higher than the low of the first candle by more than 40 points and less than 60 points. If it is, then line 6 is executed, if not, go to line 7.
6.
7.
As you can see from this decomposition, you either have all lines of code executed one after another (in case each line returns true), or you skip the line that comes after the line that returns false.
To avoid confusion in your terms, and to correctly compose your logic, enclose all statements in curly braces, regardless of whether a single line should be executed after the truth value, or an entire block.
For example:
So, try to decompose your code into components, removing extra brackets, which are unnecessary in this case...Then see above, corrected!