PureBytes Links
Trading Reference Links
|
A few months ago I was trying to plot support and resistance levels
calculated from day session start and finish times using ES 24hr data,
but and I found the DayHigh and DayLow functions calculate the
beginning of the day at midnight, so I wrote it to calculate using the
correct start and finish times.
If anybody else is interested here is the code and ela.
Merry Christmas
Nevi
{Writen using ES - Emini S&P data}
{indicator S&R intraday pivot}
vars: getlow(0), gethigh(0), dailyclose(c), pivot(c);
if currentbar >1 then begin
if time crosses over sess1starttime then getlow=low else
if low < getlow[1] then getlow=low; {calculates dailylow}
if time crosses over sess1starttime then gethigh=high else
if high > gethigh[1] then gethigh = high; {calculates dailyhigh}
end;
begin
if time crosses over sess1endtime then
dailyclose=close[1] else dailyclose=dailyclose[1];
end; {stores endtime close through the next day}
if time crosses over sess1endtime then begin
pivot= ((gethigh+getlow+dailyclose)/3);
end;
begin
if time > sess1starttime and time <= sess1endtime then
plot1(gethigh,"gethigh"); {shows highs in dailyhigh calculation}
if time > sess1starttime and time <= sess1endtime then
plot2(getlow,"getlow"); {shows lows in dailylow calculation}
if time crosses over sess1endtime-1 then begin
plot3 (close,"dailyclose"); {time crosses sess1endtime-1 allows this to plot on the last bar on
chart, this plots the same as dailyclose = close[1] above }
end;
plot4 (pivot,"pivot");
end;
************************************************************
{indicator S&R intraday}
vars: getlow(0), gethigh(0), dailylow(0), dailyhigh(0), dailyclose(0), pivot(0), supp1(0), resis1(0), supp2(0), resis2(0);
if currentbar >1 then begin
if time crosses over sess1starttime then getlow=low else
if low < getlow[1] then getlow=low; {calculates dailylow}
if time crosses over sess1starttime then gethigh=high else
if high > gethigh[1] then gethigh = high; {calculates dailyhigh}
end;
begin
if time crosses over sess1endtime then dailylow=getlow[1];
if time crosses over sess1endtime then dailyhigh=gethigh[1];
end;
begin
if time crosses over sess1endtime then
dailyclose=close[1] else dailyclose=dailyclose[1];
end; {stores endtime close through the next day}
if time crosses over sess1endtime then begin
pivot= ((dailyhigh+dailylow+dailyclose)/3);
end;
begin
resis2 = (pivot+ (dailyhigh - dailylow));
resis1 = 2*pivot-dailylow;
supp1 = 2*pivot-dailyhigh;
supp2 = (pivot- (dailyhigh - dailylow));
end;
if supp2>(low-10000) then begin {prevents plotting while plots are initializing}
plot1 (resis2,"resis2");
plot2 (resis1,"resis1");
plot3 (supp1,"supp1");
plot4 (supp2,"supp2");
end;
{
resis2 = pivot plus (resis1 minus supp1)
resis1 =(two times pivot) minus dailylow
pivot = (dailyhigh plus dailylow plus dailyclose) divided by 3
supp1 = (two times pivot) minus dailyhigh
supp2 = pivot minus (resis1 minus supp1)
} Attachment:
S&Rintra.ELA
Description: Binary data
|