TrendEMA_V_1_001

Author: FxPars
TrendEMA_V_1_001
Indicators Used
Moving average indicator
2 Views
0 Downloads
0 Favorites
TrendEMA_V_1_001
//+------------------------------------------------------------------+
//|                       TrendEMA - Display Trend And MA Values.mq4 |
//|                        Original Name                TrendEMA.mq4 |
//|                                                           FxPars |
//|                        Original Source     http://www.fxpars.com |
//+------------------------------------------------------------------+
#property copyright "FxPars"
#property link      "http://www.fxpars.com"
#property indicator_chart_window

//---Display Trend and MA Values At User Select Corner  - Added by Robert - 7/21/2010
//---Added User Select Font Size (Fontz) And Select Bar (Barz)For Current Or Past Bars
//---Changed hard coded MA TF from Period_H1 to "0" default current chart TF
//---Save As : TrendEMA - Display Trend And MA Values - 7/21/2010

//---Variables
extern int LargeEMA   = 100;
extern int MediumEMA  = 10;
extern int LowEMA     = 5;

//---Added for User Comfort Settings
extern int Fontz         = 12;  // Font size 12 default
extern int DisplayCorner = 0;   // Added for corner to display - default 3 bottom right
extern int Barz          = 0;   // Added to select MA current bar or previous bars : 0 = Current Bar Default
//--------------------------
int Fonts  = 9;
double Lma = 0;
double Mma = 0;
double Nma = 0;
double pp  = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- Changed from hard code PERIOD_H1 to "0" default chart TF
   Lma=iMA(NULL,0,LargeEMA,0,MODE_EMA,PRICE_CLOSE,Barz);
   Mma=iMA(NULL,0,MediumEMA,0,MODE_EMA,PRICE_CLOSE,Barz);
   Nma=iMA(NULL,0,LowEMA,0,MODE_EMA,PRICE_CLOSE,Barz);
  
   
//----   
   if (Lma>Mma && Mma>Nma) // DownTrend
     {
     //  Comment("\n  * DownTrend *    " + "\n LargeEMA= " + Lma + "\n MediumEMA= " + Mma + "\n LowEMA= " + Nma);

       //---Try Trend only on top - start
      ObjectCreate("Nma-Trend", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Nma-Trend", OBJPROP_CORNER,DisplayCorner);     //
      ObjectSet("Nma-Trend", OBJPROP_XDISTANCE, 10); // 
      ObjectSet("Nma-Trend", OBJPROP_YDISTANCE, 60); //
      //---Try Trend only on top - end
      
      ObjectCreate("Lma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Lma", OBJPROP_CORNER,DisplayCorner);     // Extern User setting
      ObjectSet("Lma", OBJPROP_XDISTANCE, 10); // Adjust this for side to side display
      ObjectSet("Lma", OBJPROP_YDISTANCE, 45); // Adjust this for up and down display
           
      ObjectCreate("Mma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Mma", OBJPROP_CORNER,DisplayCorner);
      ObjectSet("Mma", OBJPROP_XDISTANCE, 10);
      ObjectSet("Mma", OBJPROP_YDISTANCE, 30);
      
      ObjectCreate("Nma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Nma", OBJPROP_CORNER,DisplayCorner);
      ObjectSet("Nma", OBJPROP_XDISTANCE, 10);
      ObjectSet("Nma", OBJPROP_YDISTANCE, 15);
 
       ObjectSetText("Nma-Trend","DownTrend ",Fontz,"Arial Black",Crimson);  
       ObjectSetText("Lma","Large EMA = "+DoubleToStr(Lma,5),Fonts,"Arial Bold",White);  
       ObjectSetText("Mma","Medium EMA = "+DoubleToStr(Mma,5),Fonts,"Arial Bold",White);
       ObjectSetText("Nma","Low EMA = "+DoubleToStr(Nma,5),Fonts,"Arial Bold",White);

         //ObjectDelete("Nma-Trend"); 
           ObjectDelete("Lma-Trend");
           ObjectDelete("Mma-Trend");
     }
   //------------------------------------
   
   else if (Lma<Mma && Mma<Nma) // UpTrend
      {
     //   Comment("\n  * UpTrend *    " + "\n LargeEMA= " + Lma + "\n MediumEMA= " + Mma + "\n LowEMA= " + Nma); 
   
      //---Trend on top
      ObjectCreate("Lma-Trend", OBJ_LABEL, 0, 0, 0);        
      ObjectSet("Lma-Trend", OBJPROP_CORNER,DisplayCorner); 
      ObjectSet("Lma-Trend", OBJPROP_XDISTANCE, 20);        
      ObjectSet("Lma-Trend", OBJPROP_YDISTANCE, 60);       
      
      ObjectCreate("Lma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Lma", OBJPROP_CORNER,DisplayCorner);     
      ObjectSet("Lma", OBJPROP_XDISTANCE, 10); 
      ObjectSet("Lma", OBJPROP_YDISTANCE, 45); // 
           
      ObjectCreate("Mma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Mma", OBJPROP_CORNER,DisplayCorner);
      ObjectSet("Mma", OBJPROP_XDISTANCE, 10);
      ObjectSet("Mma", OBJPROP_YDISTANCE, 30);
      
      ObjectCreate("Nma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Nma", OBJPROP_CORNER,DisplayCorner);
      ObjectSet("Nma", OBJPROP_XDISTANCE, 10);
      ObjectSet("Nma", OBJPROP_YDISTANCE, 15);
 
      ObjectSetText("Lma-Trend","UpTrend ",Fontz,"Arial Black",SpringGreen);  
      ObjectSetText("Lma","Large EMA = "+DoubleToStr(Lma,5),Fonts,"Arial Bold",White);  
      ObjectSetText("Mma","Medium EMA = "+DoubleToStr(Mma,5),Fonts,"Arial Bold",White);
      ObjectSetText("Nma","Low EMA = "+DoubleToStr(Nma,5),Fonts,"Arial Bold",White);
       
         //ObjectDelete("Lma-Trend");
           ObjectDelete("Mma-Trend"); 
           ObjectDelete("Nma-Trend");
    }   
//-------------------------------------  
      else             // Sideways
    {
     //  Comment("\n  * Sideway *    " + "\n LargeEMA= " + Lma + "\n MediumEMA= " + Mma + "\n LowEMA= " + Nma);
    
      //---Trend on top
      ObjectCreate("Mma-Trend", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Mma-Trend", OBJPROP_CORNER,DisplayCorner);     
      ObjectSet("Mma-Trend", OBJPROP_XDISTANCE, 30);  
      ObjectSet("Mma-Trend", OBJPROP_YDISTANCE, 60); 
      
      ObjectCreate("Lma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Lma", OBJPROP_CORNER,DisplayCorner);  
      ObjectSet("Lma", OBJPROP_XDISTANCE, 10); 
      ObjectSet("Lma", OBJPROP_YDISTANCE, 45); 
           
      ObjectCreate("Mma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Mma", OBJPROP_CORNER,DisplayCorner);
      ObjectSet("Mma", OBJPROP_XDISTANCE, 10);
      ObjectSet("Mma", OBJPROP_YDISTANCE, 30);
      
      ObjectCreate("Nma", OBJ_LABEL, 0, 0, 0);
      ObjectSet("Nma", OBJPROP_CORNER,DisplayCorner);
      ObjectSet("Nma", OBJPROP_XDISTANCE, 10);
      ObjectSet("Nma", OBJPROP_YDISTANCE, 15);
 
      ObjectSetText("Mma-Trend","Sideways ",Fontz,"Arial Black",Gold);  
      ObjectSetText("Lma","Large EMA = "+DoubleToStr(Lma,5),Fonts,"Arial Bold",White);  
      ObjectSetText("Mma","Medium EMA = "+DoubleToStr(Mma,5),Fonts,"Arial Bold",White);
      ObjectSetText("Nma","Low EMA = "+DoubleToStr(Nma,5),Fonts,"Arial Bold",White);

           ObjectDelete("Nma-Trend"); 
           ObjectDelete("Lma-Trend");
         //ObjectDelete("Mma-Trend");
     }
   return(0);
  }
//+---------------------End Of Code---------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---