Author: Copyright 2015, MetaQuotes Software Corp.
3clinetf

This tool is designed as a visual technical indicator for the MetaTrader platform. Its primary purpose is to identify and display specific price levels based on historical price actions—specifically focusing on "Up" and "Down" movements over a defined timeframe.

Core Logic and Functionality

1. Multi-Timeframe Analysis The script allows users to analyze data from different timeframes than the one currently displayed on the chart. It looks for specific signals within these alternate periods and translates that information back onto your current view. This helps in identifying broader market trends that might be hidden on smaller charts.

2. Trend Identification (Up and Down Movements) The logic separates market movements into two distinct categories:

  • Downside Movements: The script tracks historical "down" bars to calculate specific price points.
  • Upside Movements: Similarly, it tracks "up" bars to identify corresponding price levels.

3. Data Mapping and Synchronization The tool performs a sophisticated "shifting" process. Because it looks at data from different timeframes, it must align those historical moments with the current chart's timeline. It automatically calculates where those specific past events occurred in your current view so that the resulting lines appear in the correct chronological order.

4. Visual Representation The script produces four distinct visual elements on the chart:

  • Trend Lines: It draws horizontal dashed lines (colored Blue and Orange) representing key price levels derived from the "Up" and "Down" data.
  • Dynamic Calculation: When specific conditions are met, it calculates the distance between current market prices (Ask and Bid) to adjust these levels accurately in real-time.

5. User Customization The logic includes a "Break Only" mode, which allows the user to filter the information shown on the chart, ensuring that only significant structural breaks are highlighted rather than every minor price fluctuation.

Summary for the User

Essentially, this script acts as an automated scout. It goes into other timeframes, finds specific upward and downward momentum points, and brings those key price levels back to your main screen. It helps you visualize where the market "moved" previously, allowing you to see significant support or resistance levels that might otherwise be overlooked.

Miscellaneous
Implements a curve of type %1
4 Views
0 Downloads
0 Favorites
3clinetf
//+------------------------------------------------------------------+
//|                                                       3CLine.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   4
double X[],Y[],X0[],Y0[];
string C3X="C3X",C3Y="C3Y";
//---
input int TF=0;
input bool BreakOnly=true;
//---
int BBar=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectDelete(C3X);
   ObjectDelete(C3Y);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,X);
   SetIndexBuffer(1,Y);
   SetIndexBuffer(2,X0);
   SetIndexBuffer(3,Y0);
//---
   SetIndexStyle(0,DRAW_SECTION,STYLE_DOT,1,clrRoyalBlue);
   SetIndexStyle(1,DRAW_SECTION,STYLE_DOT,1,clrOrangeRed);
   SetIndexStyle(2,DRAW_SECTION,STYLE_SOLID,3,clrOrangeRed);
   SetIndexStyle(3,DRAW_SECTION,STYLE_SOLID,3,clrRoyalBlue);
//---
   if(TF==0)
     {
      SetIndexStyle(0,DRAW_NONE);
      SetIndexStyle(1,DRAW_NONE);
      SetIndexStyle(2,DRAW_SECTION,STYLE_SOLID,1,clrOrangeRed);
      SetIndexStyle(3,DRAW_SECTION,STYLE_SOLID,1,clrRoyalBlue);
     }
//---
   C3X=C3X+(string)TF;
   C3Y=C3Y+(string)TF;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   if(TF!=0 && TF<_Period) {OnDeinit(0);return(0);}
//---
   ArrayInitialize(X,EMPTY_VALUE);
   ArrayInitialize(Y,EMPTY_VALUE);
   ArrayInitialize(X0,EMPTY_VALUE);
   ArrayInitialize(Y0,EMPTY_VALUE);
//---
   int j1=0,j3=0;
//--- Óðîâåíü ðàçâîðîòà ââåðõ      
   j1=DnBars(TF,1);
   j3=DnBars(TF,3);
//---
   j1=iBarShift(_Symbol,_Period,iTime(_Symbol,TF,j1));
   j3=iBarShift(_Symbol,_Period,iTime(_Symbol,TF,j3));
   datetime tx=time[j3];
//---
   X[j3]=DnValues(TF,3);
   X[0]=X[j3];
//---
   X0[j3]=X[j3];
   X0[j1]=DnValues(TF,1);
//--- Óðîâåíü ðàçâîðîòà âíèç      
   j1=UpBars(TF,1);
   j3=UpBars(TF,3);
//---
   j1=iBarShift(_Symbol,_Period,iTime(_Symbol,TF,j1));
   j3=iBarShift(_Symbol,_Period,iTime(_Symbol,TF,j3));
   datetime ty=time[j3];
//---
   Y[j3]=UpValues(TF,3);
   Y[0]=Y[j3];
//---
   Y0[j3]=Y[j3];
   Y0[j1]=UpValues(TF,1);
//---
   if(TF==0) Draw(tx,ty);
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Draw(datetime t1,datetime t2)
  {
//---
   double a=MarketInfo(_Symbol,MODE_ASK);
   double b=MarketInfo(_Symbol,MODE_BID);
   double XX0=X[0]+a-b;
   double YY0=Y[0];
//---
   datetime t=TimeCurrent();
   ObjectCreate(C3X,OBJ_TREND,0,0,0,0,0);
   ObjectSet(C3X,OBJPROP_TIME1,t1);
   ObjectSet(C3X,OBJPROP_TIME2,t);
   ObjectSet(C3X,OBJPROP_PRICE1,XX0);
   ObjectSet(C3X,OBJPROP_PRICE2,XX0);
   ObjectSet(C3X,OBJPROP_COLOR,clrRoyalBlue);
   ObjectSet(C3X,OBJPROP_STYLE,STYLE_DASH);
//---
   ObjectCreate(C3Y,OBJ_TREND,0,0,0,0,0);
   ObjectSet(C3Y,OBJPROP_TIME1,t2);
   ObjectSet(C3Y,OBJPROP_TIME2,t);
   ObjectSet(C3Y,OBJPROP_PRICE1,YY0);
   ObjectSet(C3Y,OBJPROP_PRICE2,YY0);
   ObjectSet(C3Y,OBJPROP_COLOR,clrOrangeRed);
   ObjectSet(C3Y,OBJPROP_STYLE,STYLE_DASH);
  }
//---
int DnBars(int tf, int i) {return((int)iCustom(_Symbol,tf,"3CLine",BreakOnly,0,i));}
int UpBars(int tf, int i) {return((int)iCustom(_Symbol,tf,"3CLine",BreakOnly,1,i));}
double DnValues(int tf,int i) {return(iCustom(_Symbol,tf,"3CLine",BreakOnly,2,i));}
double UpValues(int tf,int i) {return(iCustom(_Symbol,tf,"3CLine",BreakOnly,3,i));}
//+------------------------------------------------------------------+

Comments