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

Reply
Old 01-22-2009, 12:52 PM   #1

Join Date: Dec 2008
Location: Madrid
Posts: 1
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Multiple Profit Targets for Multiple Contracts

Hello,
I am a total easylangguage newbie and try to figure out how to scale out a trade in a trading strategy.

My system should buy e.g. 3 contracts and sell 1 contract at various Dollar Profit targets.

I tried it this way:

Code:
	if condition1 then begin 
  
	Buy ( "Firstcontract" ) 1 contract next bar at market;
	SetStopContract;
	SetProfitTarget(25);
				
	Buy ( "Secondcontract" ) 1 contract next bar at market;
	SetStopContract;
	SetProfitTarget(100);

	Buy ( "Thirdcontract" ) 1 contract next bar at market;
	SetStopContract;
	SetProfitTarget(200);
				
	end;
The problem is that the above code will just buy 1 contract and only execute the 1 profit target for that contract.

How could I get 3 contracts with three different profit targets being bought?
Would be great if anybody could help me.
palmcarl is offline  
Reply With Quote
Old 01-23-2009, 12:26 AM   #2

Join Date: Dec 2008
Location: miami beach
Posts: 12
Ignore this user

Thanks: 0
Thanked 2 Times in 2 Posts

Re: Multiple Profit Targets for Multiple Contracts

Ok well the reason it's only executing one profit target per contract is that those EasyLanguage statements are per strategy, not per signal. So you can only have one of those commands per strategy (this is for stop and profit targets).

As to why it's only sending one buy order... this seems strange to me. Although in theory since your buy signals are all being sent under the same condition, there is no reason they should be seperate. So you might try :

Buy 3 contracts at next bar at market

instead of 3 'buy 1 contracts' statements.

in terms of having multiple profit targets, you should be able to do that still... you just wouldn't want to use easylanguage functions. you'd want to check your openpl yourself, and then close the desired amount of trade. eg, something like :

if ((GetPositionOpenPL / GetPositionQuanity > profittarget3 ) && (profittarget3HIT==0))
then begin
Sell 1 contract at next bar at market
profittarget3HIT = 1
end

and so on for each target. vicea verca if you wanted to 'tier' stops/exits in the same way.

Sorry my easylanguage is a little rough, but the function names and general syntax should be right. You'd also have to make sure that GetPositionQuantity was not zero in the above example. Hopefully you get the idea, and you found this helpful.
tradelink is offline  
Reply With Quote
Old 01-23-2009, 07:16 AM   #3

Join Date: May 2007
Location: Toronto
Posts: 262
Ignore this user

Thanks: 9
Thanked 149 Times in 54 Posts

Re: Multiple Profit Targets for Multiple Contracts

In order to allow additional contracts to be added to the first order you have to select the option to allow "Pyramiding" in the Strategy Properties format box.
bakrob99 is offline  
Reply With Quote
Old 02-19-2009, 05:43 PM   #4

swansjr's Avatar

Join Date: Oct 2007
Location: Gurnee, IL
Posts: 282
Ignore this user

Thanks: 86
Thanked 132 Times in 69 Posts

Re: Multiple Profit Targets for Multiple Contracts

Quote:
Originally Posted by palmcarl »
Hello,
I am a total easylangguage newbie and try to figure out how to scale out a trade in a trading strategy.

My system should buy e.g. 3 contracts and sell 1 contract at various Dollar Profit targets.

I tried it this way:

Code:
	if condition1 then begin 
  
	Buy ( "Firstcontract" ) 1 contract next bar at market;
	SetStopContract;
	SetProfitTarget(25);
				
	Buy ( "Secondcontract" ) 1 contract next bar at market;
	SetStopContract;
	SetProfitTarget(100);

	Buy ( "Thirdcontract" ) 1 contract next bar at market;
	SetStopContract;
	SetProfitTarget(200);
				
	end;
The problem is that the above code will just buy 1 contract and only execute the 1 profit target for that contract.

How could I get 3 contracts with three different profit targets being bought?
Would be great if anybody could help me.

If I understand you correctly I think this is what you are looking for:

Code:
if condition1 then Buy ( "Go Long" ) 3 contracts next bar at market; 


If ( CurrentContracts = 3) Then SetProfitTarget( Target_1 )
Else If ( CurrentContracts = 2 ) Then SetProfitTarget( Target_2 )
Else SetProfitTarget( Target_3 );

SetStopLoss( StopLoss );

Jeff
swansjr is offline  
Reply With Quote
Old 02-24-2009, 05:36 PM   #5

swansjr's Avatar

Join Date: Oct 2007
Location: Gurnee, IL
Posts: 282
Ignore this user

Thanks: 86
Thanked 132 Times in 69 Posts

Re: Multiple Profit Targets for Multiple Contracts

Quote:
Originally Posted by swansjr »
If I understand you correctly I think this is what you are looking for:

Code:
if condition1 then Buy ( "Go Long" ) 3 contracts next bar at market; 


If ( CurrentContracts = 3) Then SetProfitTarget( Target_1 )
Else If ( CurrentContracts = 2 ) Then SetProfitTarget( Target_2 )
Else SetProfitTarget( Target_3 );

SetStopLoss( StopLoss );

Jeff

Let me correct that:

Code:
If ( condition1 ) Then Buy ( "Go Long" ) 3 contracts next bar at market; 

If ( CurrentContracts = 3) Then  Sell ("Target 1") next bar at EntryPrice+Target_1 limit
Else If ( CurrentContracts = 2 ) Then Sell ("Target 2") next bar at EntryPrice+Target_2 limit
Else Sell ( "Target 3") next bar at EntryPrice+Target_3 limit;


SetStopLoss( StopLoss );
swansjr is offline  
Reply With Quote
Old 03-20-2009, 10:52 PM   #6

Join Date: Feb 2007
Location: zephyr
Posts: 97
Ignore this user

Thanks: 2
Thanked 3 Times in 3 Posts

Re: Multiple Profit Targets for Multiple Contracts

just curious..
did the OP resolve this issue?
the thread apparently just stopped


i've made a few attempts at this (scalable profits), but none lately.
it seemed difficult..
bubba is offline  
Reply With Quote
Old 03-21-2009, 09:51 AM   #7

swansjr's Avatar

Join Date: Oct 2007
Location: Gurnee, IL
Posts: 282
Ignore this user

Thanks: 86
Thanked 132 Times in 69 Posts

Re: Multiple Profit Targets for Multiple Contracts

I'm actually home so I was able to verify the following code. It's a simple moving average crossover system that uses three targets.

Code:
Input:
    Price( Close ),
    StopLoss$(300),
    LT_Length( 34 ),
    ST_Length( 13 ),
    Target_1(25),
    Target_2(50),
    Target_3(100);

Variables:
   LT_SMA(0),
   ST_SMA(0),
   Counter(0);


LT_SMA = Average( Price, LT_Length );
ST_SMA = Average( Price, ST_Length );

If ( ST_SMA crosses over LT_SMA ) Then Buy ( "Long" ) 3 contracts next bar at market
Else If ( ST_SMA crosses under LT_SMA ) Then SellShort ( "Short" ) 3 contracts next bar at market;

If ( MarketPosition = 1 ) Then
Begin
If ( CurrentContracts = 3) Then Sell ("LT 1") 1 contract next bar at EntryPrice+Target_1 limit
Else If ( CurrentContracts = 2 ) Then Sell ("LT2")1 contract next bar at EntryPrice+Target_2 limit
Else Sell ( "LT 3") next bar at EntryPrice+Target_3 limit;
End
Else If ( MarketPosition = -1 ) Then
Begin
If ( CurrentContracts = 3) Then BuyToCover ("ST 1") 1 contract next bar at EntryPrice-Target_1 limit
Else If ( CurrentContracts = 2 ) Then BuyToCover ("ST 2") 1 contract next bar at EntryPrice-Target_2 limit
Else BuyToCover ( "ST 3") next bar at EntryPrice-Target_3 limit;
End;


SetStopLoss( StopLoss$ );
swansjr is offline  
Reply With Quote
Old 03-21-2009, 11:20 AM   #8

Join Date: Feb 2007
Location: zephyr
Posts: 97
Ignore this user

Thanks: 2
Thanked 3 Times in 3 Posts

Re: Multiple Profit Targets for Multiple Contracts

well..
let's see, maybe i'm just too slow but...
what happens if you enter a long position; you hit 1st target so you now are long 2 contracts

then..
you get a signal to enter short position (sell 3 contracts)
what's your position now?

Last edited by bubba; 03-21-2009 at 11:39 AM.
bubba 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
Multiple Timeframes jasont Technical Analysis 68 01-27-2009 04:16 AM
profit targets franky Beginners Forum 19 03-26-2007 06:13 PM
Dollar profit targets rally64 Brokers and Data Feeds 0 12-28-2006 02:04 PM

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