Test previous candles against MA

 

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 

 

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.

 

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.

 
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.
 
  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?


 

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

 
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 

 
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!! 

Reason: