Previous days 9pm open

 

Hi guys

has anyone come across an indicator that draws a histogram of either red or green buffers if price is above or below the previous days 9pm open price?

Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Price Constants
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Price Constants
  • www.mql5.com
Price Constants - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2019.08.21)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help (2017.04.21)

 
William Roeder:

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2019.08.21)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help (2017.04.21)

iv managed to do it with a histogram, although a rudimentary way. I have attached if anyone else may need it.

Files:
9pm_close.mq4  5 kb
 
your code can show different on different TFs........ 
shabaz:
   

has anyone come across an indicator that draws a histogram of either red or green buffers if price is above or below the previous days 9pm open price?

old one -- just line on chart to see higher or lower (no colors) - but you can enter extern any time you need... or adopt for yourself

//+------------------------------------------------------------------+
//|                                                   Open_day_price |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

extern string SessionStart="21:00";
//inputs
int    DayNow=0,Day_of_week=0;
//buffers
double Open_Day_Buff[];
//+------------------------------------------------------------------+
double open_week,open_day;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+


int init()
  {
   if(Period()>240)
     {
      Print("TF must be lower than D1!");
      return(-1);
     }
   SetIndexBuffer(0,Open_Day_Buff);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexLabel(0," Open day price ");
   IndicatorShortName(" Open day price ");
      SetIndexEmptyValue(0,EMPTY_VALUE);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();   //returns qty bars, that are unchanged after the last call
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   
   datetime t1=StrToTime(TimeToStr(CurTime(), TIME_DATE)+" 00:00");
   datetime t2=StrToTime(TimeToStr(CurTime(), TIME_DATE)+" "+SessionStart);
   int t3=(t2-t1)/(Period()*60);   //sec
   Comment(t3);   
   int i=Bars-counted_bars;   //int Bars - qty Bars on current chart. 
 
   if(counted_bars==0) i--;
   
   int shift=t3;  
   while(i>=0)
     {
     //
      int bar_today_D1=TimeDayOfYear(Time[iBarShift(Symbol(),0,iTime(Symbol(),0,i+t3),true)]);
      if(bar_today_D1!=DayNow) // condition for new day
        {
         DayNow=bar_today_D1;
         open_day=Open[i];//read the price of Day open in D1
        }
      ////////
      int day_off_week=TimeDayOfWeek(Time[iBarShift(Symbol(),0,iTime(Symbol(),0,i+t3),true)]);
      if(day_off_week!=Day_of_week) // condition for new day
        {
         Day_of_week=day_off_week;
         open_week=Open[i]; //read the price of day open in D1 
        }
      //////////
      Open_Day_Buff[i]=open_day;
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+
Reason: