Coding Price Cross

 

Hi All,

Completely new to MT4 and looking for some help coding a simple price cross over a moving average.

Pseudocode looks like this:

__________________

When CurrentPrice crosses MA(100)

Start Buy function

__________________

Hope you can help!

 
Instead of looking (end endlessly waiting) here for someone search (or google) for already existing code!
 
RainyDay: Hope you can help!
Help you with what? You haven't stated a problem.
We can't help you unless you show us your attempt and state the nature of your problem.
          No free help
          urgent help.
 
whroeder1:
Help you with what? You haven't stated a problem.
We can't help you unless you show us your attempt and state the nature of your problem.
          No free help
          urgent help.

Hi whroeder1,

I'm looking for a way to identify: when the current price crosses (above/below) a Simple Moving average.

Any suggestions?

 
RainyDay: I'm looking for a way... Any suggestions?

  1. You said that in your first post. What part of "show us your attempt and state the nature of your problem" was unclear?

  2. If the open is on one side and the close is on the other, then price crossed.

    double ma = ...;
    bool wasBelow =  Open[1] < ma;
    bool  isBelow = Close[1] < ma;
    bool hasCrossed = wasBelow != isBelow;
    Is that so hard?
Reason: