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

Reply
Old 03-08-2010, 08:46 AM   #1

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

Thanks: 13
Thanked 29 Times in 21 Posts



Daily Net Profit Target & Time Code Segment

While working up an auto execution strategy for the futures market, my friend and I created this segment of code that provides for market exit after achieving the desired profit target or end of time.

Hope others find it useful .....

RANGER


///// This code ends trading once the Daily Net Points are achieved or end time constraint is met.
//// Designed for use on futures contracts
/// If used within an Auto Execution Strategy, you may elect to revisit the "marketposition" terms.
//// Co-written by ZAC & RANGER 2010 Rev 0 / tested and found operational


inputs:
DailyNetPoints(4),
StopLossTicks(12),
ProfitTargetTicks(12),
BreakEvenTicks (6),
NumberContracts(4),

start_time(0930),
end_time(1615),

ExitOnClose( true );

variables:
Prior_Date(date),
Prior_Net_Profit(0),
StopPx_Amt(0),
Daily_NP_Amt(0),
Profit_Target_Amt(0),
Break_Even_Amt(0);



StopPx_Amt = ((StopLossTicks/4)*BigPointValue) * NumberContracts;

Daily_NP_Amt = (DailyNetPoints * BigPointValue) * NumberContracts;

Profit_Target_Amt = ((ProfitTargetTicks/4)*BigPointValue) * NumberContracts;

Break_Even_Amt = ((BreakEvenTicks/4)*BigPointValue) * NumberContracts;

once
begin
Prior_Date = Date - 1;
end;

if Time > start_time and Time < end_time then
BEGIN

if Date > Prior_Date then
begin
Prior_Date = Date;
Prior_Net_Profit = netprofit;
end;

if netprofit - Prior_Net_Profit <= Daily_NP_Amt then
begin

///////////START ENTRY/EXIT SIGNALS HERE




///////////////END ENTRY EXIT SIGNALS HERE

end else {ends when daily profit objective is reached}
begin
if marketposition = 1 then sell ("DONE-2") next bar on Open;
if marketposition = -1 then buytocover ("DONE-1") next bar on Open;
end;

END else

if Time > end_time then {ends when time limit is hit}
begin
if marketposition = 1 then sell ("EOD-0") this bar on Close;
if marketposition = -1 then buytocover ("EOD-1") this bar on Close;
end;

if ExitOnClose = true then SetExitOnClose ; {exit on close of market - this can be rem if desired}

if marketposition <> 0 then
begin
SetDollarTrailing( StopPx_Amt ) ;
SetBreakeven( Break_Even_Amt ) ;
if Profit_Target_Amt > 0 then SetProfitTarget(Profit_Ta rget_Amt ) ;
end;
Ranger is offline  
Reply With Quote

Reply

Tags
daily net profit

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Daily stop loss/profit targets Sparrow Money Management 21 03-29-2011 09:42 PM
Is Optimizing Profit Target & Stop Loss Curve Fitting? cunparis Automated Trading 21 04-04-2010 09:34 AM
Profit Target Levels thecloser Coding Forum 8 12-27-2009 10:54 AM
Arts of stop placment and profit target kingking Beginners Forum 24 03-01-2007 02:52 AM
Processing Market Information: Segment by Segment Soultrader Technical Analysis 3 02-13-2007 12:30 PM

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