clbradley17
Junior member
- Messages
- 25
- Likes
- 0
Hey. I have a code which works fairly well in backtesting, but there are bugs in most end of day exit strategy codes at Tradestation, and have noticed recently that SetExitOnClose just works in backtesting. What do I need to do to make sure I'm out by the end of the day or just before? Here's what I have so far:
Inputs:
FastLength(10), SlowLength(20), StartTime(0930),EndTime(1600);
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 the exit end of day codes at TS, and not sure what really works. Thanks for any help and hope you're having a great weekend.
Curtis
Inputs:
FastLength(10), SlowLength(20), StartTime(0930),EndTime(1600);
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 the exit end of day codes at TS, and not sure what really works. Thanks for any help and hope you're having a great weekend.
Curtis