Multiple Timeframes support available?

Viewing 15 posts - 16 through 30 (of 30 total)
  • Author
    Posts
  • #109828 quote
    ginko
    Participant
    Average

    Do you have any documentation on how the server works in tick modes, because I have any issue while coding IF-THEN AND WHILE.DO in tick mode

    the following code is OK

    ONCE FutTime=40000
    ONCE s=2*pipsize
    CH=Hour
    CM=Minute
    //CMC=Minute
    CloseTime=Close
    CT=Time
    CTC=Time
    BI=barindex
    Y=high
    v=volume
    DRAWTEXT("Time: #CT#" , BI, Y+10*s)
    DRAWTEXT("Current time: #CTC#" , BI, Y+9*s)
    DRAWTEXT("FutTime: #FutTime#" , BI, Y+8*s)
    DRAWTEXT("Volume: #v#" , BI, Y+7*s)
    DRAWTEXT("Close0: #closeTime0#" , BI, Y+6*s)
    DRAWTEXT("Close1: #closeTime1#" , BI, Y+5*s)
    DRAWTEXT("Close2: #closeTime2#" , BI, Y+4*s)
    DRAWTEXT("Close3: #closeTime3#" , BI, Y+3*s)
    DRAWTEXT("Close4: #closeTime4#" , BI, Y+2*s)
    DRAWTEXT("Nb hits: #CountMM5M15#" , BI, Y+1*s)
    
    
    IF CT > FutTime AND CT<220000 Then
    while yabug=CountMM5M15 do // and add a while as the kludge is the basic kludge
    closetime4=closeTime3
    closeTime3=closeTime2
    closeTime2=closeTime1
    closeTime1=closeTime0
    closeTime0=closetime
    CountMM5M15=CountMM5M15+1 // This is the basic kludge while end
    Y=close
    s=-s
    DRAWTEXT("Time: #CT#" , BI, Y+10*s)
    DRAWTEXT("Current time: #CTC#" , BI, Y+9*s)
    DRAWTEXT("FutTime: #FutTime#" , BI, Y+8*s)
    DRAWTEXT("Volume: #v#" , BI, Y+7*s)
    DRAWTEXT("Close0: #closeTime0#" , BI, Y+6*s)
    DRAWTEXT("Close1: #closeTime1#" , BI, Y+5*s)
    DRAWTEXT("Close2: #closeTime2#" , BI, Y+4*s)
    DRAWTEXT("Close3: #closeTime3#" , BI, Y+3*s)
    DRAWTEXT("Close4: #closeTime4#" , BI, Y+2*s)
    DRAWTEXT("Nb hits: #CountMM5M15#" , BI, Y+1*s)
    DRAWTEXT("Yarg: #yarg#" , BI, Y+1*s)
    s=-s
    y=y+1
    WEND // works better if placed here
    IF CM < 58 then
    futmin=(ROUND(CM/2)+1)*200
    IF FutMin < 6000 THEN
    FutTime=(CH)*10000+FutMin
    ELSE
    FutTime=(CH+1)*10000+FutMin-6000
    ENDIF
    IF FutTime > 210000 then
    FutTime= 040000 // make sure we do not collect value between 21:00:00 and 4:00:00 (fixed timings depending on local TZ)
    CountMM5M15=0
    ENDIF
    ENDIF
    // WEND // logic fails if placed here
    ELSE
    yabug=CountMM5M15 // This is the basic kludge, Invert IF condition and use a while to kludge
    ENDIF
    Return

    The following code does not change the programming logic, the WEND is moved a few line below,  but the execution is not correct and FutTime ss not updated accordingly

    ONCE FutTime=40000
    ONCE s=2*pipsize
    CH=Hour
    CM=Minute
    //CMC=Minute
    CloseTime=Close
    CT=Time
    CTC=Time
    BI=barindex
    Y=high
    v=volume
    DRAWTEXT("Time: #CT#" , BI, Y+10*s)
    DRAWTEXT("Current time: #CTC#" , BI, Y+9*s)
    DRAWTEXT("FutTime: #FutTime#" , BI, Y+8*s)
    DRAWTEXT("Volume: #v#" , BI, Y+7*s)
    DRAWTEXT("Close0: #closeTime0#" , BI, Y+6*s)
    DRAWTEXT("Close1: #closeTime1#" , BI, Y+5*s)
    DRAWTEXT("Close2: #closeTime2#" , BI, Y+4*s)
    DRAWTEXT("Close3: #closeTime3#" , BI, Y+3*s)
    DRAWTEXT("Close4: #closeTime4#" , BI, Y+2*s)
    DRAWTEXT("Nb hits: #CountMM5M15#" , BI, Y+1*s)
    
    
    IF CT > FutTime AND CT<220000 Then
    while yabug=CountMM5M15 do // and add a while as the kludge is the basic kludge
    closetime4=closeTime3
    closeTime3=closeTime2
    closeTime2=closeTime1
    closeTime1=closeTime0
    closeTime0=closetime
    CountMM5M15=CountMM5M15+1 // This is the basic kludge while end
    Y=close
    s=-s
    DRAWTEXT("Time: #CT#" , BI, Y+10*s)
    DRAWTEXT("Current time: #CTC#" , BI, Y+9*s)
    DRAWTEXT("FutTime: #FutTime#" , BI, Y+8*s)
    DRAWTEXT("Volume: #v#" , BI, Y+7*s)
    DRAWTEXT("Close0: #closeTime0#" , BI, Y+6*s)
    DRAWTEXT("Close1: #closeTime1#" , BI, Y+5*s)
    DRAWTEXT("Close2: #closeTime2#" , BI, Y+4*s)
    DRAWTEXT("Close3: #closeTime3#" , BI, Y+3*s)
    DRAWTEXT("Close4: #closeTime4#" , BI, Y+2*s)
    DRAWTEXT("Nb hits: #CountMM5M15#" , BI, Y+1*s)
    DRAWTEXT("Yarg: #yarg#" , BI, Y+1*s)
    s=-s
    y=y+1
    //WEND // works better if placed here
    IF CM < 58 then
    futmin=(ROUND(CM/2)+1)*200
    IF FutMin < 6000 THEN
    FutTime=(CH)*10000+FutMin
    ELSE
    FutTime=(CH+1)*10000+FutMin-6000
    ENDIF
    IF FutTime > 210000 then
    FutTime= 040000 // make sure we do not collect value between 21:00:00 and 4:00:00 (fixed timings depending on local TZ)
    CountMM5M15=0
    ENDIF
    ENDIF
    WEND // logic fails if placed here
    ELSE
    yabug=CountMM5M15 // This is the basic kludge, Invert IF condition and use a while to kludge
    ENDIF
    Return
    
    #109841 quote
    robertogozzi
    Moderator
    Master

    This is what the charts look like (100 ticks, DAX), left with the correct code, right with the incorrect one.

    I actually did not study the logic.

    Why did you want to move WEND?

    ginko thanked this post
    x-6.jpg x-6.jpg
    #109862 quote
    ginko
    Participant
    Average

    Hi Roberto, Nicolas

    I work with ticks that can range from 200 to 10000 ticks per bar.

    I neeed to get the price that was given @12h00:00 sharp, I do not want to get the price that would be the close at the end of the candle (on a 2000 tick candle, that could be delayed by more than 15 minutes easily).

    I can get that price after the candle is closed, but I need the price that was current @12h:00:00 and not the one current at the close of the bar instead.

    I go from problem to problem with the implementation of the graph tick mode that does not provide a correct CurrentTime.

    PRT does provide Time, but it does not authorize to store a price value sampled at a precise Time.

    I made a test moving the WEND as a possible kludge but it doesn’t work better.

    I am stuck.

    #109867 quote
    robertogozzi
    Moderator
    Master

    Even using a 1-tick chart there’s no guarantee that there will be a 12:00:00 tick, in the case there isn’t one, the price valid at that time is the previous tick’s price.

    It’s the previous price when the opentime is > 12:00:00 and the previous opentime is < 12:00:00.

    If there’s a 12:00:00 tick then you have it without much trouble.

    ginko and Nicolas thanked this post
    #109903 quote
    ginko
    Participant
    Average

    ThanksRoberto.

    Let’s say I have a bar starting at @11:55:25 and closing @12:17:54.

    I am able to retrieve the price value at the tick just after 12:00:00 (or just before), that is not a problem. My problem is to store that value for good into a variable, and keep it unchanged.

    I need to use the price that was @12:00:00 later in the afternoon, let say at 16:43:45 or whatever else time in the afternon.

    All my tests show that I will not store the value of the price @12:00:00, but PRT will retain only the price of the bar close (i.e. the close @12:17:54). And this is biased data for me.

    #109910 quote
    Nicolas
    Keymaster
    Master

    My problem is to store that value for good into a variable, and keep it unchanged.

    It is not possible as I stated in my last post in this thread. Each variable are reset on new received tick. So even with your while/wend loop inside a candle you couldn’t retrieve the Close price at a precise Time inside it. If the code is not read precisely at the exact time of the Close of the candlestick’s timeframe you want to get, then you can’t get it.

    #109913 quote
    robertogozzi
    Moderator
    Master

    If you do like I suggested and store that price in a variable, you can retrieve it whenever you want:

    DEFPARAM DrawOnLastBarOnly = true
    IF (Time = 110000) OR (Time > 110000 AND Time[1] < 110000) THEN
       PriceAT11 = close[1]
       BarAT11   = barindex
    ENDIF
    IF PriceAT11 > 0 THEN
       DRAWTEXT("Price at 11:00:00 #PriceAT11#",BarAT11,PriceAT11)
    ENDIF
    RETURN

    edit warning:   The above code has been changed, I replaced OpenTime with Time and close with close[1] to reflect the changes suggested in the following posts.
    Roberto

    Nicolas thanked this post
    x-8.jpg x-8.jpg
    #109921 quote
    GraHal
    Participant
    Master

    Above linked as Log 174 in here

    Snippet Link Library

    robertogozzi and ginko thanked this post
    #109930 quote
    robertogozzi
    Moderator
    Master

    Sorry about my snippet of code, at line 3 CLOSE shall be replaced with:

    close[1]
    GraHal thanked this post
    #109932 quote
    ginko
    Participant
    Average

    Hi Roberto.

    Correct close price @13:00:00 is 13380,7

    With your code just modified for a few lines to sample at another time, and to print the time value.

    I get the value of the close bar that closes way after 13:00:00 more that 15 minutes later, and is biased data

    See attached

    BTW: In the 1 minute chart info is the close price of 13:00:59.9999 (given the code, there is a 1 minute offset expected), but this is not important. I could be fixed easily.

    Annotation-2019-10-11-132740.jpg Annotation-2019-10-11-132740.jpg Annotation-2019-10-11-133310.jpg Annotation-2019-10-11-133310.jpg
    #109935 quote
    robertogozzi
    Moderator
    Master

    It’s because OpenTime is the time a candle opens, replace it with TIME, instead.

    #109936 quote
    ginko
    Participant
    Average

    So basically with The code you provided  Roberto,

    I can get two values on the 2000 tick bar chart, open or close of the bar that is current @<time to sample>.

    In my case the tick bar duration is often more than 30 minutes, and both values might be totally incorrect vs. the actual price @<time to sample>.

    #109938 quote
    robertogozzi
    Moderator
    Master

    Being totally incorrect does not exist!

    IT IS correct according to the TF or Number of TICKS you selected. If you want a greater accuracy you need to decrease the number of ticks, up to 1, still in this case, as I wrote some posts ago, there can be ticks with no price movement (actually there are no ticks).

    At any one time, no matter whether you are using time-base or tick-based charts, in case there is no movement (ticks) at the time you are monitoring, the correct value for that time is the previous known one!

    #109939 quote
    robertogozzi
    Moderator
    Master

    A further suggestion to reach a greater extent of accuracy.

    Use 1-tick charts, then count ticks yourself, say 100, 200 or 1000 to make your decisions. Of course your charts will change very fast!

    #109998 quote
    ginko
    Participant
    Average

    Yes, that would be doable if there were no graph constraints.

    But I also need visuals in 200-10000 tick periods. ANd with a very low number of ticks displayed, 1 would get a graph that is too fast.

    Like: if I had this issue on a 1 hour graph, I don’t want to kludge it by displaying a 5 second or a 1 minute graph, this without seeing any signal on my hourly chart.

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

Multiple Timeframes support available?


Platform Support: Charts, Data & Broker Setup

New Reply
Author
Summary

This topic contains 29 replies,
has 6 voices, and was last updated by ginko
6 years, 4 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 01/30/2018
Status: Active
Attachments: 6 files
Logo Logo
Loading...