end of day close - futures io
futures io futures trading



end of day close


Discussion in MultiCharts

Updated
    1. trending_up 6,347 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 11 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,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
 

end of day close

(login for full post details)
  #1 (permalink)
new york
 
 
Posts: 355 since Mar 2012
Thanks: 665 given, 580 received

In regular version of multicharts, what is proper code for close at end of day ?
Will it be based on session time ?

And where are some good study material for multicharts coding ?

thanks


shane

Reply With Quote

Can you help answer these questions
from other members on futures io?
Strategy Builder - configure a profit target PnL condition?
NinjaTrader
SimplerOptions
Trading Reviews and Vendors
What blockvolume is visible? - order processing
NinjaTrader
EL/PL for FOPs?
EasyLanguage Programming
COTbase for quant trading?
Elite Algorithmic NinjaTrader Trading
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Battlestations: Show us your trading desks!
118 thanks
Big Mike in Ecuador
66 thanks
If you needed one-on-one help with any trading issue, ho …
31 thanks
Want your NinjaTrader indicator created, free?
27 thanks
Building a Crypto Mining Rig
21 thanks
 
(login for full post details)
  #2 (permalink)
 
 
Posts: 2,232 since Apr 2013
Thanks: 411 given, 1,474 received

Shane,

what exactly are you looking for? Code for a signal that closes a trade at the end of the session?

In backtesting you can use "SetExitOnClose". However you need to be aware of it's limitations as it will use the closing price of the session that is market as session end in Quotemanager. In realtime this obviously can't work and it even might skew your backtesting as it will not represent an accurate test (as how often would you get filled at the exact closing tick).

Regards,

ABCTG

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #3 (permalink)
new york
 
 
Posts: 355 since Mar 2012
Thanks: 665 given, 580 received


Hi

I have not had luck with that code for the reason you stated.

Henry at Multicharts posted the code below at the Multicharts.net forum to overcome the problem and to allow you to set your trading times with a time filter.

I was looking for a similar thing in easylanguage.

thanks

Shane








protected override void CalcBar()
{
double m_Avg = m_AverageFC[0];
if (PublicFunctions.DoubleGreater(Price[0], m_Avg))
{
++m_Counter.Value;
}
else
{
m_Counter.Value = 0;
}
TimeSpan _tStart = new TimeSpan(9, 30, 0);
TimeSpan _tEnd = new TimeSpan(12, 0, 0);

bool _Condition = DateTime.Now.TimeOfDay >= _tStart && DateTime.Now.TimeOfDay <= _tEnd;
if (PublicFunctions.DoubleGreater(Bars.CurrentBar, ConfirmBars)
&& m_Counter.Value == ConfirmBars && _Condition)
{
m_MACrossLE.Send();
}
}



The example above has been provided for Realtime trading:
Code:
bool _Condition = DateTime.Now.TimeOfDay >= _tStart && DateTime.Now.TimeOfDay <= _tEnd;

For Backtesting please use the following code:
Code:
bool _Condition = Bars.TimeValue.TimeOfDay >= _tStart && Bars.TimeValue.TimeOfDay <= _tEnd;

Reply With Quote
 
(login for full post details)
  #4 (permalink)
new york
 
 
Posts: 355 since Mar 2012
Thanks: 665 given, 580 received

Hi

Nice !
And that has worked for you on both live and backtesting ?

Excellent. Thank you.

That will work on most.

On one of my strategies, I use an indicator for entries into the market. One problem I ran into is that the indicator can get changed with custom session times.
That is why I was hoping to code trading times into the strategy. That way, I can leave the chart on full globex session times so as not to change the indicator.

thanks

shane

Reply With Quote
 
(login for full post details)
  #5 (permalink)
 
 
Posts: 2,979 since Jul 2012
Thanks: 1,576 given, 5,906 received


shanemcdonald28 View Post
Hi

Nice !
And that has worked for you on both live and backtesting ?

Excellent. Thank you.

That will work on most.

On one of my strategies, I use an indicator for entries into the market. One problem I ran into is that the indicator can get changed with custom session times.
That is why I was hoping to code trading times into the strategy. That way, I can leave the chart on full globex session times so as not to change the indicator.

thanks

shane


Sorry I deleted previous msg, I thought it was off topic...

But setexitonclose, with custom sessions times set to end one minute before actual close, does work in backtest and live.

You are right, having a non-standard session will change your indicators. No easy workaround for that.

Follow me on Twitter Reply With Quote
The following user says Thank You to kevinkdog for this post:
 
(login for full post details)
  #6 (permalink)
new york
 
 
Posts: 355 since Mar 2012
Thanks: 665 given, 580 received

I pasted together some code I found over at Traders Exchange.
Can you guys look it over and see if you see any flaws that may be a problem ?

It seems to work in backtesting, but I hope to get some opinions on it.




inputs: price(Close), jthmaLength( 21), jthmaLength2(84),
startTime(0500), endTime(1600), EnterTradeEndTime(1600),StopTime ( 1500 );
variables: Avg( 0 ), Avg2( 0 ), Avg2Up( false ),
Avg2Dn( false ),MP( 0 ),AvgUp( false ), AvgDn( false );

MP = MarketPosition;
Avg = jthma( price, jthmaLength ) ;
Avg2 = jthma( price, jthmaLength2 );
Avg2Up = Avg2 > Avg2[1];
Avg2Dn = Avg2 < Avg2[1];
AvgUp = Avg[2]> Avg[1] and Avg > Avg[1];
AvgDn = Avg[2]< Avg[1] and Avg < Avg[1];




If Time > startTime and Time < EnterTradeEndTime then begin

if AvgUp and Avg2Up then
Buy ( "jup" ) next bar at market ;

if AvgDn and Avg2Dn then
sell short ( "jdn" ) next bar at market ;
end;


If MP = 1 and AvgDn then sell next bar at market;
If MP = -1 and AvgUp then buy to cover next bar at market;

if time = endtime and MP > 0 then sell this bar on close;
if time = endtime and MP < 0 then buy to cover this bar on close;

If Time > StopTime
Then Sell All Contracts Next Bar At Market

Reply With Quote
 
(login for full post details)
  #7 (permalink)
 
 
Posts: 2,979 since Jul 2012
Thanks: 1,576 given, 5,906 received


shanemcdonald28 View Post
I pasted together some code I found over at Traders Exchange.
Can you guys look it over and see if you see any flaws that may be a problem ?

It seems to work in backtesting, but I hope to get some opinions on it.




inputs: price(Close), jthmaLength( 21), jthmaLength2(84),
startTime(0500), endTime(1600), EnterTradeEndTime(1600),StopTime ( 1500 );
variables: Avg( 0 ), Avg2( 0 ), Avg2Up( false ),
Avg2Dn( false ),MP( 0 ),AvgUp( false ), AvgDn( false );

MP = MarketPosition;
Avg = jthma( price, jthmaLength ) ;
Avg2 = jthma( price, jthmaLength2 );
Avg2Up = Avg2 > Avg2[1];
Avg2Dn = Avg2 < Avg2[1];
AvgUp = Avg[2]> Avg[1] and Avg > Avg[1];
AvgDn = Avg[2]< Avg[1] and Avg < Avg[1];




If Time > startTime and Time < EnterTradeEndTime then begin

if AvgUp and Avg2Up then
Buy ( "jup" ) next bar at market ;

if AvgDn and Avg2Dn then
sell short ( "jdn" ) next bar at market ;
end;


If MP = 1 and AvgDn then sell next bar at market;
If MP = -1 and AvgUp then buy to cover next bar at market;

if time = endtime and MP > 0 then sell this bar on close;
if time = endtime and MP < 0 then buy to cover this bar on close;

If Time > StopTime
Then Sell All Contracts Next Bar At Market

What instrument, and what size bar are you using?

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #8 (permalink)
new york
 
 
Posts: 355 since Mar 2012
Thanks: 665 given, 580 received

RB,DAX,TF are the ones it is working good on.
moderate success on GC, CL , NQ , ZB

5, 15, 30 min

as well as .04 % .06 % and .08 % renko bars on 1 min setting

fair success on 10, 15 and 21 point settings

various percent trailing , stop loss, session settings

Reply With Quote
 
(login for full post details)
  #9 (permalink)
 
 
Posts: 2,979 since Jul 2012
Thanks: 1,576 given, 5,906 received


shanemcdonald28 View Post
RB,DAX,TF are the ones it is working good on.
moderate success on GC, CL , NQ , ZB

5, 15, 30 min

as well as .04 % .06 % and .08 % renko bars on 1 min setting

fair success on 10, 15 and 21 point settings

various percent trailing , stop loss, session settings

The reason I asked: Just be careful that there actually is trading going on after endtime and stoptime. For instance, if last bar of the day is at 1600, then the statement
if time = endtime and MP > 0 then sell this bar on close;

won't work in real time (market will be closed by the time order is sent)...

Follow me on Twitter Reply With Quote
 
(login for full post details)
  #10 (permalink)
new york
 
 
Posts: 355 since Mar 2012
Thanks: 665 given, 580 received


Hi

Thanks

I see what you mean.

It does not seem to work on point, range or renko type charts.

I will be using this on futures and want to set close for around 3 pm EST.

For the indexes, I will close around 1 hour before Stock exchange closes , with futures market closing at 5 15 pm for those indexes.

I hope this will get around the problem of closing at session end, which I would like to set separately.

thanks

shane

Reply With Quote
 
(login for full post details)
  #11 (permalink)
 
 
Posts: 2,232 since Apr 2013
Thanks: 411 given, 1,474 received

The reason for that is that rarely a non time based bar will end exactly at your specified time.
There are two ways to deal with that:

1. For historic exits take the exit if the next bar is later than your end time and the current bar is not. You can do this as you have reserved words to look into the future.
2. For realtime exits use the computer time and trigger the exit based on that.

It will take you some programming, but this works nicely.

Regards,
ABCTG


shanemcdonald28 View Post
Hi

It does not seem to work on point, range or renko type charts.

shane


Follow me on Twitter Reply With Quote
The following user says Thank You to ABCTG for this post:
 
(login for full post details)
  #12 (permalink)
new york
 
 
Posts: 355 since Mar 2012
Thanks: 665 given, 580 received

thank you ABCTG

I appreciate your help


regards

Shane

Reply With Quote


futures io Trading Community Platforms and Indicators MultiCharts > end of day close


Last Updated on August 31, 2014


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, 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