Multi timeframe and countofposition
Forums › ProRealTime English forum › ProOrder support › Multi timeframe and countofposition
- This topic has 12 replies, 5 voices, and was last updated 4 years ago by Nicolas.
-
-
03/22/2020 at 2:30 PM #122913
Hi,
It seems like countofposition will not work on earlier timeframe then the default time frame. is this a bug or a natural error ??
Eg.
12345678910111213141516171819202122timeframe (15minutes, updateonclose)if countofposition[1]>0 then//this will not work...Show15=1//Do something on chartendiftimeframe(default)if not longonmarket thenbuy 1 contract at marketendifif longonmarket and countofposition[50]>0 thenSell at marketendifif Show15=1 thenSHow1=1endifGraph show1 as "show1"show1=003/22/2020 at 2:37 PM #122914In your program, all codes below the “timeframe (15minutes, updateonclose)” line will be read and evaluated only once each 15 minutes. If you remove the “updateonclose”, it will be evaluated once every default timeframe period.
03/22/2020 at 2:50 PM #122916Hi Nicolas,
This would means that my code for the 15 minutes will hit 3 times (if the default time frame is 1 minute).
Right now it wont hit at all, as the countofposition[1]>0 (15minute) will not hit at all.
It seems to be stuck in countofposition constant zero.
Thanks for your speedily response btw!
03/22/2020 at 4:25 PM #122927Line 21 will display the final value of SHOW1 (which is 0), despite being the last line. It does not matter where you place GRPAH, it will always show values retained at the end of the code.
03/22/2020 at 4:47 PM #122930This would means that my code for the 15 minutes will hit 3 times (if the default time frame is 1 minute).
Without UpdateOnClose, it would refresh 15 times since there is 15 bars of 1 minute in a 15-minutes TF.
Without UpdateOnClose, it would refresh only 1 time at the end of the 15-minutes TF period.
But the result of your show15 variable will most likely be the same as the COUNTOFPOSITION[1] is the previous 15-minutes bar count of position !
03/22/2020 at 5:30 PM #122935la période de TF 15 minutes.
nicolas meant
with UpdateOnClose, it will refresh only 1 time at the end of the 15 minute TF period.
03/23/2020 at 3:12 AM #122966Hi Guys,
Thanks for replying, you can do a simple test on your end that you know will work for you too.
Just need to made use of countofposition as the key function in the higher timeframe then default.
i modify the code below to show exactly what i meant. You can just copy the code below to see if my interpretation is wrong.
Since 15 minutes, updateonclose. It should hit at least 5 times. but not once will it hit..
1234567891011121314151617181920212223242526timeframe (15minutes, updateonclose)if countofposition[1]>0 thenShow15=1elsif countofposition[1]=0 then//even after multiple 15 minutes the count of position will still be 0Show15=-1endiftimeframe(default)/// set to 1minuteif not longonmarket and countofposition[100]=0 thenbuy 1 contract at marketendifif longonmarket and countofposition[100]>0 thenSell at marketendifif Show15=1 and longonmarket thenShow1=1elsif show15=-1 and longonmarket thenshow1=-1endifGraph show1 as “show1”show1=003/23/2020 at 9:28 AM #122973>> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
🙂03/23/2020 at 10:33 AM #122983It should hit at least 5 times.
Sorry but why 5 times?
03/23/2020 at 10:41 AM #122985Hi Nicolas,
because for the 15 minutes code, i use countofposition[1]>0 and for the 1 minute code i locked it to 100 countofposition.
So after the first 15 minutes and subsequent 15 minutes it should hit.
countofposition[1]>0 to countofposition[6]>0 should be valid in 15minutes timeframe
So it should hit 6 times :0
04/26/2020 at 5:40 AM #128118Hi All,
Just to further illustrate the error:
it seems that the error will occur only when using [] on count of position in the higher timeframe:
Please copy the code below to try it on your end and it will be clear.
count of position error123456789101112131415161718192021222324252627282930313233343536373839404142434445timeframe (15minutes, updateonclose)COP=0if countofposition>0 then//long on market and Count of position should work the sameCOP=1endifif COP[1]>0 thenCOP15=1elseCOP15=0endifif countofposition[1]>0 then//long on market and Count of position should work the sameShow15=1elseSHow15=0endiftimeframe(default)/// set to 1minuteif not longonmarket and countofposition[100]=0 thenbuy 1 contract at marketendifif longonmarket and countofposition[100]>0 thenSell at marketendifif Show15=1 then// this should give same result as below//but this wont showShow1=1elseshow1=0endifif COP15=1 then// this should give same result as belowCOP1=1elseCOP1=0endifGraph show1 as "show1"Graph COP1 as "COP1"Thanks
04/26/2020 at 9:22 AM #128146Your code is a little confusing so I created this simple test code to try to see what is happening:
12345678910111213141516171819202122timeframe (15minutes, updateonclose)COP15 = countofpositionCOP15Back1 = countofposition[1]timeframe(default)/// set to 1minuteif not longonmarket and countofposition[100]=0 thenbuy 1 contract at marketendifif longonmarket and countofposition[100]>0 thenSell at marketendifCOP1=countofpositionCOP1Back1 = countofposition[1]Graph COP15 as "COP15"Graph COP1 as "COP1"Graph COP15Back1 as "COP15[1]"Graph COP1Back1 as "COP1[1]"The images show the results for both UPDATEONCLOSE and DEFAULT on the 15 minute time frame. There is definitely something weird going on because in UPDATEONCLOSE mode the 15 minute count of position does not change until the 15 minute bar closes which is what we would expect but if we check the previous bar it has changed to zero.
Then in DEFAULT mode the fifteen minute back one bar is not updating until the close of the fifteen minute bar when it should be updated every minute.
04/26/2020 at 9:32 AM #128150 -
AuthorPosts
Find exclusive trading pro-tools on