Welcome to the Traders Laboratory Forums.
Automated Trading Black box systems, strategy automation, algorithmic trading, etc...

Reply
Old 10-09-2008, 03:49 AM   #1

Join Date: Oct 2008
Posts: 7
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts



Easy Language Stop Loss Problem

Hi,

I'm just starting to learn Easy Language, yet am having problems with stop loss setting when testing strategies.

Although the stop loss is set in the code, it seems it isn't always acted upon.

Not sure what I'm doing wrong... any ideas most appreciated!

Code sample:

if Condition11 and Condition12 then
begin
Buy 1 contracts next bar at market ;
SetProfitTarget(3000) ;
SetStopLoss( 100);
end;


In the most recent test, the first trade closed $100.78 down, the second is $16,091 down and still open!

Ideally I'd like to set a pip based stop loss (that works!), but it doesn't seem clear how to do this looking at the docs...


Thanks!
mctaff is offline  
Reply With Quote
Old 10-09-2008, 11:23 AM   #2
zdo

Join Date: Nov 2007
Location: boonies
Posts: 1,178
Ignore this user

Thanks: 299
Thanked 299 Times in 213 Posts
Blog Entries: 104



Re: Easy Language Stop Loss Problem

What happens if you pull
SetProfitTarget(3000) ;
SetStopLoss( 100);
outside the block?
zdo is offline  
Reply With Quote
Old 10-09-2008, 12:51 PM   #3

Blu-Ray's Avatar

Join Date: Nov 2006
Location: England
Posts: 508
Ignore this user

Thanks: 164
Thanked 288 Times in 105 Posts



Re: Easy Language Stop Loss Problem

Quote:
Originally Posted by zdo »
What happens if you pull
SetProfitTarget(3000) ;
SetStopLoss( 100);
outside the block?
Yes spot on zdo !

the code should read like this:


if Condition11 and Condition12 then Buy 1 contracts next bar at market ;

SetProfitTarget(3000) ;
SetStopLoss( 100);



Cheers

Blu-Ray
__________________

“ Search is the ultimate expression of the power of the individual, using a computer, looking at the world, and finding exactly what they want ” – Eric Schmidt, Google
Blu-Ray is offline  
Reply With Quote
Old 10-09-2008, 01:32 PM   #4

Join Date: Oct 2008
Posts: 7
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts



Re: Easy Language Stop Loss Problem

Thanks for the advice guys, I'll try that this evening.

However, I'd sincerely hope that doesn't work, otherwise I'm questioning the language designers competancy! Surely the idea of a code block is that the entire contents of it get executed when the conditions are met?! I don't want to be setting stop losses etc unless the order has been executed, although I suppose it makes little difference...

Enough ranting, I'll try it out, cheers!
mctaff is offline  
Reply With Quote
Old 10-09-2008, 01:40 PM   #5

Blu-Ray's Avatar

Join Date: Nov 2006
Location: England
Posts: 508
Ignore this user

Thanks: 164
Thanked 288 Times in 105 Posts



Re: Easy Language Stop Loss Problem

Quote:
Originally Posted by mctaff »
Thanks for the advice guys, I'll try that this evening.

However, I'd sincerely hope that doesn't work, otherwise I'm questioning the language designers competancy! Surely the idea of a code block is that the entire contents of it get executed when the conditions are met?! I don't want to be setting stop losses etc unless the order has been executed, although I suppose it makes little difference...

Enough ranting, I'll try it out, cheers!

It will work, the fault in the code is that Easy Language will only read that block of code if Condition11 and Condition12 are true. So it will read it at the time of execution.. but in a couple of bars time, for example, Condition11 and Condition12 are false it will therefore not read that block of code.

Also "SetStopLoss" will only come into force if a Position is filled.

Hope this helps

Blu-Ray
__________________

“ Search is the ultimate expression of the power of the individual, using a computer, looking at the world, and finding exactly what they want ” – Eric Schmidt, Google
Blu-Ray is offline  
Reply With Quote
Old 10-10-2008, 08:32 AM   #6

Join Date: Oct 2008
Posts: 7
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts



Re: Easy Language Stop Loss Problem

It worked - thanks again!

I think I must be misunderstanding how the stop loss code works then - I assumed at the time of the order being placed, the stop would be associated with the order. Looking at the code, that clearly can't be the case, as the stop loss command doesn't reference the order.

I'm now slightly confused how to open multiple orders, and have different profit and stop values for different orders!

Is this possible? Is it possible to link the profit / stop commands to the order?
mctaff is offline  
Reply With Quote
Old 10-10-2008, 11:37 AM   #7
zdo

Join Date: Nov 2007
Location: boonies
Posts: 1,178
Ignore this user

Thanks: 299
Thanked 299 Times in 213 Posts
Blog Entries: 104



Re: Easy Language Stop Loss Problem

Quote:
Originally Posted by mctaff »
...I think I must be misunderstanding how the stop loss code works then - I assumed at the time of the order being placed, the stop would be associated with the order. Looking at the code, that clearly can't be the case, as the stop loss command doesn't reference the order.

I'm now slightly confused how to open multiple orders, and have different profit and stop values for different orders!

Is this possible? Is it possible to link the profit / stop commands to the order?
First, 'get it' that (exit) orders are continously 'cancelled' and re-entered in TS.

Then re multiple orders and linking exits to that position
you can name posititions and use the names in the exits
and / or
you can use reserve words like SetStopContract
and / or
run separate / stand alone exit strategies
and / or ...

hth... this post only cost me $3000 so far...
zdo is offline  
Reply With Quote
Old 10-13-2008, 12:21 PM   #8

Join Date: Oct 2008
Posts: 7
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts



Re: Easy Language Stop Loss Problem

Quote:
Originally Posted by zdo »
First, 'get it' that (exit) orders are continously 'cancelled' and re-entered in TS.
Yeah I figured that from the solution. I was under the impression that if you ticked the "send stop to server" checkbox (or whatever it's called) on the strategies automation tab, that you only needed to send it once and it would be held on TS servers - so if I lose my connection I don't lose 10k as well!

Is that not the case? Or does that not work with back testing?

Cheers,

David.
mctaff is offline  
Reply With Quote

Reply

Tags
profit target, stop loss

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Easy Language Strategy Help Marc33139 Automated Trading 3 07-28-2008 12:35 PM
Need Assintance with Simple Indikator ( Easy Language ) flyingdutchmen Coding Forum 1 06-30-2008 07:32 PM
Stop Loss Stop Loss Trailing rod30 Beginners Forum 8 02-23-2008 11:49 AM
Easy ADE Problem bigboy Coding Forum 1 02-08-2008 07:59 PM
Easy Language - Help with Simple System gatrader E-mini Futures Trading Laboratory 8 12-17-2007 07:40 PM

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