Multiple Timeframes support available?
Forums › ProRealTime English forum › ProRealTime platform support › Multiple Timeframes support available?
- This topic has 29 replies, 6 voices, and was last updated 5 years ago by ginko.
-
-
10/10/2019 at 2:48 PM #109828
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
WEND Works somehow12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364ONCE FutTime=40000ONCE s=2*pipsizeCH=HourCM=Minute//CMC=MinuteCloseTime=CloseCT=TimeCTC=TimeBI=barindexY=highv=volumeDRAWTEXT("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 Thenwhile yabug=CountMM5M15 do // and add a while as the kludge is the basic kludgeclosetime4=closeTime3closeTime3=closeTime2closeTime2=closeTime1closeTime1=closeTime0closeTime0=closetimeCountMM5M15=CountMM5M15+1 // This is the basic kludge while endY=closes=-sDRAWTEXT("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=-sy=y+1WEND // works better if placed hereIF CM < 58 thenfutmin=(ROUND(CM/2)+1)*200IF FutMin < 6000 THENFutTime=(CH)*10000+FutMinELSEFutTime=(CH+1)*10000+FutMin-6000ENDIFIF FutTime > 210000 thenFutTime= 040000 // make sure we do not collect value between 21:00:00 and 4:00:00 (fixed timings depending on local TZ)CountMM5M15=0ENDIFENDIF// WEND // logic fails if placed hereELSEyabug=CountMM5M15 // This is the basic kludge, Invert IF condition and use a while to kludgeENDIFReturnThe 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
moving the Wend a few lines below, the code is not properly executed as expected12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364ONCE FutTime=40000ONCE s=2*pipsizeCH=HourCM=Minute//CMC=MinuteCloseTime=CloseCT=TimeCTC=TimeBI=barindexY=highv=volumeDRAWTEXT("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 Thenwhile yabug=CountMM5M15 do // and add a while as the kludge is the basic kludgeclosetime4=closeTime3closeTime3=closeTime2closeTime2=closeTime1closeTime1=closeTime0closeTime0=closetimeCountMM5M15=CountMM5M15+1 // This is the basic kludge while endY=closes=-sDRAWTEXT("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=-sy=y+1//WEND // works better if placed hereIF CM < 58 thenfutmin=(ROUND(CM/2)+1)*200IF FutMin < 6000 THENFutTime=(CH)*10000+FutMinELSEFutTime=(CH+1)*10000+FutMin-6000ENDIFIF FutTime > 210000 thenFutTime= 040000 // make sure we do not collect value between 21:00:00 and 4:00:00 (fixed timings depending on local TZ)CountMM5M15=0ENDIFENDIFWEND // logic fails if placed hereELSEyabug=CountMM5M15 // This is the basic kludge, Invert IF condition and use a while to kludgeENDIFReturn10/10/2019 at 4:29 PM #109841This 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?
1 user thanked author for this post.
10/10/2019 at 7:06 PM #109862Hi 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.
10/10/2019 at 7:45 PM #109867Even 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.
10/11/2019 at 9:22 AM #109903ThanksRoberto.
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.
10/11/2019 at 9:53 AM #109910My 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.
10/11/2019 at 10:22 AM #109913If you do like I suggested and store that price in a variable, you can retrieve it whenever you want:
123456789DEFPARAM DrawOnLastBarOnly = trueIF (Time = 110000) OR (Time > 110000 AND Time[1] < 110000) THENPriceAT11 = close[1]BarAT11 = barindexENDIFIF PriceAT11 > 0 THENDRAWTEXT("Price at 11:00:00 #PriceAT11#",BarAT11,PriceAT11)ENDIFRETURNedit 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
1 user thanked author for this post.
10/11/2019 at 11:06 AM #109921Above linked as Log 174 in here
2 users thanked author for this post.
10/11/2019 at 12:19 PM #109930Sorry about my snippet of code, at line 3 CLOSE shall be replaced with:
1close[1]1 user thanked author for this post.
10/11/2019 at 12:33 PM #109932Hi 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.
10/11/2019 at 1:01 PM #109935It’s because OpenTime is the time a candle opens, replace it with TIME, instead.
10/11/2019 at 1:02 PM #109936So 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>.
10/11/2019 at 2:01 PM #109938Being 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!
10/11/2019 at 2:14 PM #109939A 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!
10/12/2019 at 9:49 AM #109998Yes, 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.
-
AuthorPosts
Find exclusive trading pro-tools on