| Automated Trading Black box systems, strategy automation, algorithmic trading, etc... |
![]() | | Tweet | |
| | #1 | ||
![]() | Multiple Profit Targets for Multiple Contracts 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; How could I get 3 contracts with three different profit targets being bought? Would be great if anybody could help me. | ||
| |
|
| | #2 | ||
![]() | Re: Multiple Profit Targets for Multiple Contracts 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. | ||
| |
|
| | #3 | ||
![]() | Re: Multiple Profit Targets for Multiple Contracts | ||
| |
|
| | #4 | ||
![]() | Re: Multiple Profit Targets for Multiple Contracts Quote:
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 | ||
| |
|
| | #5 | ||
![]() | Re: Multiple Profit Targets for Multiple Contracts Quote:
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 ); | ||
| |
|
| | #6 | ||
![]() | Re: Multiple Profit Targets for Multiple Contracts 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.. | ||
| |
|
| | #7 | ||
![]() | Re: Multiple Profit Targets for Multiple Contracts 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$ ); | ||
| |
|
| | #8 | ||
![]() | Re: Multiple Profit Targets for Multiple Contracts 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. | ||
| |
|
![]() |
| Thread Tools | |
| Display Modes | 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 |