NexusFi: Find Your Edge


Home Menu

 





Monthly Sell - Bug or Code Issue?


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,121 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 1 attachments




 
Search this Thread

Monthly Sell - Bug or Code Issue?

(login for full post details)
  #1 (permalink)
CreativelyChris
Los Angeles, CA
 
Posts: 13 since Sep 2021
Thanks Given: 1
Thanks Received: 0

I discovered that if I'm using a Monthly Chart - that buying the Next Bar (Month) and using "SetExitOnClose" occasionally produces months where it doesn't exit on the end of the month, but the following month.

Examples are: (05-21 which closes out at the end of 06-21, as well as 03-18, which closes out at the end of 04-21) and see attached photo.

I'm using $DIA on a monthly chart.

I'm looking to analyze the performance of each month, which won't work if it skips a sell.
My full code is:

 
Code
Inputs: BuyOrSell(1),WhichMonth(0);

Once ClearPrintLog;



if WhichMonth = 0 then
begin
		if(BuyOrSell = 1) then
				buy ("Buy Long")Next Bar Open;
		if(BuyOrSell = 2) then
				sellShort("Sell Short")Next Bar Open;
end
Else
if Month(Date of Next Bar) = WhichMonth then
begin
		if(BuyOrSell = 1) then
				buy ("Buy")Next Bar Open;
		if(BuyOrSell = 2) then
				sellShort("Sell Open")Next Bar Open;
end;

SetExitOnClose;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Futures Close-Out Policy
Commodities
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Looking for an MQL4 MetaTrader programmer/coder
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
68 thanks
Battlestations: Show us your trading desks!
35 thanks
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Daytrading ES & NQ
26 thanks

(login for full post details)
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,639 since Jul 2012
Thanks Given: 1,884
Thanks Received: 7,316

SetExitOnClose only works in backtest, it will not work in live trading. Not the root problem, but something you should know.

Now, to your real issue, setexitonclose should work on backtest, but for the month you show, it is not.

I tried a few different things with different code:

buy next bar at market;
setexitonclose;

gives same result for May 2021 as your code (it closes trade the next month)


buy next bar at market;
sell this bar at close;


Worked just fine.


So, there appears to be some issue with setexitonclose.

I suggest you post your question at the Tradestation customer forum, in the Easy Language support section.

Just show this code as the simplest example

buy next bar at market;
setexitonclose;



and TS personnel will review it.

Follow me on Twitter Reply With Quote
The following user says Thank You to kevinkdog for this post:
(login for full post details)
  #3 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,639 since Jul 2012
Thanks Given: 1,884
Thanks Received: 7,316


I see Tradestation has reviewed it on their forum, and determined it is some kind of bug. Hopefully they will address it!

Follow me on Twitter Reply With Quote





Last Updated on December 7, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts