Monthly Sell - Bug or Code Issue? - futures io
futures io



Monthly Sell - Bug or Code Issue?


Discussion in EasyLanguage Programming

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




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Monthly Sell - Bug or Code Issue?

(login for full post details)
  #1 (permalink)
CreativelyChris
Los Angeles, CA
 
 
Posts: 11 since Sep 2021
Thanks: 1 given, 0 received

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 futures io?
in depth understanding of last, bid, and ask volume in c …
NinjaTrader
NT8 Order Management Strategy
The Elite Circle
How to pay for market data with Dorman LLC
NinjaTrader
Market on Close data within IB
Platforms and Indicators
help with take profit several targets
TradeStation
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Is anyone actually making money?
88 thanks
An embarrassing, honest confession
25 thanks
Sierra vs. Ninja : why I chose .....
8 thanks
ApexTraderFunding.com experience and review
8 thanks
Want your NinjaTrader indicator created, free?
7 thanks
 
(login for full post details)
  #2 (permalink)
 kevinkdog   is a Vendor
 
 
Posts: 3,465 since Jul 2012
Thanks: 1,827 given, 6,985 received

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,465 since Jul 2012
Thanks: 1,827 given, 6,985 received


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


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Monthly Sell - Bug or Code Issue?


Last Updated on December 7, 2022


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2023 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
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.
no new posts