Question on coding MTF: tradeindex
Forums › ProRealTime English forum › ProOrder support › Question on coding MTF: tradeindex
- This topic has 5 replies, 2 voices, and was last updated 5 years ago by stefou102.
Tagged: mtf, tradeindex
-
-
07/09/2019 at 3:57 PM #102273
So MTF is available to everyone, but weirdly we don’t see a lot of posts related to it. In my opinion because it’s too complicated to code.
I have a 15min strategy which is working averagely, but that could be improved I think/hope. All my code is on the 15min, but once there is a position, I want to manage it via the 5min. So in my 15min code, I use the snippet “barindex-tradeindex>0” to avoid taking a position if one was just opened before.
Now in the MTF code, when I test via graph the value of both function, I have tradeindex which is > barindex, which doesn’t seem even possible to me.
can you see why?
Second question: is there a way to use a smaller TF which won’t be the main TF in a MTF code? For exemple if I want to know the close value of an index like the Dax which closes at 17h35, I can’t know it if my TF is 15min. Same goes for the open, for which the correct time is rather 09h02 than 09h.
07/09/2019 at 4:23 PM #102281Not so weird, only available since only 2 weeks. Not everyone is a coder. IG didn’t communicate on it. It’s Summer time! 😀
Each barindex is different in each timeframe. Same goes for tradeindex. Count of elapsed bars aren’t the same for a 5-min or a 15-min TF.
The main TF is always the smallest timeframe. Code is still only read one time, at bar closure, so in order to test TIME = 090200, you still need to run the code on a 1-minute timeframe.
07/10/2019 at 5:32 PM #102391thx for your reply Nicolas.
I’m working with STOP and Limit order in my code, so it’s not always easy to know when a trade has been taken. In a unique timeframe, I use the snippet “barindex-tradeindex=0” to know that a trade has been taken.
But now in MTF, I get how “barindex” is working, but I still don’t get how “tradeindex” is working. How can you compare both, if they don’t use the same scale?
07/10/2019 at 5:42 PM #10239207/10/2019 at 5:47 PM #10239307/10/2019 at 6:21 PM #102395yes that’s what I’m doing, but it doesn’t work. All the barindex and tradeindex functions are used under the same timeframe (15min) but tradeindex never equal barindex….
Speaking on countofposition, I thought that countofposition[1] would tell me that no trade was opened on the previous bar, but unfortunately this command always return 0 when I graph it…
Either there are still bugs in the MTF engine, or it’s me.
So I recode a fake code to explain my problems…The code is without interest, but what is important is the value of barindex, tradeindex in order to be able to compare them. Same with countofposition, how can I get the value of countofposition for the previous bar?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273DEFPARAM FlatAfter = 214500DEFPARAM cumulateorders=falseONCE positionsize=1TIMEFRAME(15 minutes, updateonclose)graph barindexgraph tradeindexgraph countofposition[1]myMA7=average[7](close)myMA20 = average[20](close)c1=myMA7 crosses over myMA20cs1= myMA7 crosses under myMA20if intradaybarindex=0 thencountL=0CountS=0endifIf countofposition=positionsize and countofposition[1]=0 thencountL=countL+1endifIf countofposition=-positionsize and countofposition[1]=0 thencountS=countS+1endifIf not onmarket and c1 and countL<1 thenBuyLevel=lowbuy positionSize contracts at buyLevel STOPendifIf not onmarket and cs1 and countS<1 thenSellLevel=lowsellshort positionSize contracts at sellLevel STOPendifTimeframe (5 minute, updateonclose)myMA75=average[7](close)closeL1= myMA75[1]>myMA75[2]closeL2=close<myMA75closeS1=myMA75[1]<myMA75[2]closeS2=close>myMA75if longonmarket and closeL1 and closeL2 thensell at marketendifif shortonmarket and closeS1 and closeS2 thenexitshort at marketendif -
AuthorPosts
Find exclusive trading pro-tools on