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

Reply
Old 05-23-2010, 02:24 PM   #1

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

Thanks: 5
Thanked 4 Times in 2 Posts

Intraday Orders (EL)

Please, help me to code the following simple algorithm.
A new day begins. Then I want that a highest high (HH) of the day to be calculated. If a HH is created then I want to place my sell short stop next bar at X points below HH. The stop must be active till the end of the day until it's executed. An exit is at the end of the day. If the stop is not executed that day then the same condition but with new parameters takes place next day.
Here is a picture of what I'm telling about:
http://file.qip.ru/file/129903846/98.../Picture3.html

I was able to write a code that sells short only on the next bar after a HH is formed and the condition is fulfilled, but I want that my stop be active until the end of the day.

Last edited by GRANDEUR; 05-23-2010 at 02:29 PM.
GRANDEUR is offline  
Reply With Quote
Old 05-25-2010, 04:19 PM   #2

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

Thanks: 5
Thanked 4 Times in 2 Posts

Re: Intraday Orders (EL)

Come on guys, there must be someone who knows the answer on my question!
GRANDEUR is offline  
Reply With Quote
Old 05-25-2010, 05:25 PM   #3

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Intraday Orders (EL)

Quote:
Originally Posted by GRANDEUR »
Come on guys, there must be someone who knows the answer on my question!
write out your thoughts step by step,
line by line.

write them out one action at a time,
one action per line...
one action per line...
one action per line...
one action per line...

eventually you will get there.
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
TIKITRADER (05-25-2010)
Old 05-26-2010, 01:30 AM   #4

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

Thanks: 5
Thanked 4 Times in 2 Posts

Re: Intraday Orders (EL)

1. 30-min timeframe.
2. A new day begins (today).
3. If high of a bar > all previous highs of today so far then that high is 'highesthigh' (HH).
4. HH is calculated each bar during the day.
5. We place a sell short stop order at (HH - 50 points).
6. That stop must be active till the end of the day.
7. If the order is not executed next bar and a new HH is formed then we cancel the order and place a new sell short order with the parameters as in (5).
8. If the order is not executed till the end of the day then we cancel the order.
9. If the order is executed then we buy to cover at the end of the day.
10. Loop.
GRANDEUR is offline  
Reply With Quote
Old 05-26-2010, 02:33 AM   #5

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Intraday Orders (EL)

Quote:
Originally Posted by GRANDEUR »
....

I was able to write a code that sells short only on the next bar after a HH is formed and the condition is fulfilled, but I want that my stop be active until the end of the day.
if you don't post your work-in-progress,
are you expecting someone to do all the work for you?
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
Old 05-26-2010, 05:25 AM   #6

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

Thanks: 5
Thanked 4 Times in 2 Posts

Re: Intraday Orders (EL)

Sorry, I got it. I just edited #3 of the list above:
3.If high of a bar > all previous highs of today so far AND IT IS > (TODAY'S OPEN+100) then that high is 'highesthigh' (HH).

Here is what I wrote so far:
if time=0930 then value1=open;
if entriestoday(date)<1 and time>0930 and time<1630 and h>(value1+100) then value2=h;
if entriestoday(date)<1 and time>0930 and time<1630 and h>(value1+100)
then sell short next bar at (value2-50) stop;
if time>1630 then buy to cover next bar at market;

When I apply this code, trades are executed not at (HH-50) during the day but at (high [of the bar prior to entry]-50).
GRANDEUR is offline  
Reply With Quote
Old 05-27-2010, 03:00 PM   #7

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Intraday Orders (EL)

some house keeping first:

1. avoid using generic variables... ie value1, value2, etc.,
always create a meaningful variable names,
because you will come back to the code 3 months from now
and you have to scratch your head wondering what value101 is about.

you have mention HH, why are you not using it in your code?

2. tag your codes, so that it is easy for everybody to read

tagged codes look like this:

Code:
// This is tagged code

if time=0930 then value1=open;
if entriestoday(date)<1 and time>0930 and time<1630 and h>(value1+100) then value2=h;
if entriestoday(date)<1 and time>0930 and time<1630 and h>(value1+100)
then sell short next bar at (value2-50) stop;
if time>1630 then buy to cover next bar at market;
__________________



Only an idiot would reply to a stupid post

Last edited by Tams; 05-27-2010 at 03:18 PM.
Tams is offline  
Reply With Quote
Old 05-27-2010, 03:03 PM   #8

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: Intraday Orders (EL)

Quote:
Originally Posted by GRANDEUR »
1. 30-min timeframe.
2. A new day begins (today).
3. If high of a bar > all previous highs of today so far then that high is 'highesthigh' (HH).
4. HH is calculated each bar during the day.
5. We place a sell short stop order at (HH - 50 points).
6. That stop must be active till the end of the day.
7. If the order is not executed next bar and a new HH is formed then we cancel the order and place a new sell short order with the parameters as in (5).
8. If the order is not executed till the end of the day then we cancel the order.
9. If the order is executed then we buy to cover at the end of the day.
10. Loop.
Quote:
Originally Posted by GRANDEUR »
Sorry, I got it. I just edited #3 of the list above:
3.If high of a bar > all previous highs of today so far AND IT IS > (TODAY'S OPEN+100) then that high is 'highesthigh' (HH).

Here is what I wrote so far:
if time=0930 then value1=open;
if entriestoday(date)<1 and time>0930 and time<1630 and h>(value1+100) then value2=h;
if entriestoday(date)<1 and time>0930 and time<1630 and h>(value1+100)
then sell short next bar at (value2-50) stop;
if time>1630 then buy to cover next bar at market;

When I apply this code, trades are executed not at (HH-50) during the day but at (high [of the bar prior to entry]-50).
approach to coding...

your logic description (1st quote) should mirror the code (2nd quote),
so that you can go through the required tasks line-by-line.
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
TIKITRADER (05-27-2010)

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
Intraday 1minute Data for Nasdaq balapandian Trading and the Markets 3 06-21-2010 10:16 AM

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