| Automated Trading Black box systems, strategy automation, algorithmic trading, etc... |
![]() | | Tweet | |
| | #1 | ||
![]() | EL End of Day Exit Problem Inputs: FastLength(10), SlowLength(20), StartTime(0930),EndTime(1 600); Vars: FastAvg(0),SlowAvg(0); FastAvg = xaverage(Close,FastLength ); SlowAvg = xaverage(Close,SlowLength ); If Time > StartTime and Time < EndTime then begin If FastAvg crosses above SlowAvg then buy 100 shares next bar at market; If FastAvg crosses below SlowAvg then sellshort 100 shares next bar at market; end; SetProfitTarget(1000); SetStopLoss( 100); SetExitOnClose; Except that now I'll leave the last line out since it only works for backtesting, not in real time. Wondering if I need to put the times at the top (EST?), the time zone I'm in, or New York Time (NYT?), and if it should be changed to 1558 or 1559 end time EST or NYT to be sure and be out before 4 PM (1600 EST), and if it should be stated to sell if long or cover if short at 1558 or 1559 EST near the end of the code. Have seen that there are lots of bugs in most exit end of day codes at TS and they don't stop the trade at the end of the day, and not sure what really works. Thanks for any help and hope you're having a great weekend. Curtis | ||
| |
|
| | #2 | ||
![]() | Re: EL End of Day Exit Problem Quote:
This is comparable to a discretionary trader who predicted the exact highs or lows and place a trade there and never got filled, it is something to be expected and planned for. You can use MarketPosition to find out if you are short or long and close out the trade that way by selling or buy to cover. The following will get you out at market at 1559, one minute before the market closes. TS does not have sub-minute resolution, so that is as close you can get unless you write a lot of code to use the PC's clock: if time >= Endtime then begin // Endtime = 1558; 1 min chart only if Marketposition > 0 then sell next bar market; if Marketposition < 0 then buytocover next bar market; end; There is a lot of information on the TS forum on this and there are many other solutions that is posted by the staff and users, for example here: https://www.tradestation.com/Discuss...txtExactMatch= | ||
| |
|
| | #3 | ||
![]() | Re: EL End of Day Exit Problem | ||
| |
|
| | #4 | ||
![]() | Re: EL End of Day Exit Problem | ||
| |
|
![]() |
| Thread Tools | |
| Display Modes | Help Others By Rating This Thread |
| |
| ∧ Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Possible Exit Methods | brownsfan019 | Technical Analysis | 6 | 08-27-2011 07:50 PM |
| Exit a Position | 156 | Beginners Forum | 5 | 07-29-2008 01:10 PM |
| My Entry vs My Stop vs My Exit | walterw | Technical Analysis | 45 | 07-23-2008 08:39 AM |
| VSA for Confirmation Entry and Exit | ubetido | Volume Spread Analysis | 9 | 06-17-2008 11:41 AM |
| {REQ} help with an exit strategy | jjthetrader | Coding Forum | 4 | 09-22-2007 01:06 PM |