Trying to set a Golden Range within which a Trade is allowed

 

Hi,

This is my first post and Im guessing this is a very easy fix! I have been struggling with it for a while and was hoping someone could give me a little help.

I am building a very simple EA, I set a golden range as an extern double (ie GoldenTop = 1.31000 and GoldenBottom = 1.30000) where I believe there will be a retracement and then trigger the trade using an MA cross within that range. The problem I am having is in setting the range at the outset and using the function NormaliseDouble. The relevant code I am trying to use is

extern double GoldenTop = 0;

extern double GoldenBottom = 0; // this gets changed in the morning when I work out the golden period based on price action


double GTop = NormalizeDouble (GoldenTop, 6);
double GBottom = NormalizeDouble (GoldenBottom, 6);


Then the trigger. For some reason there is no trade. The MA cross works fine independently so I think it is something in this part of the code.

Any help really very much appreciated!

 
Bogze:

Then the trigger. For some reason there is no trade. The MA cross works fine independently so I think it is something in this part of the code.

Any help really very much appreciated!


You don't need the NormalizeDouble . . . the error isn't there.

You need to post some more code . .

 

Bogze:

double GTop = NormalizeDouble (GoldenTop, 6);

double GBottom = NormalizeDouble (GoldenBottom, 6);

I'm surprised by the "6". 5 digit brokers are common, but 6? You could use Digits rather than a fixed number to make it work on 4 or 5 digit brokers.
 
dabbler:
I'm surprised by the "6". 5 digit brokers are common, but 6? You could use Digits rather than a fixed number to make it work on 4 or 5 digit brokers.
It doesn't make any real difference - because normalizing to 6DP rather than 5DP should be irrelevant - but someone once cited an MT4 broker offering US Treasury Notes. If that broker were to offer the 2-year notes, then the price would be specified to 7DP. (https://www.mql5.com/en/forum/109552/page3)

As RaptorUK says, the problem has to be somewhere else.
 
jjc:
It doesn't make any real difference - because normalizing to 6DP rather than 5DP should be irrelevant - but someone once cited an MT4 broker offering US Treasury Notes. If that broker were to offer the 2-year notes, then the price would be specified to 7DP. (https://www.mql5.com/en/forum/109552/page3)

As RaptorUK says, the problem has to be somewhere else.

Hi,

Thanks for the quick responses. Attached is the full code, I have cobbled together some JMA code I found on FF and added that to the existing engine that I was using in past robots. I know it is a coding travesty putting the JMA code twice (in order to get a Fast JMA line and Slow JMA line for the trigger) and have been trying to understand the JJMASeries function information posted here by Nikolay to use in the future. Any help with that would also be greatly appreciated.

Interestingly, the code was working for sell trades but wont do a buy. The FastJMA line does occasionally show as 0 in the journal which I am thinking could be causing the problem and am now thinking after seeing your posts above that the problem is stemming from the JMA code accordingly.

Any help appreciated again and apologies for the state of the code, Im obviously a novice..

Files:
 
IndicatorCounted() does not work in EAs Note: These functions cannot be used in experts and scripts.
Reason: