Yesterdays OHLC

Questions about MultiCharts and user contributed studies.
kelly simon
Posts: 45
Joined: 31 Jan 2008

Yesterdays OHLC

Postby kelly simon » 18 Jul 2008

I am wondering if there is a study in MC that will plot yesterdays open, close, high & low?

Thanks,
Simon

User avatar
TJ
Posts: 6583
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Postby TJ » 18 Jul 2008

this can easily be done.

just use the plot keyword with the [1] offset...

e.g.

plot1[1](open, "Open");
plot2[1](high, "High");
plot3[1](low, "Low");
plot4[1](close, "Close");

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 12 times
Contact:

Postby RobotMan » 18 Jul 2008

If you are using intraday data, I used to be able to use
OpenD(1)
HighD(1)
LowD(1)
CloseD(1)
For yesterday's OHLC in TS, but this does not seem to work in MC.

And don't even try
DailyOpen
DailyHigh
DailyLow
DailyClose
They're pretty useless.

So, you need to write code that references the prior intraday data.
Here's some sample code that might get you close. It does not check overnight data, I have another similar indicator that does that. And oh, BTW, I use it on emini tick data, not on stocks.

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 - - -


I know that seems a lot more complicated than OpenD, HighD etc. But that is the way it is. Maybe Marina or Andrew know an easier way.

Hope that helps,
Bob Perry
Los Altos, CA

wullenweber helmut
Posts: 51
Joined: 21 Dec 2007
Has thanked: 1 time
Been thanked: 9 times

Postby wullenweber helmut » 19 Jul 2008

Here´s a code to plot yesterdays high & low to intraday charts. Alternative to the plot function you can use the code in brackets to show trendlines, until MC will able to plot flatlines via plot function. Working with trendlines your charts will look better, but it loads your CPU.

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));
}



User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 22 Jul 2008

You can also try the OHLCPeriodsAgo function.

kelly simon
Posts: 45
Joined: 31 Jan 2008

Postby kelly simon » 29 Jul 2008

Thanks wullenweber - works a treat.

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 12 times
Contact:

Postby RobotMan » 29 Jul 2008

I couldn't get HighestD(Lookback) and LowestD (Lookback) to compile in the PLE.

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");


Seems to work ok though.

MC 3.1.1353.400

Bob Perry
Los Altos, CA

kelly simon
Posts: 45
Joined: 31 Jan 2008

Postby kelly simon » 29 Jul 2008

Meant to add, that I had to substitute LowD & HighD for LowestD & HighestD

Simon

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 12 times
Contact:

Postby RobotMan » 29 Jul 2008

Meant to add, that I had to substitute LowD & HighD for LowestD & HighestD


Great, I did not know those were working again. That makes it even easier! :D

Bob Perry
Los Altos, CA

kelly simon
Posts: 45
Joined: 31 Jan 2008

Postby kelly simon » 31 Jul 2008

At present, what is plotting using wullenweber's code (using HighD & LowD), seems to actually be yesterdays high & low of the whole 24 hour period.

I am taking it that this is useful to have on charts, though I am after the actual open & close price as well.

With respect to the time periods - even if I change the window to Regular Hours (under format symbol), I am still seeing the whole 24 hour period of prices. I don't want to change the setting in symbol manager as I want the symbol set to 24 hours for other price windows.

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 12 times
Contact:

Postby RobotMan » 31 Jul 2008

Yeah, these globex markets, by definition are 24 hour. The open is only 15 minutes after the close. That is why I use my own code and initiate and terminate the data collection times. See big post of mine above for sample code.

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;


Now you just have the RTH pit traded hours and save the RTH H, L, C values from the day before. (I use a separate plot that shows the H and L from overnight.)

Bob Perry
Los Altos, CA

User avatar
Januson
Posts: 119
Joined: 18 Apr 2007
Location: Denmark

Postby Januson » 06 Aug 2008

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 :shock: Have I missed something?

User avatar
RobotMan
Posts: 375
Joined: 12 Jul 2006
Location: Los Altos, California, USA
Has thanked: 31 times
Been thanked: 12 times
Contact:

Postby RobotMan » 06 Aug 2008

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?



Excellent!

I was using 3.1.1353.400 and it did not work, but now I am trying 4.0.1440.201 and it works for me too!

Bob Perry
Los Altos, CA


Return to “MultiCharts”