How to count iterative bars
Forums › ProRealTime English forum › ProBuilder support › How to count iterative bars
- This topic has 5 replies, 2 voices, and was last updated 6 years ago by maleczek.
-
-
09/11/2018 at 3:19 PM #80181
Hi All,
In the past I have successfully programmed snippets of code in VBA and other languages … but I am struggling with counting in ProRealTime.
Having played with the variables and ran it in ProBacktest – it’s not getting much clearer to me.
What I am trying to do is Buy or Sell based on Condition 1 (C1) or Condition 2 (C2) respectively and close at the end of what would be the same 5 minute bar.
As I need to buy at the beginning of the 5 min candle and sell at the end, I have set the bar to 10 second so that I can buy 10 seconds after C1 or C2 is satisfied (beginning of second bar) and then count 29 more bars to close after 5 minutes i.e. 300 seconds.
123456789101112131415161718192021222324252627282930313233343536373839404142// SET MARKET TIME TO 10 seconds//DEFPARAM stuff hereIF time < 145000 THENstake = 1x = 1ENDIF// time entry and exit limits hereIF timeEnterbefore AND timeEnterAfter AND NOT daysForbiddenEntry THENIF x = 1 THENIF NOT ShortOnMarket AND C1 THENBUY stake PERPOINT AT MARKETSET STOP pLOSS 20 // Safety StopENDIFIF NOT LongOnMarket AND C2 THENSELLSHORT stake PERPOINT AT MARKETSET STOP pLOSS 20ENDIFENDIF//End of Buying section and if nothing bought then onto bar increment x anywayx = x + 1IF x = 30 THENIF LongOnMarket THENSELL stake PERPOINT at MARKETENDIFIF ShortOnMarket THENEXITSHORT stake PERPOINT at MARKETENDIFx = 1ENDIFENDIFWhen run on Probacktest I get counts of 29 and other times 95 or other number of bars on the market.
I did start using a FOR/Next loop but had other problems …
Any ideas most welcome, Thank you!
09/11/2018 at 4:33 PM #8018709/11/2018 at 4:59 PM #8019309/11/2018 at 5:02 PM #80194The variables TimeEnterBefore = 150000 and TimeEnterAfter = 210000
I’m not sure you gave me the right values 🙂 It should be 2 boolean variables, and they are not!
09/11/2018 at 6:05 PM #8019709/11/2018 at 7:04 PM #80199Hi Nicolas,
Thank you for your time … suggesting ‘Graph x’ has allowed me to see step by step what is going on.
I haven’t figured out yet why I am losing a count of one but feel confident that being able to zoom in and examine the execution of the code in relation to the count of ‘x’ using ‘Graph’ I’ll have it sorted.
Thank you for your patience and advice.
Joe
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on