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

Reply
Old 04-19-2009, 07:50 AM   #1

Join Date: Apr 2009
Location: ptr
Posts: 55
Ignore this user

Thanks: 30
Thanked 6 Times in 4 Posts

Help with My First Strategy

Hello all.

I've just bought Multicharts and I'm eager to start developing my own ideas for indicators and strategies based on those same indicators.

But I've a big problem, I'm not that good in programming

I'm able to understand most formulas but then, rearrange them or even rewrite them is a complete different world.

I've been trying to write my first strategy, but thinks haven't gone as aspected.

I thought I should begin with a simple buy order, but nothing happens.

Can anyone help understanding what is happening and why?

I'd appreciate all the help.

Thank you

Code:
{ *User Input*}
input : 
	length		(5);

{ *Variables*}
variables:
	dRng		(0),
	Mid		(0),
	Hi		(0),
	Lo		(0),
	Cl		(0),
	Vl		(0);

Hi = High;
Lo = Low;
Cl = Close;
dRng = Hi - Lo;
Mid = (Hi + Lo) * .5;
Vl = Volume;

{ *Buy order* }
if (Cl > Cl [1]) and (dRng > Average(dRng,length)) then begin
	if Vl > Average(Vl,length) then
		Buy ("break") next bar open;
		
end;
ptcman is offline  
Reply With Quote
Old 04-19-2009, 11:53 AM   #2

Join Date: Jun 2008
Location: Chicago
Posts: 15
Ignore this user

Thanks: 9
Thanked 2 Times in 2 Posts

Re: Help with My First Strategy

try "...next bar at open;"
rsi77 is offline  
Reply With Quote
Old 04-19-2009, 12:00 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: Help with My First Strategy

some suggestions:

1. no need to assign these values to variable. You can use them as is.
Hi = High;
Lo = Low;
Cl = Close;
Vl = Volume;


2. get this book
Building Winning Trading Systems with tradestation
Amazon.com: Building Winning Trading Systems with TradeStation: George Pruitt, John R. Hill: Books
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
JBWTrader (09-27-2009)
Old 04-19-2009, 12:04 PM   #4

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: Help with My First Strategy

Quote:
Originally Posted by ptcman »
...
I thought I should begin with a simple buy order, but nothing happens.
Can anyone help understanding what is happening and why?
I'd appreciate all the help.
Thank you...

replace the keyword volume with ticks.

Don't ask me why, in EasyLanguage...
the keyword volume means "total upticks" in English,
the keyword ticks means "total volume" in English.

Last edited by Tams; 04-19-2009 at 12:48 PM.
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
ptcman (04-19-2009)
Old 04-19-2009, 12:53 PM   #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: Help with My First Strategy

Quote:
Originally Posted by rsi77 »
try "...next bar at open;"

At is a Skip Word.

Skip Words serve solely to improve the readability of EasyLanguage code and are skipped (ignored) during the compilation and execution.

The use of Skip Words is optional; they can be inserted anywhere within the EL code and will appear red in Editor.
Tams is offline  
Reply With Quote
Old 04-19-2009, 03:22 PM   #6

Join Date: Apr 2009
Location: ptr
Posts: 55
Ignore this user

Thanks: 30
Thanked 6 Times in 4 Posts

Re: Help with My First Strategy

Hi.

Thank you all for your comments.

OK, the above formula generates 1 buy order, the first time the condition is true.
Now my question is, why only 1 order is created when this condition is true for dozens of time?

I'm applying it in a 10 day historical 5 minutes chart.

I've been trying to add a sell order, to close the long position, but I can't find any reserved word that specified if there's an open position then if the sell condition (low < low of the entry bar) is met then close position.

I thought that writing an indicator was difficult Creating a strategy is starting to get much more difficult

Thank you
ptcman is offline  
Reply With Quote
Old 06-18-2009, 09:35 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: Help with My First Strategy

Quote:
Originally Posted by ptcman »
Hi.

Thank you all for your comments.

OK, the above formula generates 1 buy order, the first time the condition is true.
Now my question is, why only 1 order is created when this condition is true for dozens of time?

I'm applying it in a 10 day historical 5 minutes chart.

I've been trying to add a sell order, to close the long position, but I can't find any reserved word that specified if there's an open position then if the sell condition (low < low of the entry bar) is met then close position.

I thought that writing an indicator was difficult Creating a strategy is starting to get much more difficult

Thank you

the keyword is:

MarketPosition
Tams is offline  
Reply With Quote
Old 06-19-2009, 12:22 AM   #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: Help with My First Strategy

MarketPosition

Returns a numerical value, indicating the type of the specified position.

A value of 1 indicates a long position,
A value of -1 indicates a short position,
and
A value of 0 is returned only if the current position is specified and indicates that the current position is flat.

Usage

MarketPosition(PosBack)

Where:

PosBack - a numerical expression, specifying the position:

0 - open position;
1 - one position back (the last position closed);
2 - two positions back, etc.

If PosBack is not specified, a value for the open position will be returned.


Note

This function can only be used in signals.


Examples

MarketPosition will return a value of 0 if the current position is flat

MarketPosition (1) will return a value of -1 if the most recently closed position was a short position



source: EasyLanguage manual
Tams 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
Strategy for Es TWI Automated Trading 6 10-28-2008 02:18 PM
Strategy Development ephi144 Beginners Forum 7 10-21-2008 10:37 AM
{REQ} help with an exit strategy jjthetrader Coding Forum 4 09-22-2007 01:06 PM
Simple fib Strategy feb2865 Technical Analysis 1 09-19-2007 06:59 PM
What is your strategy when a trade goes against you jperl Technical Analysis 15 05-22-2007 11:41 PM

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