[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 661

 
artmedia70:

It's not working yet... and exactly AC

catch in the log, maybe recalculation is incorrect and the condition will never work, such as AC1 = 0 and AC2 = 0 and there will never be 0 > 0

print(AC1,AC2) ;
if (BB>0 && OsMA>0 && AC1>AC2) return(1);

 
IgorM:

catch in the log, maybe the recalculation is wrong and the condition will never be fulfilled, like AC1 = 0 and AC2 = 0 and never 0 > 0

print(AC1,AC2) ;
if (BB>0 && OsMA>0 && AC1>AC2) return(1);

below:

else return(0);

 

Thank you, Igor. I think that's where the dog is buried... :)

I have Comment() output the same AC1 and AC2 = 0.01, although in the data window they have AC1=0.001008, AC2=0.001020.
How do I increase the digit capacity? Well, other than a trivial multiplication by 1000, or just like that?

 
IgorM:

Yeah, so I'm gonna try while - that's until the first spike and then ........ - I can't figure it out.


Done. Here is the result of its work.

The code is not too complicated, so you should have no trouble rearranging it to suit your needs.

The script is attached to the post.

Files:
0.mq4  4 kb
 

Is such an entry correct:

double AC1=NormalizeDouble(iAC(sy,tf,1),8);
 
artmedia70:

So far it's not working... and it's the AC.

The only way out is to find out exactly what values are in the variables - this will show us why the programmed condition does not work.

If rounding is automatic up to 0.01, then most likely the test passes on an instrument like UsdJpy. Then there is an option to work through string variables (if you really need such a distant decimal place)

 
drknn:
The only way out is to find out exactly what values are in the variables - this will show us why the programmed condition does not work.
Thank you Vladimir, I've found the reason. The question above two posts...
 
drknn:


Done. Here is the result of his work.


Thanks, it's OK - it works, I just couldn't figure out how to enter the trend flag - I thought it was like sorting an array
 
artmedia70:

Is such an entry correct:


Correct, because the first parameter returns a number and the second parameter is an integer value within acceptable limits. The whole question is what exactly will go into the variable. Try to print as is and try this construction:

double AC1=NormalizeDouble(iAC(sy,tf,1),8);
string str=AC1;
Print("str = ",str);
 
IgorM:

Thanks, it's OK - it works, I just couldn't figure out how to enter the trend flag - I thought I needed to sort the array


The trouble with working with arrays is, when the function of array enumeration encounters a value given to it, it returns the number of the cell containing this value. And the fact that this value can be found in other cells of the array is exactly the tricky part. So we have to keep iterating, keep going through the values until we have gone through the whole array. And as soon as we come across the right value, we put the cell index into a previously created array, or we stitch the rows together.

The complexity of your problem is that you have to look for peaks/troughs. In order to find it, you need to skip past the extremum and only then will the code realise that it has actually skipped it. That's why we have to go back a step to remember the point of extremum and the cell it lies in.

Reason: