MTF_OsMA2_v3

Download script
Author: Copyright � 2006, Eli hayun
MTF_OsMA2_v3

This indicator is designed to provide traders with a multi-timeframe visual signal by analyzing price momentum across two different time periods simultaneously. Instead of looking at just the current chart's timeframe, it pulls data from two specific external periods (for example, a 30-minute and a 1-hour timeframe) to help identify broader market trends.

How the Logic Works

Multi-Timeframe Analysis The core strength of this tool is its ability to "look ahead" into different timeframes. It creates a synchronized view where it calculates signals based on two independent settings defined by the user. This allows a trader to see how the shorter-term price action aligns with the longer-term momentum.

Signal Generation The script utilizes an external calculation (referred to as "OsMA2") to determine market sentiment. For each timeframe analyzed:

  • It checks the resulting value of this calculation.
  • If the value is positive, it interprets the trend in one direction.
  • If the value is negative, it interprets the trend in the opposite direction.

Visual Representation Rather than drawing complex lines or curves that might clutter the screen, this script uses a "point-based" visual system:

  • Arrows/Markers: The tool places specific markers on the chart to represent the signals for both timeframes.
  • Spacing (The Gap): To prevent the markers from overlapping and becoming confusing, the script includes a "Gap" logic. This ensures that the signal for the first timeframe is plotted at a different vertical height than the signal for the second timeframe.
  • Color Coding: The signals are differentiated by color (Red and Blue), allowing you to instantly see whether both timeframes are in agreement or if there is a divergence between short-term and long-term movements.

Summary for the User

When you use this tool, you aren't just looking at what is happening right now on your current screen. You are viewing a summarized "agreement" between two different time horizons. When both markers move in the same direction (same color), it suggests a stronger consensus in the market trend. When they differ, it highlights a potential conflict between short-term volatility and long-term direction.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
MTF_OsMA2_v3
//+------------------------------------------------------------------+
//|                                          #MTF OsMA_v3            |
//|                                      Copyright © 2006, Eli hayun |
//|                                    OsMA Conversion By image3022  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli hayun"
#property link      "http://"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 20
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Blue
//---- buffers
double buf4_up[];
double buf4_down[];
double buf3_up[];
double buf3_down[];

extern double Gap = 3; // Gap between the lines of bars

extern int Period_1 = PERIOD_M30;
extern int Period_2 = PERIOD_H1;

extern bool AutoDisplay      = false;

string shortname = "";
bool firstTime = true;

int UniqueNum = 228;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
  
   
  
   shortname = "# MTF OsMA2("+Period_1+","+Period_2+")";
   firstTime = true;
   
   IndicatorShortName(shortname);
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,110);
   SetIndexBuffer(0,buf4_up);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,110);
   SetIndexBuffer(1,buf4_down);
   SetIndexEmptyValue(1,0.0);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,110);
   SetIndexBuffer(2,buf3_up);
   SetIndexEmptyValue(2,0.0);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,110);
   SetIndexBuffer(3,buf3_down);
   SetIndexEmptyValue(3,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
   shortname = "# MTF OsMA2("+Period_1+","+Period_2+")";
   firstTime = true;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int i=0, y5m=0, y15m=0, yy;
   int limit=Bars-counted_bars;

   datetime TimeArray_5M[], TimeArray_15M[];
//----

   
    
   ArrayCopySeries(TimeArray_15M,MODE_TIME,Symbol(),Period_2);
   ArrayCopySeries(TimeArray_5M,MODE_TIME,Symbol(),Period_1); 
      
   for(i=0, y5m=0,  y15m=0;i<limit;i++)
   {
      if (Time[i]<TimeArray_5M[y5m]) y5m++;
      if (Time[i]<TimeArray_15M[y15m])   y15m++;

      for (int tf = 0; tf < 2; tf++)
      {
         int prd;
         switch (tf)
         {
            case 0: prd = Period_1; yy = y5m;  break;
            case 1: prd = Period_2; yy = y15m;  break;
         }
        // iCustom(NULL,0,"Xo",10.0,0,SignalCandle);
         double cci = iCustom(NULL, prd, "OsMA2",12,0,yy);
         double dUp = EMPTY_VALUE; //   iCustom(NULL, prd, "SuperTrend", false, 1, yy);
         double dDn = EMPTY_VALUE; //iCustom(NULL, prd, "SuperTrend", false, 0, yy);
         
        // if (cci > 0) dUp = 1; else dDn = 1;
         if (cci > 0) dDn = 1; else dUp = 1;
         
         switch (tf)
         {
           
            case 0: if (dUp == EMPTY_VALUE)  buf3_down[i]  = 1 + Gap * 2; 
            else buf3_up[i]  = 1 + Gap * 2; break;
            case 1: if (dUp == EMPTY_VALUE)  buf4_down[i]  = 1  + Gap * 3; 
            else buf4_up[i]  = 1 + Gap * 3; break;
         }
         
         
      }


   }

   return(0);
  }
  
//+------------------------------------------------------------------+






Comments