Ascending/Descending moving average

Back to topics list To post a new topic, please log in or register
avatar
17
masoud0455_a 2016.07.15 14:27
 

I want to know Ascending/Descending moving average in mql4.

give me an idea to code this. How can I do it?


avatar
12983
WHRoeder 2016.07.15 15:57 #
 
How do you define ascending? That's how you code it.
avatar
17
masoud0455_a 2016.07.15 16:08 #
 

that's my problem.

I don't know how to define.can someone help me and give me an idea to define it?

avatar
12983
WHRoeder 2016.07.15 22:15 #
 
masoud0455_a: that's my problem.I don't know how to define.
Perhaps: Ascending | Define Ascending at Dictionary.com
avatar
17
masoud0455_a 2016.07.15 23:00 #
 

:-)))

I got it and I coded it.

Just get 2 price of first and 15 candle back and subtract them and compare the result with my define distance.

#property copyright "Masoud"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property show_inputs

 extern int CandlesBack=15; //How many candles look back:
 extern int pipsdefine=5;//How many pips define at M5
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
 { 
  
   double pips =Point; 
   if(Digits==3||Digits==5)
   pips*=10;
   //------
   
    int timef;             
    double distance=pipsdefine*pips;
    
    switch(Period())
    {   
      case 15: timef=15; distance*=2;  break; //10 pips M15
      case 30: timef=30; distance*=4;  break; //20 pips M30          
      case 60: timef=60; distance*=4; break;
      case 240: timef=240; distance*=5; break;
      case 1440:timef=1440; distance*=12; break;
      default:timef=5; break;         
    }
    
    double startSMA20 =iMA(Symbol(),timef,20,0,MODE_SMA,PRICE_CLOSE,1);
    double endSMA20 =iMA(Symbol(),timef,20,0,MODE_SMA,PRICE_CLOSE,CandlesBack);
     
    if(startSMA20-endSMA20 > distance) MessageBox("Ascending","Trend Info"); 
    else if(startSMA20-endSMA20 < -distance) MessageBox("Descending","Trend Info"); 
    else MessageBox("Sideway","Trend Info");
            
 }
Back to topics list  

To add comments, please log in or register