Formula to compare two MA vlaues
-
I am working on an EA to provide buy signal when ...
(Condition 1) the MA(5) crosses above MA(10) on third bar before the current bar
AND
(Condition 2) if the difference between MA(5) and MA(10) on current bar is more than 50 points.I could create the condition block for the first condition, but I can not find a way to create the second condition. I tried the formula block but could not really get it.
Does someone know of any example? Please guide me with some images / examples.
Thanks
-
You can use "Adjust" field for that. For example:
- MA(5) + 0.0050 > MA(10)
- MA(5) > MA(10) -0.0050
where "+0.0050" or "-0.0050" is written in "Adjust" field. You can also write "+50pips" or "-50pips" there.
-
I am testing two conditions for two different shift values and there is an AND operator also. The first condition is for shift value of 3 whereas the second condition is for the current bar. So how do I format the adjust parameter will will take care of these two different shift values? I also need these shift values to be user configurable so that I can change them from the parameters screen of the EA.
Thanks
-
http://fxdreema.com/shared/AyQm2K6nc
And it's much better to connect two (or more) blocks one after another instead of connecting them in parallel and then use AND.
-
I am trying to create a copy of all the boxes on this ea. When I use the constants I get too many compilation errors like
Compilation errors
'free' - unexpected token
'inp2_Lo_SHIFT' - expression on global scope not allowed
'inp2_Lo_SHIFT' - variable not defined
'CrossBeforeBar' - expression on global scope not allowed
'inp2_Lo_SHIFT' - variable not defined
'inp2_Lo_SHIFT' - variable not defined
'inp2_Lo_SHIFT' - variable not defined
'inp2_Lo_SHIFT' - variable not defined'MAdiff' - an operator expected
'=' - assignment expected
'MAdiff' - semicolon expected
';' - assignment expected
rrors--4
ee logfile "C=\Program Files\MetaTrader 4 - Exness\experts\FxDr MA 031367548439.log"I get no compilation errors without usage of constants.
Is it becasue I am working on free version? or some thing else? -
It's something else. Don't check input parameters checkbox when using constant.
You can export .mq4 file from the shared project and then import that file into your projects.