Yesterdays OHLC
Posted: Jul 18 2008
I am wondering if there is a study in MC that will plot yesterdays open, close, high & low?
Thanks,
Simon
Thanks,
Simon
MultiCharts
https://www.multicharts.com/discussion/
Code: Select all
{ Bob Perry 09/2007
Close of Yesterday: Cyan, point, weight=3
Open of today: White, point, weight=3
Intraday Highest High, Lowest Low: red/green cross
Yesterday Highest High, Lowest Low: red/green dot
}
Inputs: PriceLev(1.00), True_C1(0);
Vars: Reset(0), CCval(C), SpacerTxt(" "),
C1val(C), O1val(C), HHval(C), LLval(C), H1val(C), L1val(C),
C1ref(-1), O1ref(-1), HHref(-1), LLref(-1), H1ref(-1), L1ref(-1) ;
// Initialize Variables
If Date <> Date[1] then Reset = 0;
If time >= SessionStartTime(1,2) and time <= SessionEndTime(1,2) then begin
If Reset = 0 then begin
C1val = CCval;
H1val = HHval;
L1val = LLval;
HHval = 0;
LLval = 999999;
Reset = 1;
End;
HHval = IFF(High>HHval,High,HHval);
LLval = IFF(Low<LLval,Low,LLval);
CCval = IFF(True_C1=0,Close,True_C1);
If Reset = 1 then O1val = Open;
Reset = 2;
End;
// Plots
If (AbsValue(O1val-H) < PriceLev) or (AbsValue(L-O1val) < PriceLev) then begin
Plot1(O1val,"OpenToday");
If Date = CurrentDate AND time_s >= LastCalcSSTime then begin
If O1ref <> -1 Then Text_SetLocation_s(O1ref, Date, Time_s, O1val)
Else Begin
O1ref = Text_New_s(Date, Time_s, O1val, SpacerTxt + "Open");
Text_SetStyle(O1ref, 0, 2);
Text_SetColor(O1ref, white) ;
End;
End;
End;
If (AbsValue(C1val-H) < PriceLev) or (AbsValue(L-C1val) < PriceLev) then begin
Plot2(C1val,"Close[1]");
If Date = CurrentDate AND time_s >= LastCalcSSTime then begin
If C1ref <> -1 Then Text_SetLocation_s(C1ref, Date, Time_s, C1val)
Else Begin
C1ref = Text_New_s(Date, Time_s, C1val, SpacerTxt + "C1");
Text_SetStyle(C1ref, 0, 2);
Text_SetColor(C1ref, cyan) ;
End;
End;
End;
If HHval-H <= PriceLev then Begin
Plot3(HHval, "HH");
If Date = CurrentDate AND time_s >= LastCalcSSTime then begin
If HHref <> -1 Then Text_SetLocation_s(HHref, Date, Time_s, HHval)
Else Begin
HHref = Text_New_s(Date, Time_s, HHval, SpacerTxt + "HH");
Text_SetStyle(HHref, 0, 2);
Text_SetColor(HHref, green) ;
End;
End;
End;
If L-LLval <= PriceLev then Begin
Plot4(LLval, "LL");
If Date = CurrentDate AND time_s >= LastCalcSSTime then begin
If LLref <> -1 Then Text_SetLocation_s(LLref, Date, Time_s, LLval)
Else Begin
LLref = Text_New_s(Date, Time_s, LLval, SpacerTxt + "LL");
Text_SetStyle(LLref, 0, 2);
Text_SetColor(LLref, RGB(255,0,0) ) ;
End;
End;
End;
// Alerts
If H > HHval[1] or L < LLval[1] then Alert;
// Yesterdays HH and LL
If AbsValue(H1val-H) <= PriceLev then Begin
Plot5(H1val, "HH[1]");
If Date = CurrentDate AND time_s >= LastCalcSSTime then begin
If H1ref <> -1 Then Text_SetLocation_s(H1ref, Date, Time_s, H1val)
Else Begin
H1ref = Text_New_s(Date, Time_s, H1val, SpacerTxt + "HH[1]");
Text_SetStyle(H1ref, 0, 2);
Text_SetColor(H1ref, RGB(0,128,0)) ;
End;
End;
End;
If AbsValue(L-L1val) <= PriceLev then Begin
Plot6(L1val, "LL[1]");
If Date = CurrentDate AND time_s >= LastCalcSSTime then begin
If L1ref <> -1 Then Text_SetLocation_s(L1ref, Date, Time_s, L1val)
Else Begin
L1ref = Text_New_s(Date, Time_s, L1val, SpacerTxt + "LL[1]");
Text_SetStyle(L1ref, 0, 2);
Text_SetColor(L1ref, RGB(139,0,0)) ;
End;
End;
End;
// - - - EOF - - -
Code: Select all
Input: Lookback(1);
var: HH(0),LL(0);
var: PlotEndTime(2200),StartTime(0800), EndTime(2200),
Linie1(0),Linie2(0),Linie3(0);
HH = HighestD(Lookback);
LL = LowestD (Lookback);
plot1(HH,"HH",RGB(128,128,255));
plot2(LL,"LL",RGB(255,104,032));
{Trendlines:
Linie1 = TL_New(date,StartTime,HH,date,EndTime,HH);
Linie2 = TL_New(date,StartTime,LL,date,EndTime,LL);
TL_Setcolor(Linie1,RGB(128,128,255));
TL_Setcolor(Linie2,RGB(255,104,032));
}
Code: Select all
vars: oPeriodOpen(0), oPeriodHigh(0), oPeriodLow(0), oPeriodClose(0);
Value1 = OHLCPeriodsAgo(1, 1, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose);
Value2 = oPeriodHigh;
Value3 = oPeriodLow;
Plot1(Value2,"H");
Plot2(Value3,"L");
Great, I did not know those were working again. That makes it even easier!Meant to add, that I had to substitute LowD & HighD for LowestD & HighestD
Code: Select all
// Initialize Variables
If Date <> Date[1] then Reset = 0;
If time >= SessionStartTime(1,2) and time <= SessionEndTime(1,2) then begin
If Reset = 0 then begin
C1val = CCval;
H1val = HHval;
L1val = LLval;
HHval = 0;
LLval = 999999;
Reset = 1;
End;
HHval = IFF(High>HHval,High,HHval);
LLval = IFF(Low<LLval,Low,LLval);
CCval = IFF(True_C1=0,Close,True_C1);
If Reset = 1 then O1val = Open;
Reset = 2;
End;
This is interesting..
I've just built Floor Traders Pivot, using
OpenD(1)
HighD(1)
LowD(1)
CloseD(1)
And it seems to work just fine Have I missed something?