NexusFi: Find Your Edge


Home Menu

 





Monthly Sell - Bug or Code Issue?


Discussion in EasyLanguage Programming

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




 
Search this Thread
  #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?
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
No book, only a stair: journaling fills where price move …
Cryptocurrency
Trump Media to sell instant access to market-moving soci …
Traders Hideout
My Rant with AMP Futures
Trading Reviews and Vendors
Datafeed for Atas
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
TopStep Trader disappointment
2 thanks
Johnnys Journal
2 thanks
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,740 since Jul 2012
Thanks Given: 1,918
Thanks Received: 7,489

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 X Reply With Quote
Thanked by:
  #3 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,740 since Jul 2012
Thanks Given: 1,918
Thanks Received: 7,489


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 X Reply With Quote




Last Updated on December 7, 2022


© 2026 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 - Downloads - Top
no new posts