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

Reply
Old 07-13-2010, 08:36 PM   #1

Join Date: Jul 2010
Posts: 6
Ignore this user

Thanks: 11
Thanked 1 Time in 1 Post

Question Position Management Code for TS

Hey Folks,
Does anyone know where I can find some code to do this: (in easy language)

a position on limit order, initial stop loss, 3 different targets, trigger of "stop loss change" to "break-even", with or without factor setting, at hit of a target, option to set the triggered "stop loss change" to be a "trailing stop loss".

thanks!
bumblebee is offline  
Reply With Quote
Old 07-13-2010, 09:28 PM   #2

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: Position Management Code for TS

Quote:
Originally Posted by bumblebee »
Hey Folks,
Does anyone know where I can find some code to do this: (in easy language)

a position on limit order, initial stop loss, 3 different targets, trigger of "stop loss change" to "break-even", with or without factor setting, at hit of a target, option to set the triggered "stop loss change" to be a "trailing stop loss".

thanks!

if you write out your thoughts one line at a time... (instead of a blurb)
you might be able to see your code hidden in there.
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
Old 07-13-2010, 11:06 PM   #3

Join Date: Jul 2010
Posts: 6
Ignore this user

Thanks: 11
Thanked 1 Time in 1 Post

Cool Re: Position Management Code for TS

hmmmm well lets see.. I am not a coder at all, never was and never will be. But lets see how it goes..

ask user for position variable,
place position as limit order,
ask user for stop loss,
set initial stop loss,
ask user for up to 3 different targets,
ask user for each target if there is a need to trigger a stoploss action,
if trigger needed move stop loss to breakeven with the option of adjusting factor variable,
or
if trigger needed change stoploss to trailing stoploss with the option of adjusting factor variable.


i tried...

anyone?????
bumblebee is offline  
Reply With Quote
Old 07-13-2010, 11:43 PM   #4

Join Date: Jul 2010
Posts: 6
Ignore this user

Thanks: 11
Thanked 1 Time in 1 Post

Re: Position Management Code for TS

Ihave also found this, but it just spits out a bunch of errors when i hit compile... any ideas? Im pretty sure this is what I am after.. thanks guys!


// START Trading Strategy Study EasyLanguage Code

[IntrabarOrderGeneration = false]
inputs:
ShareOrPosition( 1 ), { pass in 1 for per share basis, 2 for position basis }
ProfitTargetAmt( 5 ), { pass in 0 if you don't want a profit target }
StopLossAmt( 1 ), { pass in 0 if you don't want a stop loss }
BreakevenFloorAmt( 0 ), { pass in 0 if you don't want a breakeven stop }
DollarTrailingAmt( 0 ), { pass in 0 if you don't want a dollar trailing stop }
PctTrailingFloorAmt( 0 ), { pass in 0 here and/or in next input if you don't want
a percent trailing stop }
PctTrailingPct( 0 ), { pass in 0 here and/or in previous input if you don't want
a percent trailing stop; else pass in XX for XX percent }
ExitOnClose( false ) ; { pass in true if you want to exit the position at the
close of the day, else pass in false. CAUTION: We recommend that you set this to
TRUE only for back-testing, if at all; in automated execution, the exit order
will NOT be filled at the close of the day; instead, the order can be sent into
the extended session as a limit order. }

if ShareOrPosition = 1 then
SetStopShare
else
SetStopPosition ;

if ProfitTargetAmt > 0 then
SetProfitTarget( ProfitTargetAmt ) ;
if StopLossAmt > 0 then
SetStopLoss( StopLossAmt ) ;
if BreakevenFloorAmt > 0 then
SetBreakeven( BreakevenFloorAmt ) ;
if DollarTrailingAmt > 0 then
SetDollarTrailing( DollarTrailingAmt ) ;
if PctTrailingFloorAmt > 0 and PctTrailingPct > 0 then
SetPercentTrailing( PctTrailingFloorAmt, PctTrailingPct ) ;
if ExitOnClose = true then
SetExitOnClose ;


// END Trading Strategy EasyLanguage Code
bumblebee is offline  
Reply With Quote
Old 07-18-2010, 10:32 AM   #5

Join Date: Oct 2009
Location: Port St Lucie
Posts: 62
Ignore this user

Thanks: 13
Thanked 29 Times in 21 Posts

Re: Position Management Code for TS

Hi bumblebee:

a) Recompile your code and review the error messages. See, if you can determine the error on your own and if not then post the error messages on the forum and ask for help.

b) I had a difficult time following your sequence of operation because it appears that you are trying to specify entry & exit conditions but the code you provided only exits the market, once the conditions in the code are satisfied and marketposition <> 0.

c) Perhaps further clarifying your objective will be helpful as Tams suggested, however you might want to print-out a simple chart; attach some notes ie enter on this trigger(s), qty x limit order at this price level; stop(s) at this price level(s); profit target(s) this level(s). Scan the document and post.

I doubt anyone will write the code for you but perhaps someone will share some code; help you edit your work; or provide a link.

Based on my understanding of what you outlined .... this code will not meet your objective.

RANGER

Last edited by Ranger; 07-18-2010 at 10:35 AM. Reason: error in posting
Ranger is offline  
Reply With Quote
The Following 2 Users Say Thank You to Ranger For This Useful Post:
bumblebee (07-18-2010), Tams (07-18-2010)
Old 07-18-2010, 11:09 AM   #6

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: Position Management Code for TS

Quote:
Originally Posted by bumblebee »
hmmmm well lets see.. I am not a coder at all, never was and never will be. ...
don't waste your time... call up a professional programmer.
you will be up and running faster (ie make real money).
__________________



Only an idiot would reply to a stupid post
Tams is offline  
Reply With Quote
Old 07-18-2010, 11:11 AM   #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: Position Management Code for TS

Quote:
Originally Posted by bumblebee »
Ihave also found this, but it just spits out a bunch of errors when i hit compile... any ideas? ....
...let me check my crystal ball for your error messages, will get back to you soon.
__________________



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:
aaa (07-24-2010)
Old 07-18-2010, 11:11 AM   #8

Join Date: Jul 2010
Posts: 6
Ignore this user

Thanks: 11
Thanked 1 Time in 1 Post

Re: Position Management Code for TS

Hi Ranger,

Thank you for taking the time to respond with some thought. The sample code above does suffice my needs, as my initial thoughts were not exact.

Anyhow, I have it working at the moment with the help of my broker as I really have no time to fiddle with code...
Apparently they value my business.

Best Regards, BB
bumblebee is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


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