Hamyar Calculate

Download script
Author: Copyright � 2010,Farshad Saremifar
Hamyar Calculate

This script is designed to act as a sophisticated data processing tool for traders, primarily focused on identifying key price levels and measuring market volatility across multiple timeframes simultaneously. Instead of just showing a single piece of information, it performs background calculations to help map out the "structure" of the market.

Core Functionality

1. Pivot Point Calculation The script identifies significant price levels known as Pivot Points. It calculates these by looking back at historical data to find the highest and lowest prices reached during specific periods. By combining the previous high, the previous low, and the closing price, it establishes a central "balance" point for the market.

2. Multi-Timeframe Volatility Tracking One of the most unique features of this script is its ability to "look" at different timeframes (such as 5-minute, 15-minute, 30-minute, 1-hour, and 4-hour charts) all at once. It measures a specific type of market movement (volatility) for each of these intervals simultaneously. This allows a trader to see how the current market price is behaving relative to both short-term "noise" and long-term trends.

3. Time-Based Synchronization The script doesn't just run randomly; it is programmed with specific logic to recognize new trading sessions or significant time blocks (like every hour, every 4 hours, or even daily resets). When it detects these specific milestones, it refreshes its calculations to ensure the data remains relevant to the current market cycle.

How it Works for the User

  • Data Continuity: If the script identifies a new period of importance, it updates all the calculated values (Pivots and Volatility metrics) instantly.
  • Stability: During periods where no new time milestones are hit, the script holds onto its last known values. This ensures that the data remains consistent and "smooth" on your chart rather than jumping around erratically.
  • Comprehensive Overview: By calculating five different volatility measures at once, it provides a complete picture of market energy, helping to distinguish between a small price move in the 5-minute window versus a significant shift in the 4-hour window.

In summary, this tool acts as a multi-dimensional calculator that automatically tracks historical extremes and real-time volatility across a wide spectrum of timeframes, providing a stabilized view of where the market stands at any given moment.

Indicators Used
Indicator of the average true range
6 Views
0 Downloads
0 Favorites
Hamyar Calculate
//+------------------------------------------------------------------+
//|                                             Hamyar Calculate.mq4 |
//|                               Copyright © 2010,Farshad Saremifar |
//|                                               www.4xline.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010,Farshad Saremifar"
#property link      "www.4xline.com"

#property indicator_chart_window
#property indicator_buffers 6
extern string    Copyright="Copyright © 2010,Farshad Saremifar,www.4xline.com";
extern string    Help="This is just used to calculate Internal Variables";
extern int ATR_Period=25;
 int MasterTF=60;
double Pivot[];
double pip5[],pip15[],pip30[],pip60[],pip240[];
double PDayHigh, PDayLow;
datetime PivotDayStartTime;
int NumberOfDays=2;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorDigits(Digits);
   SetIndexBuffer( 0, Pivot);
   SetIndexBuffer( 1, pip5);
   SetIndexBuffer( 2, pip15);
   SetIndexBuffer(3, pip30);
   SetIndexBuffer( 4, pip60);
   SetIndexBuffer(5, pip240);
   SetIndexLabel( 0, "Pivot" );
   SetIndexLabel( 1, "Period_M5" );
   SetIndexLabel( 2, "Period_M15" );
   SetIndexLabel( 3, "Period_M30" );
   SetIndexLabel( 4, "Period_H1" );
   SetIndexLabel( 5, "Period_H4" );
   PivotDayStartTime = 0; 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
 
   int     j =((NumberOfDays*1440)/Period())+((1440)/Period());
   double Range;
   int Count;
   while(j >=0)
   {    
   
     if( Check(Time[j]) )
        {
         Count = iBarShift( Symbol(), 0, PivotDayStartTime ) - j;           
         PDayHigh = High[ iHighest( Symbol(), 0, MODE_HIGH, Count, j+1 ) ]; 
         PDayLow = Low[ iLowest( Symbol(), 0, MODE_LOW, Count, j+1 ) ]; 
         pip5[j]=iATR(Symbol(),PERIOD_M5,ATR_Period,iBarShift(NULL,PERIOD_M5,PivotDayStartTime,false));
         pip15[j]=iATR(Symbol(),PERIOD_M15,ATR_Period,iBarShift(NULL,PERIOD_M15,PivotDayStartTime,false));    
         pip30[j]=iATR(Symbol(),PERIOD_M30,ATR_Period,iBarShift(NULL,PERIOD_M30,PivotDayStartTime,false));
         pip60[j]=iATR(Symbol(),PERIOD_H1,ATR_Period,iBarShift(NULL,PERIOD_H1,PivotDayStartTime,false));
         pip240[j]=iATR(Symbol(),PERIOD_H4,ATR_Period,iBarShift(NULL,PERIOD_H4,PivotDayStartTime,false));
         Pivot[j] = ( PDayHigh + PDayLow + Close[j+1]*2) /4;
         PivotDayStartTime = Time[j];    
        }
         else     
        {
       
                 pip15[j]=pip15[j+1];
                 pip5[j]=pip5[j+1];
                 pip30[j]=pip30[j+1];
                 pip60[j]=pip60[j+1];
                 pip240[j]=pip240[j+1];
                 Pivot[j] = Pivot[j+1];
        }  
      j--; 
      }
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
bool Check(datetime t)
{   
    int TM=TimeMinute(t), TH=TimeHour(t) ;
    bool draw=false;
   
      if(MasterTF==5)
          {  
            if( TM==0 || TM==5 ||TM==10 ||TM==15 ||TM==20||TM==25 ||TM==30 
            ||TM==35 ||TM==40 ||TM==45||TM==50||TM==55) 
            draw=true;
          }  
      if(MasterTF==15)
          {
          if( TM==0 || TM==15 ||TM==30 ||TM==45) 
            draw=true;
          }      
      if(MasterTF==30)
          {
          if( TM==0 || TM==30) 
            draw=true;
          }      
      if(MasterTF==60)
          {
           if( TM==0) 
            draw=true;
          }      
      if(MasterTF==240)
          {
            if(TM==0 && (TH==0 ||TH==4||TH==8||TH==12||TH==16||TH==20||TH==24) ) 
            draw=true;
          }      
      if(MasterTF==1440)
          {
            if(TH==0 && TM==0) 
            draw=true;
          }       
      if(MasterTF==10080)
          {
            if(TH==0 && TM==0 && TimeDayOfWeek(t)==1 ) 
            draw=true;
          } 
      if(MasterTF==43200)
          {
            if(TH==0 && TM==0 && TimeDay(t)==1 ) 
            draw=true;
          }      
          
 return(draw);         
}  

Comments