title: How to find a down trend in MQL4 from coding
body: <p><a href="https://i.stack.imgur.com/zkncF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zkncF.jpg" alt="enter image description here"></a></p>
  
  <p>I am writing an EA but I am beginner in MQL4. Please suggest me how could I identify a DOWN TREND or an UP TREND of moving average in my EA programmatically?</p>
  
  <p>Please advise me as I have not so familiar with MQL4.</p>
  
  <p>in the above image trend is not moving in up or down direction it moving in horizontal direction.</p>
  
  <p>I want to make an EA using Heiken Ashi and MA. First in my code I want to identify weather its an up trend or down trend or a tread shown in the above image.</p>
  
  <p><a href="https://www.mql5.com/en/articles/136" rel="nofollow noreferrer">https://www.mql5.com/en/articles/136</a>
  on this link I found this:</p>
  
  <blockquote>
    <p><strong>2.1. Trend Detection Using Moving Average</strong> 
    Perhaps, the easiest way to detect a trend and its direction - using moving averages. One of
    the first tools of technical analysis - moving average - is still used
    in different variations and is the basis of most indicators. Traders
    use both one moving average and a whole set of them, which sometimes
    is called as "fan". </p>
    
    <p>Let's formulate a simple rule for one moving average: 
    <strong>Trend goes up</strong> if at a given timeframe the closing price of bar is <strong>above</strong> moving average.
    <strong>Trend goes down</strong> if at a given timeframe the closing price of bar is
    <strong>below</strong> moving average.</p>
  </blockquote>
  
  <p>If I identify trend like said above if price close above MA then its an up trend and if price close below MA then its a down trend that how could I identify that horizontal moving trend?</p>
  
  <p>Please guide.</p>