Please use the SRC button to post code . . .
Works just fine . . . with one small change . . .
//+------------------------------------------------------------------+ //| DayStart.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Yellow double Lo; int Holder; double LoBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_ARROW); SetIndexBuffer(0,LoBuffer); SetIndexArrow(0,233); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int CalculatedBars = Bars - counted_bars; for(int Count = CalculatedBars; Count >=0; Count--) { if(TimeHour(Time[Count]) == 0) { Lo = Low[Count]; Holder = Count; LoBuffer[Holder] = Lo - 0.0025; // <---- line moved } } //---- return(0); } //+------------------------------------------------------------------+
Another way without using an indicator and with grid off to see the beginning of new day is
properties ==> common ==> select "Show Period Separators"
This way the beginning of the new day is on the chart indicated with a vertical dotted line
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am trying to place an arrow on the chart at the start of each day. However the code is only placing an arrow for the start of the last day.
//+------------------------------------------------------------------+
//| DayStart.mq4 |
//| Copyright 2012, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
double Lo;
int Holder;
double LoBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0,LoBuffer);
SetIndexArrow(0,233);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int CalculatedBars = Bars - counted_bars;
for(int Count = CalculatedBars; Count >=0; Count--)
{
if(TimeHour(Time[Count]) == 0)
{
Lo = Low[Count];
Holder = Count;
}
}
LoBuffer[Holder] = Lo - 0.0025;
//----
return(0);
}
//+------------------------------------------------------------------+