Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 07-04-2009, 03:55 AM   #1

Join Date: Jun 2009
Location: BFE
Posts: 10
Ignore this user

Thanks: 5
Thanked 2 Times in 2 Posts

EL: Get High of a Bar from a Specific Time Yesterday

Hello, ... first post here. I just started using tradestation and EL today. I'm working on a very simple strategy for the sake of understanding the basics.

I'm trying to figure out 2 things:

1. How can I get the high of a bar at a specific time
2. How can I run a piece of logic at a specific time?

For example:

At 10:30am, I'd like to get the high of the 3:30 bar yesterday to compare, and place a buy order based on the results.


Makes no sense, but just trying to understand how to work with bar times.
TraderFoo is offline  
Reply With Quote
Old 07-06-2009, 01:06 AM   #2

Join Date: Jun 2009
Location: BFE
Posts: 10
Ignore this user

Thanks: 5
Thanked 2 Times in 2 Posts

Re: EL: Get High of a Bar from a Specific Time Yesterday

i actually got this figured out over the weekend.

Code:
variables yesterdaysHigh(0);

// if time is 10am
if Time = 1530 then
  yesterdaysHigh = High;

if Time = 1000 then
  // do something with yesterdaysHigh
TraderFoo is offline  
Reply With Quote
The Following User Says Thank You to TraderFoo For This Useful Post:
Tams (07-06-2009)
Old 11-03-2009, 01:22 AM   #3

Join Date: Nov 2008
Location: Orel
Posts: 33
Ignore this user

Thanks: 5
Thanked 4 Times in 2 Posts

Re: EL: Get High of a Bar from a Specific Time Yesterday

And is it possible to get the highest high for a period of time?
I mean something like this:
if time > 10:00 and time < 15:00 then the highest high for that period is 'HH'.
GRANDEUR is offline  
Reply With Quote
Old 11-03-2009, 07:55 AM   #4

Join Date: Jan 2008
Location: San Francisco
Posts: 394
Ignore this user

Thanks: 17
Thanked 338 Times in 156 Posts

Re: EL: Get High of a Bar from a Specific Time Yesterday

This is indicator version -- I plotted it as a 'point' on a chart

//create variables
//store the 'bar count' in the variable using 'currentbar' keyword

Quote:
vars: startbar(0), endbar(0), length(0);

if time=1000 then startbar=currentbar;

if time<=1100 then endbar=currentbar;

length=endbar-startbar;

if time>1000 and time<=1100 then begin
value1=highest(high, length);

plot1(value1,"HH");
end;
Frank is offline  
Reply With Quote
Old 11-03-2009, 01:16 PM   #5

Join Date: Nov 2008
Location: Orel
Posts: 33
Ignore this user

Thanks: 5
Thanked 4 Times in 2 Posts

Re: EL: Get High of a Bar from a Specific Time Yesterday

Frank, thank you for your reply!
I've changed the code according to your advice. Here is what happened:

vars: startbar(0), endbar(0), length(0);

if time=1030 then startbar=currentbar;
if time<=1039 then endbar=currentbar;

length=endbar-startbar;

if time>1039 and time<=1100 then Buy next bar at highest(h,length) stop;
if marketposition=1 and time=1200 then sell next bar at market;


If I followed your words correctly, it doesn't work as intended. There are trades between 1040 and 1100 but they are executed not at the high of the price range between 1030 and 1039. (I couldn't even figure out how 'get in' price is calculated).
Could you, please, check my code again?
GRANDEUR is offline  
Reply With Quote
Old 11-03-2009, 02:07 PM   #6

Join Date: Jan 2008
Location: San Francisco
Posts: 394
Ignore this user

Thanks: 17
Thanked 338 Times in 156 Posts

Re: EL: Get High of a Bar from a Specific Time Yesterday

hi Grandeur,

I can't be sure what it is you want to do but I can give you some idea how EL reads bars. study this and see if you can convert it to what you want. If not, give it an honest attempt and I will try again.

you have to think about the word 'length' here. length was moving target in your last code because endbar was equal to current bar. so I changed it to 'lock' the variable 'length' to a specific time. see if you can see the adjustment I made --- by using the variable 'value1' -- I am able to lock-in the highest price that was set during the specific time period you chose.


Quote:
vars: startbar(0), endbar(0), length(0);

if time=1030 then startbar=currentbar;
if time<=1100 then endbar=currentbar;

length=endbar-startbar;

if time>1039 and time<=1100 then value1= highest(h,length);

if time>1039 and time<1200 then Buy next bar at value1 stop;
if marketposition=1 and time=1200 then sell next bar at market;
Frank is offline  
Reply With Quote
Old 11-03-2009, 03:55 PM   #7

Join Date: Nov 2008
Location: Orel
Posts: 33
Ignore this user

Thanks: 5
Thanked 4 Times in 2 Posts

Re: EL: Get High of a Bar from a Specific Time Yesterday

Yes, Frank, you're absolutely right! I want to lock the variable 'length'. (At first, I tested with 'value1' but overlooked and came to the thought it is the same as without it).
The code you wrote works fine but how can I avoid repeated trades when I add stoplosses and they are executed?
GRANDEUR is offline  
Reply With Quote
Old 11-03-2009, 04:23 PM   #8

Join Date: Jan 2008
Location: San Francisco
Posts: 394
Ignore this user

Thanks: 17
Thanked 338 Times in 156 Posts

Re: EL: Get High of a Bar from a Specific Time Yesterday

try this for n entries (3):

and entriestoday(date)<3

Quote:
vars: startbar(0), endbar(0), length(0);

if time=1030 then startbar=currentbar;
if time<=1100 then endbar=currentbar;

length=endbar-startbar;

if time>1039 and time<=1100 then value1= highest(h,length);

if time>1039 and time<1200 and entriestoday(date)<3 then Buy next bar at value1 stop;
if marketposition=1 and time=1200 then sell next bar at market;
Frank is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
I Want Alerts Based on Specific Parameters? Johnson S. Mcdermott Trading and the Markets 5 06-08-2009 04:39 PM
Tried to Move OEC Specific Posts to This Area brownsfan019 Open E Cry 0 02-03-2009 09:56 AM
Need to Rewrite Specific Macd from MQL or MultiChart for NT backfoot Automated Trading 2 09-05-2008 01:24 PM
Who Caught This Yesterday? james_gsx The Candlestick Corner 14 08-13-2008 11:50 PM
Be Specific: Precisely What Are You Doing Wrong? MrPaul Market Analysis 4 11-14-2006 06:58 PM

All times are GMT -4. The time now is 01:30 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.