NexusFi: Find Your Edge


Home Menu

 





Exit at end of trading day on 5 minute bars


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,739 views
    2. thumb_up 4 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

Exit at end of trading day on 5 minute bars

  #1 (permalink)
Prophet85
Gothenburg Sweden
 
Posts: 75 since Jul 2019
Thanks Given: 53
Thanks Received: 24

Hi

I was looking for the best way to exit trades close to the end of the day (3.15 pm) on intraday strategies that uses 5 minute bars.

So far I have been using "setexitonclose" together with a session that goes from 8.30 am-3.09 pm. To my understanding this would then exit the trade on the next bar that is 3.10 pm.

Now let's say I want to exit at 3.14 pm instead. How would I achieve this the best way possible? I was thinking about making a session from 8.30 - 3.14 and in the code write "If time > 1511 then sell this bar on close". Would this then close the trade at the session close (3.14 pm) or not?

Regards

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #2 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,666 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,360


Prophet85 View Post
Hi

I was looking for the best way to exit trades close to the end of the day (3.15 pm) on intraday strategies that uses 5 minute bars.

So far I have been using "setexitonclose" together with a session that goes from 8.30 am-3.09 pm. To my understanding this would then exit the trade on the next bar that is 3.10 pm.

Now let's say I want to exit at 3.14 pm instead. How would I achieve this the best way possible? I was thinking about making a session from 8.30 - 3.14 and in the code write "If time > 1511 then sell this bar on close". Would this then close the trade at the session close (3.14 pm) or not?

Regards

That should work, it should exit at at 3:14 PM.

After you backtest it, I suggest running in real time, preferably real account, just to test and make sure it is working correctly. I have seen times where this does not always work properly.

Follow me on Twitter Reply With Quote
Thanked by:
  #3 (permalink)
Prophet85
Gothenburg Sweden
 
Posts: 75 since Jul 2019
Thanks Given: 53
Thanks Received: 24



kevinkdog View Post
That should work, it should exit at at 3:14 PM.

After you backtest it, I suggest running in real time, preferably real account, just to test and make sure it is working correctly. I have seen times where this does not always work properly.

Thank you! Yeah I will test it live. I know the method of using "sell this bar on close" works well with bar building of daily bars (405 minute bars) with a session (8.30 - 15.14). But I always thought that is because the bars use smaller 1 minute intervals to build the full bars. This means that Tradestation can do proper backtesting as it could calculate the exit price at 15.14.

I just don't know how it would know the exit price at 15.14 if I do backtesting at 5 minutes bars since TS would only know the price at 15.15. Or would I have to use "look-inside-bar" for the backtesting to work properly?

Reply With Quote
  #4 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,666 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,360


Prophet85 View Post
Thank you! Yeah I will test it live. I know the method of using "sell this bar on close" works well with bar building of daily bars (405 minute bars) with a session (8.30 - 15.14). But I always thought that is because the bars use smaller 1 minute intervals to build the full bars. This means that Tradestation can do proper backtesting as it could calculate the exit price at 15.14.

I just don't know how it would know the exit price at 15.14 if I do backtesting at 5 minutes bars since TS would only know the price at 15.15. Or would I have to use "look-inside-bar" for the backtesting to work properly?

If you create a custom session, the last bar should end at 15:14, so then TS would know the proper price to use.

I know that works in backtest, I have heard and seen mixed reviews on how well this works live.

Follow me on Twitter Reply With Quote
Thanked by:
  #5 (permalink)
Prophet85
Gothenburg Sweden
 
Posts: 75 since Jul 2019
Thanks Given: 53
Thanks Received: 24


kevinkdog View Post
If you create a custom session, the last bar should end at 15:14, so then TS would know the proper price to use.

I know that works in backtest, I have heard and seen mixed reviews on how well this works live.

Ok, great! I will try it out and see how it goes.

Reply With Quote
  #6 (permalink)
M4STR0
Florence
 
Posts: 27 since Jan 2021
Thanks Given: 23
Thanks Received: 9

In this cases I use a 1 minute chart and simply say "If Time = 1411 then begin.." if you us minutes ending with five then you can just use the 5 minute bar and so on. like 60minute bar if you just enter at round hours. The time information is stored in the chart bars obviously you have to consider local or exchange time settings.

Reply With Quote
  #7 (permalink)
Prophet85
Gothenburg Sweden
 
Posts: 75 since Jul 2019
Thanks Given: 53
Thanks Received: 24


M4STR0 View Post
In this cases I use a 1 minute chart and simply say "If Time = 1411 then begin.." if you us minutes ending with five then you can just use the 5 minute bar and so on. like 60minute bar if you just enter at round hours. The time information is stored in the chart bars obviously you have to consider local or exchange time settings.

I'm not sure I understand what you mean. My backtesting is done on 5 minute bars. You mean I should make a data2 with five minute bars but take the trades on 1 minute bars?

Anyway the previous method mentioned in this thread seems to work fine for me.

Reply With Quote
  #8 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,666 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,360


Prophet85 View Post
I'm not sure I understand what you mean. My backtesting is done on 5 minute bars. You mean I should make a data2 with five minute bars but take the trades on 1 minute bars?

Anyway the previous method mentioned in this thread seems to work fine for me.

For 5 minute bar, you'd use if time=1410 then begin...

Follow me on Twitter Reply With Quote
Thanked by:
  #9 (permalink)
Prophet85
Gothenburg Sweden
 
Posts: 75 since Jul 2019
Thanks Given: 53
Thanks Received: 24


kevinkdog View Post
For 5 minute bar, you'd use if time=1410 then begin...

Ahh I just re-read that. So I could for example use "if time = 1510 then sell this bar on close" together with a session that ends at 15.14?

Wouldn't "if time > 1511 then sell this bar on close" do the exact same thing though? Or is there a benefit of using "=" instead?

Reply With Quote
  #10 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,666 since Jul 2012
Thanks Given: 1,892
Thanks Received: 7,360



Prophet85 View Post
Ahh I just re-read that. So I could for example use "if time = 1510 then sell this bar on close" together with a session that ends at 15.14?

Wouldn't "if time > 1511 then sell this bar on close" do the exact same thing though? Or is there a benefit of using "=" instead?

Both should work. Depending how you do it, you might not need a custom session to handle it. I've done it both ways.

Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on January 26, 2021


© 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