I hope this is simple.
The indicator draws horizontal lines at the highest and lowest values for a given period.
The only problem is, it never re-draws the lines. When the lines were drawn at values based on candles further out than the period. It never re-calculates.
If anyone can tell me what I'm missing, I'd appreciate it.
Thanks.
The indicator draws horizontal lines at the highest and lowest values for a given period.
The only problem is, it never re-draws the lines. When the lines were drawn at values based on candles further out than the period. It never re-calculates.
If anyone can tell me what I'm missing, I'd appreciate it.
Thanks.
Inserted Code
#property copyright "Nondisclosure"
#property link "[url]http://no.link.yet[/url]"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width1 1
#property indicator_width2 1
extern int varPeriod=20;
extern int varBack=2;
int init()
{
double varHigh=High[iHighest(NULL,0,MODE_HIGH,varPeriod,varBack)];
double varLow=Low[iLowest(NULL,0,MODE_LOW,varPeriod,varBack)];
ObjectCreate("High Boundry",OBJ_HLINE,0,Time[0],varHigh);
ObjectCreate("Low Boundry",OBJ_HLINE,0,Time[0],varLow);
return(0);
}
int deinit()
{
ObjectsDeleteAll();
return(0);
}
int start()
{
bool varNewBar=funcIsNewBar(0);
if (varNewBar)
{
ObjectsDeleteAll();
double varHigh=High[iHighest(NULL,0,MODE_HIGH,varPeriod,varBack)];
double varLow=Low[iLowest(NULL,0,MODE_LOW,varPeriod,varBack)];
ObjectCreate("High Boundry",OBJ_HLINE,0,Time[0],varHigh);
ObjectCreate("Low Boundry",OBJ_HLINE,0,Time[0],varLow);
}
return(0);
}
bool funcIsNewBar(int timeFrame)
{
bool res=false;
// the array contains open time of the current (zero) bar
// for 7 (seven) timeframes
static datetime _sTime[7];
int i=6;
//Note: i below will be 6 or timeframe will be day.
switch (timeFrame)
{
case 1 : i=0; break;
case 5 : i=2; break;
case 15 : i=3; break;
case 30 : i=4; break;
case 60 : i=5; break;
case 240: break;
case 1440:break;
default: timeFrame = 1440;
}
//----
if (_sTime[i]==0 || _sTime[i]!=iTime(Symbol(),timeFrame,0))
{
_sTime[i] = iTime(Symbol(),timeFrame,0);
res=true;
}
//----
return(res);
}