Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

ptcman

Plot Previous Day Time Interval and Today's Time Interval

Recommended Posts

I'd like some help here, please.

 

I have the following formula:

 

inputs:
  todayStTime      (830),
  todayEnTime      (900),
  yesterdayStTime   (1430),
  yesterdayEnTime   (1500);

variables:
  dayCounter      (0),
  dayClose      (0),
  dayOpen      (0),
  //dayHigh      (-999999),
  //dayLow      (+999999),
  //prevDayHigh      (0),
  //prevDayLow      (0),
  //dayHigh      (0),
  //dayLow      (0),
  prevDayClose      (0),
  prevDayOpen      (0),
  prevClCounter      (0),
  prevTradeDay      (false),
  todayTradeDay      (false);

// confirms the beginning of the day with true/false conditions
if date <> date[1] then begin
  prevTradeDay = true;
  todayTradeDay = false;
  dayCounter = dayCounter + 1;
end;

// resets the new day to give the previous day open time interval
if prevTradeDay then begin
  if time = yesterdayStTime then begin
     prevTradeDay = false;
     prevDayOpen = Open;
  end;
end;

// resets the new day to give today's open time interval
if todayTradeDay = false then begin
  if time >= todayStTime then begin
     todayTradeDay = true;
     dayOpen = Open;
  end;
end;

// resets the new day to give the previous day close time interval
if prevTradeDay then begin
  if time = yesterdayEnTime then begin
     prevTradeDay = false;
     prevDayClose = close;
  end;
end;

// resets the new day to give today's close time interval
if todayTradeDay = false then begin
  if time = todayEnTime then begin
     todayTradeDay = true;
     dayClose = close;
  end;
end;


plot1(DayOpen);
//plot2(dayClose);
plot13(prevDayOpen);
//plot14(prevDayClose);

 

 

I want to plot yesterday's open and close prices based on the time interval selected in the input and also, today's open and close prices also, based on the time interval selected in the input.

 

As it is, plots today's open and yesterday open prices, but If I also plot today's and yesterday's close prices, these will be zero, though, if I remove the statements regarding the opening prices, the close prices will be correctly plotted.

 

What am I doing wrong?

 

Please see attached images.

 

Thank you.

5aa710403adf4_closepricesonly.thumb.png.306a26dbd64abb1facd6ab4302329a16.png

5aa71040404bf_openandcloseprices.thumb.png.1e8b11ef3725e6ac496be3ba5a61d8f9.png

5aa710404537d_openpricesonly.thumb.png.7b4da1b843347bcb6f8139bb8f1bda45.png

Share this post


Link to post
Share on other sites
I'd like some help here, please.

 

I have the following formula:

...

What am I doing wrong?

 

Please see attached images.

 

Thank you.

 

can you do a mock up?

ie draw some lines and write some notes on the chart to illustrate how you envision the plots.

Edited by Tams

Share this post


Link to post
Share on other sites

Hi Tams

 

OK, in the image you can see both open and close prices on the same chart because I used 2 indicators since the problem is that together (open statements and close statements), the close statements don't work (they plot a zero price).

 

How the lines are plotted have no interest to me.

What I want is to be able to use yesterday's open and close prices, based on the time interval chosen, and do whatever calculations I want with today's open and close prices also based on the time interval chosen.

 

Example:

If yesterday last trading hour the close was higher than the open
then, if today's open is higher (or lower) than yesterday's close
then, what is the probability (in percentage) of today's first hour
close to be higher (or lower) than today's open.

 

Regards

image.thumb.gif.ca1e798476e4a24f34fbf39dab640136.gif

Share this post


Link to post
Share on other sites

If yesterday last trading hour the close was higher than the open
then, if today's open is higher (or lower) than yesterday's close
then, what is the probability (in percentage) of today's first hour
close to be higher (or lower) than today's open.

 

you have to learn to

think one thought at a time

write one thing per sentence

and code one action per line

if you have more than one action on the same line

you are going to get the computer confused.

Share this post


Link to post
Share on other sites

I don't know what are all the resets about...

if you just assign the open and the close,

you have all the variables to do

whatever analysis you want.

 

 

if time = yesterdayStTime then
     prevDayOpen = Open;

if time = todayStTime then 
     dayOpen = Open;

if time = yesterdayEnTime then 
     prevDayClose = close;

if time = todayEnTime then 
     dayClose = close;

Share this post


Link to post
Share on other sites

you have to learn to

think one thought at a time

write one thing per sentence

and code one action per line

if you have more than one action on the same line

you are going to get the computer confused.

 

But Tams.......

 

I did that.

 

I wrote:

 

// resets the new day to give the previous day open time interval
if prevTradeDay then begin
  if time = yesterdayStTime then begin
     prevTradeDay = false;
     prevDayOpen = Open;
  end;
end;

 

then...

 

// resets the new day to give today's open time interval
if todayTradeDay = false then begin
  if time >= todayStTime then begin
     todayTradeDay = true;
     dayOpen = Open;
  end;
end;

 

then...

 

// resets the new day to give the previous day close time interval
if prevTradeDay then begin
  if time = yesterdayEnTime then begin
     prevTradeDay = false;
     prevDayClose = close;
  end;
end;

 

then...

 

// resets the new day to give today's close time interval
if todayTradeDay = false then begin
  if time = todayEnTime then begin
     todayTradeDay = true;
     dayClose = close;
  end;
end;

 

Each statement plot the requested data.

The problem is that when they are plotted together, something happens with the close statements.

 

The "something" is the problem......

Share this post


Link to post
Share on other sites
But Tams.......

 

The problem is that when they are plotted together, something happens with the close statements.

 

The "something" is the problem......

 

I am not following,

can you use the arrow to point out the problem area on the chart?

Share this post


Link to post
Share on other sites

Using the indicator as show below:

 

inputs:
todayStTime		(830),
todayEnTime		(900),
yesterdayStTime	(1430),
yesterdayEnTime	(1500);

variables:
dayCounter		(0),
dayClose		(0),
dayOpen		(0),
//dayHigh		(-999999),
//dayLow		(+999999),
//prevDayHigh		(0),
//prevDayLow		(0),
//dayHigh		(0),
//dayLow		(0),
prevDayClose		(0),
prevDayOpen		(0),
prevClCounter		(0),
prevTradeDay		(false),
todayTradeDay		(false);

// confirms the beginning of the day with true/false conditions
if date <> date[1] then begin
prevTradeDay = true;
todayTradeDay = false;
dayCounter = dayCounter + 1;
end;

// resets the new day to give the previous day open time interval
if prevTradeDay then begin
if time = yesterdayStTime then begin
	prevTradeDay = false;
	prevDayOpen = Open;
end;
end;

// resets the new day to give today's open time interval
if todayTradeDay = false then begin
if time >= todayStTime then begin
	todayTradeDay = true;
	dayOpen = Open;
end;
end;

// resets the new day to give the previous day close time interval
if prevTradeDay then begin
if time = yesterdayEnTime then begin
	prevTradeDay = false;
	prevDayClose = close;
end;
end;

// resets the new day to give today's close time interval
if todayTradeDay = false then begin
if time = todayEnTime then begin
	todayTradeDay = true;
	dayClose = close;
end;
end;


plot1(DayOpen);
plot2(dayClose);
plot13(prevDayOpen);
plot14(prevDayClose);

 

The result can be seen on the attached image.

That is the problem.

Both closes (today and yesterday) are plotted with a value of zero.

 

Regarding the resets, don't I need to reset for each day the open and close prices? How can the computer recognize which open and close am I referring to?

image02.gif.90de0720f18c1e170d7c636eed104ef2.gif

Share this post


Link to post
Share on other sites
...Regarding the resets, don't I need to reset for each day the open and close prices? How can the computer recognize which open and close am I referring to?

 

the indicator evaluates the chart one bar at a time... from bar #1.

 

when the indicator arrives at a bar

where time = yesterdayStTime ,

prevDayOpen will be assigned with the that bar's Open price.

 

... and so on.

 

 

when the indicator encounters time = yesterdayStTime again,

it will be a new day,

and the variable will be reassigned with the new bar's price.

That's why no additional reset is necessary.

Share this post


Link to post
Share on other sites

Thanks for the explanation Tams, but....

 

If you plot what you wrote:

 

if time = yesterdayStTime then
     prevDayOpen = Open;

if time = todayStTime then 
     dayOpen = Open;

if time = yesterdayEnTime then 
     prevDayClose = close;

if time = todayEnTime then 
     dayClose = close;

 

... you'll see that today's open will plot zero.

 

I reset today's date...

 

if date <> date[1] then begin
todayTradeDay = true;
end;

if todayTradeDay then begin
if time >= todayStTime then begin
	todayTradeDay = false;
	dayOpen = Open;
end;
end;

 

... to see if that would resolve the problem, but when I compile it, today's open plotted OK, but today's open plotted zero.

 

:confused: :doh:

 

Why when we resolve the problem of one plot, another one creates another problem?

 

:crap:

Share this post


Link to post
Share on other sites
Thanks for the explanation Tams, but....

...

... to see if that would resolve the problem, but when I compile it, today's open plotted OK, but today's open plotted zero.

 

:confused: :doh:

 

Why when we resolve the problem of one plot, another one creates another problem?

 

:crap:

 

 

make sure these are valid times on your chart:

 

inputs:
  todayStTime      (830),
  todayEnTime      (900),
  yesterdayStTime   (1430),
  yesterdayEnTime   (1500);

 

 

TradeStation/MaultiCharts (and many other charting software) uses EOB (End Of Bar) time as bar reference.

 

ie.

on a 1 min chart,

if the starting time on your 1st bar is 8:30am,

then your todayStTime should be 831.

 

on a 5 min chart,

if the starting time on your 1st bar is 8:30am,

then your todayStTime should be 835

Edited by Tams

Share this post


Link to post
Share on other sites

TradeStation/MaultiCharts (and many other charting software) uses EOB (End Of Bar) time as bar reference.

 

ie.

on a 1 min chart,

if the starting time on your 1st bar is 8:30am,

then your todayStTime should be 831.

 

on a 5 min chart,

if the starting time on your 1st bar is 8:30am,

then your todayStTime should be 835

 

 

 

Yes Tams,

 

that was the problem with today's open price

 

This is surely one of those problem that almost everyone steps on when dealing with time, no?

 

regards and many thanks for your help

Share this post


Link to post
Share on other sites
Yes Tams,

 

that was the problem with today's open price

 

This is surely one of those problem that almost everyone steps on when dealing with time, no?

 

regards and many thanks for your help

 

yw.

 

 

Time is a challenge in programming...

 

wait till you try to add 1 day to 20101030,

or subtract 10 mins from 1005.

 

;-)>

Share this post


Link to post
Share on other sites
the indicator evaluates the chart one bar at a time... from bar #1.

 

when the indicator arrives at a bar

where time = yesterdayStTime ,

prevDayOpen will be assigned with the that bar's Open price.

 

... and so on.

 

 

when the indicator encounters time = yesterdayStTime again,

it will be a new day,

and the variable will be reassigned with the new bar's price.

That's why no additional reset is necessary.

 

Tams,

 

Is it possible for you do give and explanation with simple examples when we need (must) use resets and when that is not a necessary?

 

Also, it would be nice to know the many (?) ways to reset variables.

 

Regards

Share this post


Link to post
Share on other sites
yw.

 

 

Time is a challenge in programming...

 

wait till you try to add 1 day to 20101030,

or subtract 10 mins from 1005.

 

;-)>

 

:eek:

 

Saying that to a guy that considers time as the most important thing after price.....

 

You really want me to have nightmares during this year Halloween

 

:roll eyes:

Share this post


Link to post
Share on other sites

What I want is to be able to use yesterday's open and close prices, based on the time interval chosen, and do whatever calculations I want with today's open and close prices also based on the time interval chosen.

 

Regards

 

pctman,

 

You have piqued my curiosity.

 

What "do" you want to do with the resulting chart/data.

 

For instance.... I can think of one thing someone may want to do. If you only traded,say, the first two hours in the morning... and wanted a simple historical look at the range and volume, just during that time frame.... this would be a quick birds eye view way to get it.

 

What type of applications are you interested in exploring with this?

 

snowbird

Share this post


Link to post
Share on other sites
Tams,

 

Is it possible for you do give and explanation with simple examples when we need (must) use resets and when that is not a necessary?

 

Also, it would be nice to know the many (?) ways to reset variables.

 

Regards

 

if time = xxx then...

is a form of reset.

 

it resets the variable to a new value if the time meets a criteria.

Share this post


Link to post
Share on other sites
pctman,

 

You have piqued my curiosity.

 

What "do" you want to do with the resulting chart/data.

 

For instance.... I can think of one thing someone may want to do. If you only traded,say, the first two hours in the morning... and wanted a simple historical look at the range and volume, just during that time frame.... this would be a quick birds eye view way to get it.

 

What type of applications are you interested in exploring with this?

 

snowbird

 

 

Hi snowbird.

 

Yes, that is one of the ways we can use the data retrieved from the indicator, but countless others may be used. Our imagination is the limit.

 

I don't believe in automatic systems.

I believe in strategies, in probabilities, in statistics, all due to past behaviour.

 

I believe that "today's" trading day should be divided in 2 halves.

The first half is the conclusion of the previous trading day. All trades/businesses that couldn't be done til the end of yesterday trading the day, will be closed at the beginning of today's trading day.

There are many reasons for this to happen, the majority due to our own behaviour, human behaviour.

 

The second half, well, the same pattern repeats itself. The second half will initiate new trading business that will be closed... the next day.

 

Naturally that we are speaking of very short term trading / daytrading, an area where, when things are well studied and structured, can generate a very nice monthly income till the end of our lives.

 

I try mainly to follow human psychology and incorporate that into time and prices. There are periods when time is a factor far more important than the price itself.

 

The beginning of an hour, a day, a week, a month, a quarter. The end of an hour, a day, a week, a month, a quarter. These are all time periods that have importance for us humans, in all aspects of our lives.

We don't have the notion of it, but we react to all of this in one way or the other. This creates patterns that can be exploited.

 

There are studies saying that the first day of every month, mainly in the S&P500, but also tested with good results in the German DAX, has a very, very high probability of being a positive day (I'm not certain but I think the reading was made on a close to close basis).

Now, knowing this, we can try to exploit it, but through other ways (ie. psychological ways).

Analysing only the close is misleading. We should analyse the highest and the lowest points where traders were able to push prices. These will show the real strength behind of each move.

OK, the first day of the month tends to be positive, but when that happened, how the first half of the day traded relatively to the previous day?

 

Naturally, before we can answer that, we must first determined the time period for each half of the day?

Can we consider noon the time that should divide each half?

There are readings that lunch time should be the one to be considered, which spans between 11:30 am to 1:00 pm (EST).

 

I confess that a lunch time period makes perfect sense since we humans, when dealing with other humans, we tend to share experiences, ideas, thoughts that, although we try not to be influenced by them, by the simple fact that we took knowledge of it, they will be taken in consideration in one way or another. Also, humans, we need time to absorb all news things that are brought to us.

 

Time must always be taken in consideration.

Example: the markets are acting weird, not really making sense, we have a position that is laying there, and lunch time is arriving. We decide to close it, so we can enjoy the lunch period without the morning stress. During lunch we heard an idea, a gossip, some news event just been released. Traders come from lunch to see how the markets reacted to that period, hence, the beginning of the second half period.

 

All of this are ideas that MUST be studied and structured before any trade can be executed.

 

 

Regards.

Share this post


Link to post
Share on other sites

Can we consider noon the time that should divide each half?

There are readings that lunch time should be the one to be considered, which spans between 11:30 am to 1:00 pm (EST).

 

I confess that a lunch time period makes perfect sense since we humans, when dealing with other humans, we tend to share experiences, ideas, thoughts that, although we try not to be influenced by them, by the simple fact that we took knowledge of it, they will be taken in consideration in one way or another. Also, humans, we need time to absorb all news things that are brought to us.

 

Time must always be taken in consideration.

 

Your response confirmed many of my own thoughts... Now I'm going to have to see if I can get the code working on TS to start the analysis (which is is the fun part for me!). If it works, I personally will start with three periods (treating the eastern "lunch" session 11:30 to 1) initially as a separate period. My expectations of this period, would of course be different than the other two. I would expect lower volume, consolidations, market drifting in the "general" direction of the "pre-lunch" session etc. Don't know yet... but if the opposite occurs... "high volume", "large range", "dramatic price reversal", etc., I imagine that there could be some "learnings" from those situations (what was so important to keep traders engaged during lunch!)

 

Questions I currently have about the morning and afternoon sessions... do they have different characteristics in up vs down markets? What does a high volume afternoon session tell you in terms of probabilities/expectations for the morning session, etc.

 

I'd be willing to post findings, if any. I believe this could be a cool thread if others are interested as well.

 

snowbird

Share this post


Link to post
Share on other sites

Hi snowbird.

 

You really catch the idea.

But this is just the beginning, a very small part of a much bigger picture.

 

When dealing with futures, we MUST include the overnight session.

Even if we only trade the floor session, 9:30 am to 4:00 pm EST, what prices did during the overnight MUST be taken in consideration.

 

Why do prices retest the overnight high or low the majority of time during the floor session when prices are trading outside of that range? Why traders like to confirm those values?

 

Also, if we trade the ES futures, despite the prices being traded accordingly to the supply and the demand of it at that moment, prices are still indexed to the cash market, hence, to the 500 stocks that constitute the index, meaning that the big caps performance not only make the cash market move, but also the futures.

For this I like to follow the S&P500 GICS sector indices. The big four are Technology, Finance, Healthcare and Consumer Staples.

 

The premise here is that following the sectors we are able to confirm the S&P movements, hence, the ES movements.

There are people that prefer to use the industries instead of the sector due to their ability in grouping companies that really operate in the same industry, like Banks, Brokers, Semiconductors, Software and so forth.

 

The easiest way to do this, and in real time, is to use their ETF's counterparts since the S&P doesn't distribute the GICS indices in realtime to any data provider.

 

Note that all of this must be analysed always taking human psychology in consideration. Behind each price movement exists people, traders with fears, hopes, expectations that must be reached in X time.

When they aren't met, emotions take control and these same emotions leave marks on the charts that can be measured by the length of the move.

 

Regards

Edited by ptcman

Share this post


Link to post
Share on other sites

well said

 

I often struggle with the "bigger picture"

especially in this new connected world where news. policy and government decisions across continents can affect inter-related markets, often instantly and opposite to 'expectations"

 

I'm sure this is why so many of the experts on this forum recommend beginner traders start out and focus on:

 

1 market or

1 system or

1 chart pattern or

1 time of day or

1 quantifiable edge or

price only/order flow only/etc.

 

in essence... the goal is to be able to understand a particular aspect of human emotion that repeatedly drives a market behavior one can both recognize, and potentially profit from.

 

snowbird

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.