How do i know what bar im using

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #207893 quote
    andyafonso
    Participant
    New

    Hi fellow coders,

    One problem I run into alot when I want to program a system is that I often don’t know which bar to use.

    Let’s say I use the 1 hour timeframe and a time session of 08-22. (intraday system) If I want to compare the last candlestick of yesterday’s close (within my time session) with today’s open (within my time session).

    What close[X] and open[X] do I use then? Is the open/close function adapting to my time session that i declared above or is it using the 24hour that comes with an 1hour timeframe view?

    Hope you understand my question since it confuses me alot 🙂

    #207895 quote
    robertogozzi
    Moderator
    Master

    You can use Dclose() and Dopen(), 0 is the cirrent one, 1 is the previous day:

    YesterdayClose = Dclose(1)
    TodayOpen      = Dopen(0)
    andyafonso thanked this post
    #207901 quote
    andyafonso
    Participant
    New

    If i do an example of the above,

    1. will Dclose(1) return the last bar of the tsession @ 22:00 or the bar at 24:00 ?
      2. will Dopen(0) return the first bar of the tsession @09:00 or the bar at 01:00 ?
    ma20 = average[20]
    ma200 = average[200]
    tsession = time > 080000 and time < 220000
    
    
    if tsession then
    yclose = Dclose(1)
    topen = Dopen(0)
    if not longonmarket and topen < yclose and ma20 > ma200 and time=090000 then
    buy 1 contract at market
    endif
    if longonmarket and topen > yclose then
    sell 1 contract at market
    endif
    endif
    
    #208069 quote
    Nicolas
    Keymaster
    Master

    Dopen and Dclose returns the default and official price of the market.

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

How do i know what bar im using


General Trading: Market Analysis & Manual Trading

New Reply
Author
author-avatar
andyafonso @andyafonso Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by Nicolas
3 years ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 01/22/2023
Status: Active
Attachments: No files
Logo Logo
Loading...