Recurring Vertical Lines – datetolastbarindex

Viewing 15 posts - 16 through 30 (of 41 total)
  • Author
    Posts
  • #178137 quote
    inverse
    Participant
    New

    So all was going swimmingly until an outage yesterday (ASX Cash timeframe) with PRT and since then we’re now capped to something close to ~30k bars in 1sec int Australia Cash 200., could be lingering outage issues, housekeeping. The DAX30(now 40) however seems worse for wear. Was a rock before then.

    It looks to only be affecting 1sec ints. and duplicating another chart from another period, say 5min, will recreate the charts correctly when 1sec is selected however shortly afterwards it redraws to ~30k bars – this is with or w/o the indicator applied.

    #194744 quote
    inverse
    Participant
    New

    Anyway to add txt to the vertical lines (as drawn by code below)?

    drawvline(datetobarindex(20220606110000))Coloured (105,105,105)style(dottedline,1)

     

    Thanks in advance.

    #194752 quote
    robertogozzi
    Moderator
    Master

    There you go:

    defparam drawonlastbaronly = true
    drawvline(datetobarindex(20220606110000))Coloured (105,105,105)style(dottedline,1)
    drawtext("My Text",datetobarindex(20220606110000),high)Coloured (105,105,105)
    return
    inverse thanked this post
    #194772 quote
    inverse
    Participant
    New

    Hey Rob ….

    I must be going sideways on this one, this is what I had below but it was spitting the dummy.

    I’ll look closer and see what the go is.

    drawtext(“SGX”,datetobarindex(20220606110000))Coloured (105,105,105)style(dottedline,1)

     

    Many thanks for the speedy reply … 🙂

     

    edit: lol, dotted line ref. ….. one of those days. Thanks for setting me straight.

    #196499 quote
    inverse
    Participant
    New

     

    Hi Team,

    I’ve put together something with Rob’s help over the journey that’ll plot open times and label them. Many thanks for this.

    Been great for the past few weeks till the other day where it started to flag an error, complaining about date format.

     

    I shrunk the days to 1 and it’s still having a problem.

    Very much a newb here with this and thanks for your patience with me.

    Rgds,

     

    INV

     

     

     

     

     

    defparam drawonlastbaronly=true
    
    defparam calculateonlastbars=100
    
    
    //
    //
    //
    //Label offsets
    //
    //
    voffset=10+close
    voffset1=20+close
    voffset2=40+close
    //
    //
    //
    //
    Time1        = 070000
    Time2        = 095000
    Time3        = 100000
    Time4        = 110000
    Time5        = 113000
    Time6        = 150000
    Time7        = 160000
    //
    //
    //Label Time
    //
    //
    //
    //
    //
    //Time8        = 070000
    Time9        = 093000
    Time10       = 101500
    Time11       = 101500
    Time12       = 111500
    Time13       = 115000
    Time14       = 152000
    Time15       = 162000
    Time16       = 162000
    Time17       = 162500
    //
    //
    NumberOfDays = 1
    Time1          = max(0,min(235959,Time1))
    Time2          = max(0,min(235959,Time2))
    Time3          = max(0,min(235959,Time3))
    Time4          = max(0,min(235959,Time4))
    Time5          = max(0,min(235959,Time5))
    Time6          = max(0,min(235959,Time6))
    Time7          = max(0,min(235959,Time7))
    //
    Time9          = max(0,min(235959,Time9))
    Time10         = max(0,min(235959,Time10))
    Time11         = max(0,min(235959,Time11))
    Time12         = max(0,min(235959,Time12))
    Time13         = max(0,min(235959,Time13))
    Time14         = max(0,min(235959,Time14))
    Time15         = max(0,min(235959,Time15))
    Time16         = max(0,min(235959,Time16))
    Time17         = max(0,min(235959,Time17))
    //
    NumberOfDays   = max(0,min(999,NumberOfDays))
    MyDD           = Day
    MyMM           = Month
    MyYY           = Year
    //
    DayCount       = NumberOfDays
    While DayCount > 0 DO
    //
    // make sure it’s the same number of digits for days < 10
    If MyDD < 10 Then
    MyDate = (MyYY * 10000) + (MyMM * 1000) + MyDD
    Else
    MyDate = (MyYY * 10000) + (MyMM * 100) + MyDD
    Endif
    // last step, add hours
    a = (MyDate * 1000000) + Time1
    b = (MyDate * 1000000) + Time2
    c = (MyDate * 1000000) + Time3
    d = (MyDate * 1000000) + Time4
    e = (MyDate * 1000000) + Time5
    f = (MyDate * 1000000) + Time6
    g = (MyDate * 1000000) + Time7
    //
    // plot the lines
    //
    drawvline(datetobarindex(a))Coloured  (105,105,105)style(dottedline,1)
    drawvline(datetobarindex(b))Coloured  (105,105,105)style(dottedline,1)
    drawvline(datetobarindex(c))Coloured  (105,105,105)style(dottedline,1)
    drawvline(datetobarindex(d))Coloured  (105,105,105)style(dottedline,1)
    drawvline(datetobarindex(e))Coloured  (105,105,105)style(dottedline,1)
    drawvline(datetobarindex(f))Coloured  (105,105,105)style(dottedline,1)
    drawvline(datetobarindex(g))Coloured  (105,105,105)style(dottedline,1)
    //
    //
    //
    // draw the lables in - removed
    //
    //
    //x = (MyDate * 1000000) + Time9
    //i = (MyDate * 1000000) + Time10
    //j = (MyDate * 1000000) + Time11
    //k = (MyDate * 1000000) + Time12
    //l = (MyDate * 1000000) + Time13
    //m = (MyDate * 1000000) + Time14
    //n = (MyDate * 1000000) + Time15
    //o = (MyDate * 1000000) + Time16
    //p = (MyDate * 1000000) + Time17
    //
    //
    //
    //drawtext("SPI",datetobarindex(x),voffset1,SansSerif,standard,14)Coloured (000,100,000)
    //drawtext("TSE",datetobarindex(i),voffset,SansSerif,standard,14)Coloured (000,100,000)
    //drawtext("ASX",datetobarindex(j),voffset1,SansSerif,standard,14)Coloured (000,100,000)
    //drawtext("SGX",datetobarindex(k),voffset,SansSerif,standard,14)Coloured (000,100,000)
    //drawtext("SSE",datetobarindex(l),voffset,SansSerif,standard,14)Coloured (000,100,000)
    //drawtext("SSE",datetobarindex(m),voffset,SansSerif,standard,14)Coloured (000,100,000)
    //drawtext("FDAX",datetobarindex(n),voffset,SansSerif,standard,14)Coloured (000,100,000)
    //drawtext("FTEU",datetobarindex(o),voffset1,SansSerif,standard,14)Coloured (000,100,000)
    //drawtext("ASXCL",datetobarindex(p),voffset2,SansSerif,standard,14)Coloured (000,100,000)
    //
    //
    //
    
    // get ready to build tomorrow’s date, if needed
    //
    // compute tomorrow’s date (could be a new month, even a new year)
    //
    // 1. compute the last day of the month
    LastDay = 31
    // 2. it’s max 30 on a few months
    If MyMM = 4 or MyMM = 6 or MyMM = 9 or MyMM = 11 Then
    LastDay = 30
    Endif
    // 3. it’s max 28 days in February, 29 on a leap year
    If MyMM = 2 Then
    LastDay = 28
    If Year MOD 4 = 0 Then
    If Year MOD 100 = 0 Then
    If Year MOD 400 = 0 Then
    LastDay = 29
    Endif
    Else
    LastDay = 29
    Endif
    Endif
    Endif
    //
    MyDD = MyDD + 1
    // 4. if it’s greater than LastDay it’s the next month
    If MyDD > LastDay Then
    MyDD = 1
    MyMM = MyMM + 1
    // 5. if it’s greater than 12 it’s a new year
    If MyMM > 12 Then
    MyMM = MyMM - 12
    MyYY = MyYY + 1
    Endif
    Endif
    //
    DayCount = DayCount - 1     //one day has been plotted
    Wend
    RETURN
    
    #196502 quote
    inverse
    Participant
    New

    For some reason the month code for July is being interpreted as  70 rather than 07.

     

    The lines commented out allowed for line plots only, apologies for the mess.

    #196503 quote
    inverse
    Participant
    New
    //now working
    
    // make sure it’s the same number of digits for days < 10 (as per Robs layout)
    If MyDD < 0 Then
    MyDate = (MyYY * 10000) + (MyMM * 1000) + MyDD
    Else
    MyDate = (MyYY * 10000) + (MyMM * 100) + MyDD
    Endif
    
    vs
    
    //non-working but was
    
    // make sure it’s the same number of digits for days < 10
    If MyDD < 10 Then
    MyDate = (MyYY * 10000) + (MyMM * 1000) + MyDD
    Else
    MyDate = (MyYY * 10000) + (MyMM * 100) + MyDD
    Endif
    

    Not sure what happened here tbh, will have a closer look but this is usually set and forget.

    Even backups confirm it was <10, so,

    <10

    went

    <0

    for a fix?

    Really confused atmo .. lol

     

    Will see how the day rolls up.

    #196504 quote
    inverse
    Participant
    New

    Just as a follow up – I needed to create a new indicator with the same code otherwise the vectoring wouldn’t work.

    Copying and pasting.

    #196572 quote
    inverse
    Participant
    New

    Just updating that all went well after the tweaks.

    Kind of odd that it all worked for a few weeks then went RS.

    #228334 quote
    inverse
    Participant
    New

    Hi Team,

    Roberto helped out quite a bit with our smaller tf and all is well on that front.

    On the

     

    I’m wondering if there’s a way to work with a historical anchor (or any date) and add a series of calendar days to the anchor.

    Ideally the both anchor and days added would be variable but I could work with static added days but a flexible anchor would be the minimum.

     

    From what I’ve seen there can be problems with increasing the anchor variable past 31 days (32) and the indicator can error.

     

    These days plus anchor day (dates) would be represented as v-lines on a daily chart.

     

    eg: 20231030 as an anchor

    plus 10 days

    plus 12 days

    plus 15 days

    plus 22 days

    For the life of me I can work with the smaller TF kind of ok, minutes w/in a s session for example but on the larger TF, day for example, I can’t seen to get my head around it.

    Any help would be appreciated.

     

    Cheers,

    inv

    #228338 quote
    inverse
    Participant
    New
    defparam drawonlastbaronly=true
    
    
    
    
    drawvline(datetobarindex(MyDate1))style(dottedline,2)
    drawvline(datetobarindex(MyDate2))style(dottedline,2)
    drawvline(datetobarindex(MyDate3))style(dottedline,2)
    drawvline(datetobarindex(MyDate4))style(dottedline,2)
    drawvline(datetobarindex(MyDate5))style(dottedline,2)
    drawvline(datetobarindex(MyDate6))style(dottedline,2)
    //
    MyDateA = (MyDate1) + (Day1)
    MyDateB = (MyDate2) + (Day1)
    MyDateC = (MyDate3) + (Day1)
    MyDateD = (MyDate4) + (Day1)
    MyDateE = (MyDate5) + (Day1)
    MyDateF = (MyDate6) + (Day1)
    
    drawvline(datetobarindex(MyDateA))style(dottedline,2)
    drawvline(datetobarindex(MyDateB))style(dottedline,2)
    drawvline(datetobarindex(MyDateC))style(dottedline,2)
    drawvline(datetobarindex(MyDateD))style(dottedline,2)
    drawvline(datetobarindex(MyDateE))style(dottedline,2)
    drawvline(datetobarindex(MyDateF))style(dottedline,2)
    
    
    
    
    drawvline(datetobarindex(Day1))style(dottedline,2)
    drawvline(datetobarindex(Day10))style(dottedline,2)
    drawvline(datetobarindex(Day12))style(dottedline,2)
    drawvline(datetobarindex(Day15))style(dottedline,2)
    drawvline(datetobarindex(Day22))style(dottedline,2)
    drawvline(datetobarindex(Day30))style(dottedline,2)
    
    
    DayA = (Day1)
    DayB = (Day10)
    DayC = (Day12)
    DayD = (Day15)
    DayE = (Day22)
    DayF = (Day30)
    
    drawvline(datetobarindex(DayA))style(dottedline,2)
    drawvline(datetobarindex(DayB))style(dottedline,2)
    drawvline(datetobarindex(DayC))style(dottedline,2)
    drawvline(datetobarindex(DayD))style(dottedline,2)
    drawvline(datetobarindex(DayE))style(dottedline,2)
    drawvline(datetobarindex(DayF))style(dottedline,2)
    
    
    
    
    Time1          = max(0,min(235959,Time1))
    Time2          = max(0,min(235959,Time2))
    Time3          = max(0,min(235959,Time3))
    Time4          = max(0,min(235959,Time4))
    Time5          = max(0,min(235959,Time5))
    
    
    
    
    
    // last step, add hours
    a = (MyDate * 1000000) + Time1
    b = (MyDate * 1000000) + Time2
    c = (MyDate * 1000000) + Time3
    d = (MyDate * 1000000) + Time4
    e = (MyDate * 1000000) + Time5
    
    
    
    
    
    //
    NumberOfDays   = max(0,min(999,NumberOfDays))
    MyDD           = Day
    MyMM           = Month
    MyYY           = Year
    //
    DayCount       = NumberOfDays
    While DayCount > 0 DO
    //
    // make sure it’s the same number of digits for days < 10
    //If MyDD < 10 Then  //was 10 but needed to go to 0
    //
    If MyDD < 00 Then
    MyDate = (MyYY * 10000) + (MyMM * 1000) + MyDD
    Else
    MyDate = (MyYY * 10000) + (MyMM * 100) + MyDD
    Endif
    // last step, add hours
    a = (MyDate * 1000000) + Day1
    b = (MyDate * 1000000) + Day10
    c = (MyDate * 1000000) + Time3
    d = (MyDate * 1000000) + Time4
    e = (MyDate * 1000000) + Time5
    
    
    
    
    
    // 1. compute the last day of the month
    LastDay = 31
    // 2. it’s max 30 on a few months
    If MyMM = 4 or MyMM = 6 or MyMM = 9 or MyMM = 11 Then
    LastDay = 30
    Endif
    // 3. it’s max 28 days in February, 29 on a leap year
    If MyMM = 2 Then
    LastDay = 28
    If Year MOD 4 = 0 Then
    If Year MOD 100 = 0 Then
    If Year MOD 400 = 0 Then
    LastDay = 29
    Endif
    Else
    LastDay = 29
    Endif
    Endif
    Endif
    //
    MyDD = MyDD + 1
    // 4. if it’s greater than LastDay it’s the next month
    If MyDD > LastDay Then
    MyDD = 1
    MyMM = MyMM + 1
    // 5. if it’s greater than 12 it’s a new year
    If MyMM > 12 Then
    MyMM = MyMM - 12
    MyYY = MyYY + 1
    Endif
    Endif
    //
    DayCount = DayCount - 1     //one day has been plotted
    wend
    return
    

    Work in progress.

    itf is attached as a semi-hacked rev, probably 1/3rd of the way there maybe.

    Assistance appreciated.

    #228343 quote
    inverse
    Participant
    New
    defparam drawonlastbaronly=true
    
    
    
    
    drawvline(datetobarindex(MyDate1))style(dottedline,2)
    
    
    MyDateA = (MyDate1)
    MyDateB = (MyDate1) + (Day1)
    MyDateC = (MyDate1) + (Day2)
    MyDateD = (MyDate1) + (Day3)
    MyDateE = (MyDate1) + (Day4)
    MyDateF = (MyDate1) + (Day5)
    MyDateG = (MyDate1) + (Day6)
    
    
    
    
    
    drawvline(datetobarindex(MyDateA))style(dottedline,2)
    drawvline(datetobarindex(MyDateB))style(dottedline,2)
    drawvline(datetobarindex(MyDateC))style(dottedline,2)
    drawvline(datetobarindex(MyDateD))style(dottedline,2)
    drawvline(datetobarindex(MyDateE))style(dottedline,2)
    drawvline(datetobarindex(MyDateF))style(dottedline,2)
    drawvline(datetobarindex(MyDateG))style(dottedline,2)
    
    
    
    
    drawvline(datetobarindex(Day1))style(dottedline,2)
    drawvline(datetobarindex(Day2))style(dottedline,2)
    drawvline(datetobarindex(Day3))style(dottedline,2)
    drawvline(datetobarindex(Day4))style(dottedline,2)
    drawvline(datetobarindex(Day5))style(dottedline,2)
    drawvline(datetobarindex(Day6))style(dottedline,2)
    
    
    DayA = (Day1)
    DayB = (Day2)
    DayC = (Day3)
    DayD = (Day4)
    DayE = (Day5)
    DayF = (Day6)
    
    drawvline(datetobarindex(DayA))style(dottedline,2)
    drawvline(datetobarindex(DayB))style(dottedline,2)
    drawvline(datetobarindex(DayC))style(dottedline,2)
    drawvline(datetobarindex(DayD))style(dottedline,2)
    drawvline(datetobarindex(DayE))style(dottedline,2)
    drawvline(datetobarindex(DayF))style(dottedline,2)
    
    
    
    
    
    
    Time1          = max(0,min(235959,Time1))
    Time2          = max(0,min(235959,Time2))
    Time3          = max(0,min(235959,Time3))
    Time4          = max(0,min(235959,Time4))
    Time5          = max(0,min(235959,Time5))
    Time6          = max(0,min(235959,Time6))
    
    
    
    
    
    // last step, add hours
    a = (MyDate * 1000000) + Time1
    b = (MyDate * 1000000) + Time2
    c = (MyDate * 1000000) + Time3
    d = (MyDate * 1000000) + Time4
    e = (MyDate * 1000000) + Time5
    f = (MyDate * 1000000) + Time6
    
    
    
    
    //
    NumberOfDays   = max(0,min(999,NumberOfDays))
    MyDD           = Day
    MyMM           = Month
    MyYY           = Year
    //
    DayCount       = NumberOfDays
    While DayCount > 0 DO
    //
    // make sure it’s the same number of digits for days < 10
    //If MyDD < 10 Then  //was 10 but needed to go to 0
    //
    If MyDD < 00 Then
    MyDate = (MyYY * 10000) + (MyMM * 1000) + MyDD
    Else
    MyDate = (MyYY * 10000) + (MyMM * 100) + MyDD
    Endif
    // last step, add hours
    a = (MyDate * 1000000) + Day1
    b = (MyDate * 1000000) + Day2
    c = (MyDate * 1000000) + Day3
    d = (MyDate * 1000000) + Day4
    e = (MyDate * 1000000) + Day5
    f = (MyDate * 1000000) + Day6
    
    
    
    
    
    
    // 1. compute the last day of the month
    LastDay = 31
    // 2. it’s max 30 on a few months
    If MyMM = 4 or MyMM = 6 or MyMM = 9 or MyMM = 11 Then
    LastDay = 30
    Endif
    // 3. it’s max 28 days in February, 29 on a leap year
    If MyMM = 2 Then
    LastDay = 28
    If Year MOD 4 = 0 Then
    If Year MOD 100 = 0 Then
    If Year MOD 400 = 0 Then
    LastDay = 29
    Endif
    Else
    LastDay = 29
    Endif
    Endif
    Endif
    //
    MyDD = MyDD + 1
    // 4. if it’s greater than LastDay it’s the next month
    If MyDD > LastDay Then
    MyDD = 1
    MyMM = MyMM + 1
    // 5. if it’s greater than 12 it’s a new year
    If MyMM > 12 Then
    MyMM = MyMM - 12
    MyYY = MyYY + 1
    Endif
    Endif
    //
    DayCount = DayCount - 1     //one day has been plotted
    wend
    return
    

     

    inverse wrote:

    Work in progress and now need to work on as the integers rise and we hit a month with days more than it has triggering an error.

    #228345 quote
    inverse
    Participant
    New

    I know it’s messy and incorrect in places that are glaring as I look at it but I’m sadly lacking in this kind of thing … 🙂

    #228361 quote
    inverse
    Participant
    New
    defparam drawonlastbaronly=true
    
    
    
    
    // number of days ahead for each date
    NumberOfDays = 1  // Change this value to adjust the number of days ahead
    
    // Calculate subsequent dates
    MyDateA = MyDate1 + NumberOfDays
    MyDateB = MyDate1 + (3 * NumberOfDays)
    MyDateC = MyDate1 + (7 * NumberOfDays)
    MyDateD = MyDate1 + (11 * NumberOfDays)
    MyDateE = MyDate1 + (16 * NumberOfDays)
    MyDateF = MyDate1 + (21 * NumberOfDays)
    
    
    
    //
    
    
    drawvline(datetobarindex(MyDateA))style(dottedline,2)coloured("red")
    drawvline(datetobarindex(MyDateB))style(dottedline,2)coloured("red")
    drawvline(datetobarindex(MyDateC))style(dottedline,2)coloured("red")
    drawvline(datetobarindex(MyDateD))style(dottedline,2)coloured("red")
    drawvline(datetobarindex(MyDateE))style(dottedline,2)coloured("red")
    drawvline(datetobarindex(MyDateF))style(dottedline,2)coloured("red")
    
    
    
    
    
    
    
    
    NumberOfDays   = max(0,min(999,NumberOfDays))
    MyDD           = Day
    MyMM           = Month
    MyYY           = Year
    //
    DayCount       = NumberOfDays
    While DayCount > 0 DO
    //
    // make sure it’s the same number of digits for days < 10
    //If MyDD < 10 Then  //was 10 but needed to go to 0
    //
    If MyDD < 00 Then
    MyDate = (MyYY * 10000) + (MyMM * 1000) + MyDD
    Else
    MyDate = (MyYY * 10000) + (MyMM * 100) + MyDD
    Endif
    
    
    
    
    
    
    // 1. compute the last day of the month
    LastDay = 31
    // 2. it’s max 30 on a few months
    If MyMM = 4 or MyMM = 6 or MyMM = 9 or MyMM = 11 Then
    LastDay = 30
    Endif
    // 3. it’s max 28 days in February, 29 on a leap year
    If MyMM = 2 Then
    LastDay = 28
    If Year MOD 4 = 0 Then
    If Year MOD 100 = 0 Then
    If Year MOD 400 = 0 Then
    LastDay = 29
    Endif
    Else
    LastDay = 29
    Endif
    Endif
    Endif
    //
    MyDD = MyDD + 1
    // 4. if it’s greater than LastDay it’s the next month
    If MyDD > LastDay Then
    MyDD = 1
    MyMM = MyMM + 1
    // 5. if it’s greater than 12 it’s a new year
    If MyMM > 12 Then
    MyMM = MyMM - 12
    MyYY = MyYY + 1
    Endif
    Endif
    //
    DayCount = DayCount - 1     //one day has been plotted
    wend
    return

    Ended up here but still cant roll past the month barrier. So it’ll plot w/in a month but not beyond …

    #228362 quote
    inverse
    Participant
    New
    // Define the anchor date (MyDate1), month (MyMM), and year (MyYY)
    MyDate1 = 20231001  // Assign the anchor date
    MyMM = 10     // Assign the month
    MyYY = 23     // Assign the year

     

    MyDate1 defined as a ext variable so you can plug it in via GUI and not w/in code but to be honest is easy enough to do it via cli.

Viewing 15 posts - 16 through 30 (of 41 total)
  • You must be logged in to reply to this topic.

Recurring Vertical Lines – datetolastbarindex


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
inverse @inverse Participant
Summary

This topic contains 40 replies,
has 2 voices, and was last updated by inverse
1 year, 11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 09/11/2021
Status: Active
Attachments: 11 files
Logo Logo
Loading...