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

Reply
Old 12-03-2009, 02:14 PM   #1

Join Date: Feb 2007
Location: Anytown
Posts: 1
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Stop Trading After Profit/Loss

I have a TS automated strategy (ES Futures) and would like to have a capability to turn off the automation and stop trading for the day once a certain PROFIT (in dollars) or LOSS is reached during the day.

I found some code in the TS forums that was suppose to accomplish this but it does not seem to work.

Any help/suggestions would be appreciated.

The TS forum code is:

Variables:
NP( 0 ),
OPP( 0 ),
PLB4Today( 0 ),
ProfToday( 0 ),
PTarget( 2000 ),
LLimit( -660 ) ;

NP = NetProfit ;
OPP = OpenPositionProfit ;

If date <> date[1] then
PLB4Today = NP[1] + OPP[1] ;

ProfToday = NP + OPP - PLB4Today ;

If ProfToday >= PTarget or ProfToday <= LLimit then
begin { exit all trades }
Sell this bar close ;
Buy to cover this bar close ;
end
else
begin

//Insert the trading code here
cortlane is offline  
Reply With Quote
Old 12-08-2009, 09:27 PM   #2

swansjr's Avatar

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

Thanks: 86
Thanked 132 Times in 69 Posts

Re: Stop Trading After Profit/Loss

I don't know about the code you posted, but I use something along these lines:

Code:
  If ( date <> date[1] ) Then 
  Begin
     PLB4Today = NetProfit;
    Trade_Flag = true;
  End;

 /// Track Today's P&L
 NP = NetProfit - PLB4Today;
 OPP = OpenPositionProfit;
 ProfToday = NP + OPP ;

 If  ( ProfToday > Profit_Target$) OR (  ProfToday <= -(Day_Loss) ) Then Trade_Flag = false;
 
 If ( Trade_Flag ) Then
 Begin
    // Trade Logic Here
 End
 Else SetDollarTrailing(0); // Exit all trades if any
swansjr 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
Daily stop loss/profit targets Sparrow Money Management 21 03-29-2011 08:42 PM
Master the Art of Stop Loss Placement Soultrader Trading Articles 4 10-30-2010 11:54 AM
NinjaTrader Stop Loss Bug - You May Looose $$$$ rsagi Brokers and Data Feeds 21 04-16-2010 08:14 AM
Stop Loss Stop Loss Trailing rod30 Beginners Forum 8 02-23-2008 10:49 AM
Stop Loss or Target Price? Follow The Trend Trading Psychology 4 12-01-2006 12:54 PM

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