[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 410
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
no
The problem here is simply in the loop. It goes through i from 0 to 2. You want 2 to 0.
Show me an example please, I did Didn't work.
sss2019:
Show me an example please, I did It didn't work
I made the script like this
As a result, Print outputs the following
0 4
1 4
That's all, for some reason the loop does not print
2 4
3 4
I have added to the loop OrderSelect(i, SELECT_BY_POS, MODE_TRADES instead of I 0, i.e. the first order is always selected and the script works correctly. It turns out that when the loop deletes two orders, it tries to select the third order when there are only two orders in the list.
Made the script like this
In the end...
Please show me an example, I did
Didn't help.
because you still have to think.
Help me solve this dilemma
The script searches for the maximal distance between the lines. It outputs all values on all bars, the maxrange is 1.6235 on one bar and 1.6208 on the other one.
I try to print Print(maxrange); it prints 0.086, I don't understand why, I am dividing by Point
Help me solve this dilemma
The script searches for the maximal distance between the lines. It outputs all values on all bars, the maxrange is 1.6235 on one bar and 1.6208 on the other one.
I try to output Print(maxrange); it returns 0.086, I don't understand why at all, I'm dividing by Point
This is not a dilemma. A dilemma is when you don't know which of two solutions is best.
Well, first, the iMA() function has seven parameters, not six. Second, you have declared a variable by the int i string. And further on, the i variable is not initialized anywhere with a value. As a result, it is either zero or contains memory junk left over from the previous activity. And third, the while loop is arranged incorrectly. Well, let's say the i variable is equal to zero after initialization. Let's also assume that the Ma1 > Ma2 expression is also true. As a result, the while(Ma1 > Ma2) line will start the loop. At the next loop iteration we will find out that the (Ma1 > Ma2) expression is no longer true and the loop will be terminated. The variables Ma1 and Ma2 will not contain the distance that is maximal - the maximal distance was once. This condition will only show that Ma1 has now become less than or equal to Ma2.
Further, the maxrange variable will be initialized with a value only in the string range = (Ma1 - Ma2)/Point; Well, what if the condition if(range > maxrange) will never occur, because you don't initialize the maxrange variable with a value anywhere else in the code? So it turns out that you are comparing the result of calculations with memory cells' junk. Here you have incomprehensible prints as a result of code execution.
if(range > maxrange) maxrange = range;
That's the point, I was outputting all MA values in the loop and all values are correct, i.e. all MA values for this period were searched. But calculation is wrong in this place - range = (Ma1 - Ma2)/Point;
if(range > maxrange) maxrange = range;
*Point
range = (Ma1 - Ma2)*Point
*Point
range = (Ma1 - Ma2)*Point