+1 888 340 6572
MultiCharts Project Management
previous_open_issue.png
Go to the previous open issue
previous_issue.png
Go to the previous issue (open or closed)
star_stroke.svg
Please log in to bookmark issues
feature_request_small.png
Open Feature request MC-550

set exit on close at real time auto trading

minus.svg
Please log in to vote
6
Votes
pluse.svg
Please log in to vote
next_issue.png
Go to the next issue (open or closed)
next_open_issue.png
Go to the next open issue
Description

set exit on close at real time auto trading.
NinjaTrader has this feature.
NT can send exit order N second before session end time.
this is useful for day trading.

Steps to reproduce this issue

Feature Request

Comments (3)
#0
user-offline.png  laurent68
Aug 17, 2011 - 06:31

http://tradersxchange.com/viewtopic.php?f=31&t=582
//EoD Exit Strategy (EoD_Exit)|
//©2005, JRG, v8.1c, 30 Aug 2005|
//
//NOTES:
//050427 v8.1a - fix seconds calculations & refine logic.
//050807 v8.1b - begin sending last entry time 30 minutes before.
//050830 v8.1c - handle regular futures session reentry after session close.
//
// ***** Setup *****

INPUTS: Exit_Count_B4_Close ( 17 ),
Use_Seconds ( False ),
EoD_LX ( true ),
EoD_SX ( true ),
EoW_Close_All ( False ),
Early_Close_All ( False ) ;
VARIABLES: Exit_Time ( 0 ),
Exit_Seconds ( 0 ),
Frac_Exit_Time ( 0 ),
EoD_Time ( 0 ),
Early_Close_Exit ( False ),
Exit_All ( False ),
Exit_Any ( False ),
GV_Name ( NumToStr( AbsValue( GetAppInfo( aiAppID ) ), 0 ) + "EoD_Exit_Time" ) ;
// ***** Housekeeping *****
if CurrentBar = 1 then
if Use_Seconds then
Exit_Seconds = AbsValue( Exit_Count_B4_Close )
else
Exit_Seconds = AbsValue( Exit_Count_B4_Close * 60 ) ;
// ***** Find Exit_Time Each Day *****
if Date Date[1] and // run once per day
BarStatus(1) = 2 then // run once on first bar of day
begin
if EarlyClose( Date ) then // adjust close time for early close
begin
EoD_Time = SessionEndTime( 0, 1 ) - 300 ; // early close is 3 hours
Early_Close_Exit = Early_Close_All ;
end
else begin
EoD_Time = SessionEndTime( 0, 1 ) ;
Early_Close_Exit = False ; // not early close
end ;
Frac_Exit_Time = ( ( TimeToMinutes( EoD_Time) * 60 ) - Exit_Seconds ) / 86400 ;
Exit_Time = CalcTime( EoD_Time, - IntPortion( ( Exit_Seconds + 59 ) / 60 ) ) ;
Exit_All = Early_Close_Exit or
( EoW_Close_All and
DayOfWeek( Date ) = 5 ) ; // determine exit all
Exit_Any = Exit_All or
EoD_LX or
EoD_SX ;
end ; // once a day
// ***** Exit at End of Day if *****
if Time >= Exit_Time and
Time < EoD_Time + 1 and // allow over night futures session entry
MarketPosition 0 and
Exit_Any then
begin
// *** RealTime Exit ***
if GetAppinfo( aiRealTimeCalc ) = 1 and
FracPortion( ComputerDateTime ) >= Frac_Exit_Time then
begin // exit choices
if EoD_LX or
Exit_All then
Sell( "RT_EoD_LX" ) currentshares shares next bar at MARKET ;
if EoD_SX or
Exit_All then
BuyToCover( "RT_EoD_SX" ) currentshares shares next bar at MARKET ;
end // realtime exit choices
else
// *** BackTesting Exit ***
if Time >= Exit_Time then
begin // exit choices
if EoD_LX or
Exit_All then
Sell( "BT_EoD_LX" ) currentshares shares this bar ;
if EoD_SX or
Exit_All then
BuyToCover( "BT_EoD_SX" ) currentshares shares this bar ;
end ; // backtesting exit
end ; // in position
// ***** Send Exit Time to Other Strategies *****
if Time >= CalcTime( Exit_Time, -30 ) and
( EoD_LX or
EoD_SX or
Exit_All ) then
Value1 = GVSetNamedInt( GV_Name, Exit_Time )
else
Value1 = GVSetNamedInt( GV_Name, 9999 ) ;
// *** Safety Valve ***
if Exit_All then // valid only if Exit_All triggered (for backtesting)
SetExitOnClose ;

#0
user-offline.png  Guest
Aug 20, 2011 - 05:18

works well.
but little bit complicated.

#0
user-offline.png  Guest
Oct 10, 2011 - 14:53

Would that work with exchange time ? or just computer time?

History
Issue basics
  • Type of issue
    Feature request
  • Category
    Usability
  • Targeted for
    Not determined
  • Status
    Under Review
User pain
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
Affected by this issue (3)
People involved
  • Posted by
    user-offline.png  YK
  • Owned by
    Not owned by anyone
  • Assigned to
    Not assigned to anyone
  • Subscribers
    0 subscriber(s)
    Click here to show the list of subscribers
Times and dates
  • Posted at
  • Last updated
Issue details
  • Resolution
    Not determined
  • Severity
    Normal
Attachments (1)
  • /pm/public/files/show/230
    NT screen shot uploaded Aug 16, 2011 by YK
Commits (0)
There are no code checkins for this issue
×

Sign up and get MultiCharts free

Use its powerful simulation mode with data included out of the box. Just fill out the form and start honing your trading skills with a few clicks.