Previous Bars Calculation - page 2

 
qjol:

Q: if it's equal 0.14411 then what


OK, I'll try out the doubles to see if it will work. However, if you subtract the lowest value from the highest value and get 0.14411, you are supposed to multiply it by 1000 to get 144.11.


In the third line I used the MathCeil() function which will always round the number to the higher digit. So, it will turn into 145. Is this a correct assumption?


EDIT: Actually I do think I'm doing something wrong with that because it keeps on pausing and not making any trades at certain times. It's probably because there is a decimal somewhere. How do you suggest I better round it?

THANKS for all your help!

 

144 is not good, if yes

int DesiredRange = NormalizeDouble(highval - lowval,5)*1000;

should be fine

 
qjol:

144 is not good, if yes

should be fine


Thanks for the quick response. However, when I tried it, it still pauses at certain parts and doesn't make any trades. I'm assuming it's because of rounding as you suggested as a problem earlier. Is there a way to round to a whole number? When I tried MathCeil() it didn't seem to work correctly.


Thanks again

 

OK, this is how I entered the code for rounding; and it seems to compile with no errors. However, it still pauses when it trades sometimes. Should I enter the MathCeil differently? (I'm assuming I need to round for the trades to work properly).


Thanks!


double highval = High[iHighest(NULL,PERIOD_D1,MODE_HIGH,60,0)];

 
double lowval = Low[iLowest(NULL,PERIOD_D1,MODE_LOW,60,0)];


int DesiredRange = MathCeil(NormalizeDouble(highval - lowval,5)*1000);
 

Since I couldn't get MathCeil to work correctly, I just decided to use the NormalizeDouble; but instead going to the 5th decimal place, I made it go to the 3rd. If I only make it go to the 3rd, and NormalDouble rounds it there, when I multiply by 1000 it should be rounded already........right?


Thanks in advance for your help!


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;
 

Actually, I've been doing a lot of testing; and I don't think that rounding is a problem in this program. I've used functions that would solve rounding, but it would still pause at certain times. I can simply stop the tester, change the date to the day after the pause occurred, and then start the tester again. It will continue to trade for a while, but then eventually run into the same problem.


If I keep the DesiredRange constant, the EA will continue to work without a problem. However, during larger trading ranges, the DesiredRange should increase for optimal results. Does anyone have an idea on why the strategy tester pauses? I just want to make sure I'm not doing something wrong before I change the "DesiredRange" manually.


Thanks

Reason: