close position last bar intrayday

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #47157 quote
    PaulPaul
    Participant
    Master

    Hi,

     

    You can use time to set a exit-time to close a position for intraday. But is it possible to automatically close at the last bar of a intraday chart? Which adjust itself based on timeframe. If selected daily it should be disregarded.

     

    Regards,

    Paul

    #47158 quote
    DespairDespair
    Blocked
    Master

    I don’t think so. Would be convenient to have though.

    You have to take care of this yourself and even keep in mind that there can be differences in the time when a market closes when there is a shift from summer time to winter time or vice versa. And this is different for different instruments. 🙂

    #47174 quote
    OscJohOscJoh
    Participant
    Average

    Perhaps something like this? You could make an indicator that knows which bar is the last in each time frame.

    IF INTRADAYBARINDEX >= 800 THEN
    #47188 quote
    DespairDespair
    Blocked
    Master

    This won’t work. Number of bars is dependent on the TF. So I think you have to take care of this yourself.

    #47282 quote
    NicolasNicolas
    Keymaster
    Legend

    You can recognize on which timeframe you are on with this little code snippet:

    once NbBar = 1
    
    if BarIndex < NbBar+2 then
    MyDay=openday
    dayminutes = 1440*(MyDay-MyDay[1])
    MyHour=openhour
    hourminutes = 60*(MyHour-MyHour[1])
    MyMin=openminute
    barminutes = MyMin - MyMin[1] + hourminutes + dayminutes
    barminutes=abs(barminutes)
    Mybarminutes = lowest[NbBar](barminutes)[1]
    endif
    
    return Mybarminutes as "Timeframe"

    So it would be possible to set a different “intradaybarindex” for each of the found timeframe to close your orders (or event a different Time).

    Despair thanked this post
    #47379 quote
    PaulPaul
    Participant
    Master

    Thanks for the responses.

     

    That’s an interesting snippet Nicolas. It gives new possibilities to play with.

    A look at intradaybarindex set as indicator shows that not everyday has the same number of bars although the longer the timeframe the more consistent they become.

    Because of that I guess it doesn’t work to set a close at a specific bar based on selected timeframe.

    #47382 quote
    NicolasNicolas
    Keymaster
    Legend

    Even if intraday bars are not the same exact number each day, a range of bars quantity could be determined for each of the timeframe?

    Anyway, with the timeframe code snippet I posted, you should also be able to set a time to close the orders, for example, if the timeframe is 5 minutes, close the trade @ 235500 or if the timeframe is 1 minute, close orders @ 235900.. etc.

    #47390 quote
    PaulPaul
    Participant
    Master

    yes set time to close orders based on timeframe should work indeed. I focused on a bar.  Going to try that way! Thanks

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

close position last bar intrayday


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Paul @micky75d Participant
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by PaulPaul
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/24/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...