Hello, I was wondering if someone could help me out with a quick EA code correction.
I need my EA to take the lowest price within the last 60 days and subtract it from the highest price within that same period. Once the difference is made, I would like the result to be multiplied by 1000 in order to get the desired range for my calculations.
For example, if the Highest price for EURUSD in the last 60 days was 1.30000, and the lowest price was 1.20000, the difference would be 0.1 (or 1000 pips). I would then multiply that 0.1 by 1000 to get my desired range of 100. (Basically for every 1000 pip trading range, I need a value of 100 for my calculations).
If the difference was 1250 pips, the value that I need would be 125.
Anyway, this is the code that I used:
For some reason, in the strategy tester, it works fine for a short period. However, on certain dates, the tester just pauses and doesn't continue trading. It just freezes without stopping; and you have to manually stop the program and change the start date to the next day in order to continue.
Is there something wrong with my code? If I take the code above out, it works fine with a constant DesiredRange. At first I thought it could be because of rounding, but it seems to round correctly.
Thanks in advance for all your help!
I need my EA to take the lowest price within the last 60 days and subtract it from the highest price within that same period. Once the difference is made, I would like the result to be multiplied by 1000 in order to get the desired range for my calculations.
For example, if the Highest price for EURUSD in the last 60 days was 1.30000, and the lowest price was 1.20000, the difference would be 0.1 (or 1000 pips). I would then multiply that 0.1 by 1000 to get my desired range of 100. (Basically for every 1000 pip trading range, I need a value of 100 for my calculations).
If the difference was 1250 pips, the value that I need would be 125.
Anyway, this is the code that I used:
Inserted Code
double highval = High[iHighest(NULL,PERIOD_D1,MODE_HIGH,60,0)]; double lowval = Low[iLowest(NULL,PERIOD_D1,MODE_LOW,60,0)]; int DesiredRange = NormalizeDouble(highval - lowval,3)*1000;
Is there something wrong with my code? If I take the code above out, it works fine with a constant DesiredRange. At first I thought it could be because of rounding, but it seems to round correctly.
Thanks in advance for all your help!