[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 27
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
OK, let's try another way of looking at it.
vteor12 can be written as (dVolume+vback1)/k1 (factor 1)
vrealUP12 can be written as (dVolume+vback1)/k2 (coefficient 2)
As I tried to describe the indicator ideology, it consists in comparison of some theoretical and actual levels. To obtain these levels I compare (i.e. divide) the same value (dVolume+vback1) with some theoretical value (k1) and actual value (k2). It's clear that k1 I'm just making it up, to put things in their proper names. Or, if you like, making an assumption. Now this has to be compared to something. Nothing is more objective and true than the graph itself in this case. So I take the opening and closing differences, taking them as the bottom line of a given time period. And the only task here is to bring it to the same digit, which is why it is multiplied by 1000.
Try to calculate several different variants of neighbour candlesticks on a calculator and you may be surprised by the variety of results according to this very simple formula.
And in terms of school logic you are right. I add Volume + Volume/Price, you can't do that at school. :))
I'll pass... :)))
Didn't you initially have a problem with the display? Did you solve it?
I'll pass... :)))
Didn't you initially have some problem with the display? Did you solve it?
Yes, I did, by the way. I didn't take into account that it was a line, not a histogram. The line should have 2 points. Since the code does not describe all variants, but only 2 candles rising in a row, in the case when after the second rising candle was a down candle, the indicator did not draw anything. And it was right. When I figured it out, I modified it to a histogram.
By the way, do not take my reasoning about the rules of addition and subtraction to heart. :)))
And I would be very grateful if you could help me to continue the code. It was the very beginning. After two candlesticks in a row I would like to count 3, 4 etc. candlesticks in a row by the same principle. Apparently, the code should be looped, with the search of candlesticks, right? I can't do it yet. But don't get hung up on what is divided by what. :)))
Ported from
Hello. I finally wrote my first EA! I do not quite understand how it works. The EA sets 2 pending orders when certain conditions are met. Stop loss for both orders is equal to High[1] (Low[1]) for the pending sell(buy) order and take profit is always equal to pips for the stop loss. I have noticed in the strategy tester that the profit does not always equal the stop loss in pips. Please advise how this can happen. This is the code where stop orders are calculated (there is no other place in the program where stops are changed)
Hi, could you please tell me, is it possible to assign values to multiple global variables within a function, and where do these variables need to be declared in that case?
You can.
Declare variables globally - before the start() function. Inside the EA functions, change their values as you want - after returning from the function, these variables will have the values you assigned them inside your functions until you change them again somewhere.
good afternoon! could you please tell me if it's possible to assign a value to multiple global variables within a function, and where do these variables need to be declared in that case?
Example. Inside the myfunction, we assign a value to two global variables. You can also assign a value to three, four or n variables in this way.
But I think there's a catch in your question...
Yes, by the way, I have sorted it out myself. I didn't take into account that it's a line, not a histogram. And the line requires 2 points. Since the code does not describe all variants, but only 2 candles rising in a row, in the case when after the second rising candle was a down candle, the indicator did not draw anything. And it was right. When I figured it out, I converted it to a histogram.
You, by the way, don't take my reasoning about the rules of addition and subtraction to heart, think of it as an experiment. :)))
And I would be very grateful if you could help me to continue the code. It was the very beginning. After two candlesticks in a row I would like to count 3, 4 etc. candlesticks in a row by the same principle. Apparently, the code should be looped, with the search of candlesticks, right? I can't do it yet. But don't get hung up on what is divided by what. :)))
Yes. But the best way to solve this problem is to use a loop with post precondition "while" instead of a loop with counter "for". Because you do not know how many bullish or bearish candlesticks you will encounter in a row.
Start with a simpler problem, if you find it so difficult. For example, display the numbers from a to b in increments of s. Or find the factorial of n with a loop.
And to practice, solve these problems using both types of loops ("for" and "while"). Then you can start to improve your indicator.
There are no post-while loops in the language, MaxZ.
Your desire to help others is commendable, but you still need to know the language better yourself.
There are no post-while loops in the language.
If you organise the loop as follows, you will get just the right postcondition:
But I accept your correction. Thank you. Since there are indeed two loop types in MQL4: "for" (with a counter) and "while" (with a precondition). The third type (with a postcondition) can be organized only intentionally.
Your desire to help others is commendable, but you still need to know the language better yourself.
What I don't know, I do not go there.
And all the other mistakes were made inadvertently. I've been distracted lately... I just want to help people.
MaxZ: Единственная проблема состоит в том, что если советник с данным кодом запустить в тестере, а переменной PERIOD присвоить значение PERIOD_M1, то обе функции iBarShift возвращают -1, т.е. функции не удалось найти в истории бар на ТФ M1 с таким временем... Почему так происходит, не знаю.
Most likely, this function is not modelled in the tester (didn't check). Especially as exact (the fourth function parameter) is set to false by default.