Download MetaTrader 5

Test previous candles against MA

To add comments, please log in or register
Launch agents on an idle PC. It is profitable!
chipNdale
30
chipNdale 2016.10.31 06:01 

Hi Guys,

    I wanted to check with you guys if you can help me with a function that I can call to check if previous 10 candles is not touching my SMA(18) as I want to use it as another filter for the EA that I am working on something like below:

 

MA cross check 

peter.MT4Web
158
peter.MT4Web 2016.10.31 08:53  

Start with writing down, what you see in the chart. If you are shure you have all details (what is with gaps) pack all in a algorith and then you can start with coding.

peter.MT4Web
158
peter.MT4Web 2016.10.31 10:19  

If you have worked it out on a paper, you can compare it with your code.

I would have coded it otherwise, but i don't know what you want.

But if you prefer thinking and writing code at the same time, learn to use a debugger or print your variables.

chipNdale
30
chipNdale 2016.10.31 10:33  
eddie:

If you have worked it out on a paper, you can compare it with your code.

I would have coded it otherwise, but i don't know what you want.

But if you prefer thinking and writing code at the same time, learn to use a debugger or print your variables.



is there a debugger in MQ$ please guide me how to use debugger sorry as well if I was not clear on what I want that is the best way I can describe it already.
whroeder1
14514
whroeder1 2016.10.31 11:29  
  1. chipNdale: to check if previous 10 candles is not touching my SMA(18)
    Refine your requirement. A) not touching the SMA, or B) Above or below the current value of the SMA. B is what your code does.
  2. chipNdale: is there a debugger in MQ$
    Have you bothered to hover over these buttons?


peter.MT4Web
158
peter.MT4Web 2016.10.31 11:40  

There is not only a debugger, there also is some information in the manual.

chipNdale
30
chipNdale 2016.10.31 12:23  
WHRoeder:
  1. chipNdale: to check if previous 10 candles is not touching my SMA(18)
    Refine your requirement. A) not touching the SMA, or B) Above or below the current value of the SMA. B is what your code does.
  2. chipNdale: is there a debugger in MQ$
    Have you bothered to hover over these buttons?


Hi WhRoeder, thanks so much for responding I appreciate it. Below is my response. Will try to check the buttons thanks! And thanks in advance for bothering to understand me more I super appreciate it

 

Refine your requirement.

A) not touching the SMA, &   B) Above or below the current value of the SMA. B is what your code does. 

  I need to assign a variable that checks for "noise" meaning if a price crosses above  the sma I will only open a long position if the  last 10 candles did not touch the sma

The other way around for short position, when it crosses the sma downwards I will only open a short position if the past 10 candles did not touch my SMA 

chipNdale
30
chipNdale 2016.10.31 14:18  
WHRoeder:
  1. chipNdale: is there a debugger in MQ$
    Have you bothered to hover over these buttons?


Hi WHRoeder,

  Thanks for pointing me to the debugger, I found whats causing it not to work, I have declared my variables as INT instead of double good thing you showed me the debug function thanks so much!! 

To add comments, please log in or register