#^MTF_EMA_Prediction_2

Download script
Author: Codersguru
#^MTF_EMA_Prediction_2

This script is designed as a multi-timeframe analysis tool for the MetaTrader platform. Its primary purpose is to help traders identify trend movements and potential price signals by synthesizing data from higher timeframes onto their current viewing screen.

Core Functionality

Multi-Timeframe Synchronization The core logic of this tool allows you to view data from a larger timeframe (such as Daily or Hourly) while staying on a smaller, more detailed chart (like 15-minute or 1-hour). Instead of manually switching between different charts to see the "big picture," the script automatically pulls and displays that information for you.

Exponential Moving Average (EMA) Analysis The tool utilizes Exponential Moving Averages—a common technical indicator used to smooth out price fluctuations. By comparing a "Short" EMA against a "Long" EMA, the script looks for specific interactions between these averages. These interactions are used to determine the strength and direction of the current market trend.

Visual Signal Identification To make the data easy to read at a glance, the script translates complex mathematical movements into clear visual cues:

  • Trend Lines: It plots lines that represent the moving averages on your chart.
  • Vertical Markers: When specific conditions are met, the script draws vertical lines to highlight exact moments where a signal occurs.
  • Directional "Thumbs": The tool includes unique icons (resembling thumbs up or down) that appear at specific price points. These act as immediate visual indicators of potential bullish or bearish movements based on the EMA calculations.

User Experience

The script is designed to be "plug and play." Once configured, it handles the heavy lifting of calculating multiple data points across different timeframes simultaneously. It automatically cleans up its own markings when you remove it from a chart, ensuring your workspace remains organized.

In short, this tool acts as a visual bridge, allowing you to see significant trend changes from a larger timeframe directly on your active trading screen, highlighted by clear icons and markers.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
#^MTF_EMA_Prediction_2
//+------------------------------------------------------------------+
//|                                             EMA_Prediction_2.mq4 |
//|                                                       Codersguru |
//|                                         http://www.forex-tsd.com |
//+------------------------------------------------------------------+


#property copyright "Codersguru"
#property link      "http://www.forex-tsd.com"

extern int TimeFrame=0;
extern int ShortEma=1;
extern int LongEma=2;
extern bool Draw_Lines = true;
extern bool Vertical_Lines = true;
extern bool Show_Thumbs = true;

#property indicator_buffers 4
#property indicator_chart_window
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_color4 Red

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];

double Signal1=0,Signal2=0;
int Previous_Bar = 0;


int init()
  {
  
      IndicatorBuffers(4);
      SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,2); 
      SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,2); 
      SetIndexArrow(0, 234);
      SetIndexArrow(1, 233);
      SetIndexBuffer(0,ExtMapBuffer1);
      SetIndexBuffer(1,ExtMapBuffer2);


      SetIndexStyle(2,DRAW_LINE);
      SetIndexBuffer(2,ExtMapBuffer3);
      SetIndexStyle(3,DRAW_LINE);
      SetIndexBuffer(3,ExtMapBuffer4);
      //---- name for DataWindow and indicator subwindow label   
      switch(TimeFrame)
     {
       case 1 : string TimeFrameStr="Period_M1"; break;
       case 5 : TimeFrameStr="Period_M5"; break;
       case 15 : TimeFrameStr="Period_M15"; break;
       case 30 : TimeFrameStr="Period_M30"; break;
       case 60 : TimeFrameStr="Period_H1"; break;
       case 240 : TimeFrameStr="Period_H4"; break;
       case 1440 : TimeFrameStr="Period_D1"; break;
       case 10080 : TimeFrameStr="Period_W1"; break;
       case 43200 : TimeFrameStr="Period_MN1"; break;
       default : TimeFrameStr="Current Timeframe";
     }
     IndicatorShortName("MTF_EMA_Prediction_2 ("+TimeFrameStr+")");   
      

   return(0);
  }


void DrawVertical( int bar , double value, color clr)
   {
      
      static int cnt = 0;
      cnt++;
      string dv = "Signal" + cnt;

      ObjectCreate(dv, OBJ_VLINE, 0, Time[bar], 0);
      ObjectSet(dv, OBJPROP_COLOR, clr);
      ObjectsRedraw();  
   }

void DrawThumb( int bar , int thumb , double value, color clr)
   {
      
      static int cnt = 0;
      cnt++;
      string dv = "thumb" + cnt;

      ObjectCreate(dv, OBJ_ARROW, 0, Time[bar], value);
      if(thumb == 1)
      {
         ObjectSet(dv, OBJPROP_ARROWCODE, 67);
      }
      
      if(thumb == 2)
      {
         ObjectSet(dv, OBJPROP_ARROWCODE, 68);
      }
      ObjectSet(dv, OBJPROP_COLOR, clr);
      ObjectSet(dv, OBJPROP_STYLE  , STYLE_SOLID);
      ObjectSet(dv, OBJPROP_WIDTH  , 3);
      ObjectsRedraw();  
   }
   
int deinit()
  {
   int I = WindowsTotal();
   for (int count = 0; count < WindowsTotal(); count++)
   {
      int nObjects = ObjectsTotal();
      for (int i=nObjects; i>=0; i--) 
      {
         string objName = ObjectName(i);
         if(StringFind(objName, "Signal", 0) >= 0)
         ObjectDelete(objName);
         if(StringFind(objName, "thumb", 0) >= 0)
         ObjectDelete(objName);
      }
   }
   return(0);
  }
int start()
  {
   
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars;
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;
   
//---- 
  
    ExtMapBuffer1[1]=iCustom(NULL,TimeFrame,"EMA_Prediction_2", ShortEma,LongEma,Draw_Lines,Vertical_Lines,Show_Thumbs,Signal1,0,y);
    ExtMapBuffer2[1]=iCustom(NULL,TimeFrame,"EMA_Prediction_2", ShortEma,LongEma,Draw_Lines,Vertical_Lines,Show_Thumbs,Signal2,1,y);
    ExtMapBuffer3[1]=iCustom(NULL,TimeFrame,"EMA_Prediction_2", ShortEma,LongEma,Draw_Lines,Vertical_Lines,Show_Thumbs,2,y);
    ExtMapBuffer4[1]=iCustom(NULL,TimeFrame,"EMA_Prediction_2", ShortEma,LongEma,Draw_Lines,Vertical_Lines,Show_Thumbs,3,y);

    } 
//

    return(0);
   }
  

Comments