If and While structure
Forums › ProRealTime English forum › ProBuilder support › If and While structure
- This topic has 7 replies, 3 voices, and was last updated 6 years ago by PEDRAM.JOKAR.
-
-
12/09/2017 at 1:13 PM #55213
Dear All
I want to code as when 2 of my conditions met then waiting for another condition to be happened to enter short and if c1 happened exit loop. please confirm below code will do what i need. with thanks.
12345678IF C2 AND C4 THENWHILE C6 DOSELLSHORT 1 CONTRACT AT MARKETIF C1 THENBREAKENDIFWENDENDIF12/09/2017 at 3:22 PM #55219A strategy with this code will either never enter the WHILE loop if C6 is false or never exit that loop if C6 is true, since C6 and C1 are not modified once you are within the loop.
Roberto
1 user thanked author for this post.
12/12/2017 at 12:13 AM #55440can you pls guide me a code that , if c1 happened wait for c2 to happen then enter market and if c3 happened cancel the first if confirmation and exit the loop?
with thanks.
12/12/2017 at 5:12 AM #55443by the way, c1 will not persist. is a crossover
12/12/2017 at 9:15 AM #5545212/12/2017 at 12:14 PM #554831234567891011DEFPARAM CUMULATEORDERS=FALSETREND = CALL "Pedi's Trend Detector"K = CALL "STOCH K"C1= TREND CROSSES OVER 0C2=K CROSSES OVER K[1]C3=TREND>0//NEED TO BE COMPLETED. WHEN C1 HAPPEN WAIT UNTIL C2 HAPPEN WHEN C3 ALSO PERSISTS TO ENTER MARKET.NEED TO BE COMPLETED. WHEN C1 HAPPEN WAIT UNTIL C2 HAPPEN WHEN C3 ALSO PERSISTS TO ENTER MARKET
12/12/2017 at 1:27 PM #55492Ok Pedi’s! Let’s try with this code. 🙂
You need first to store the fact that C1 has crossed, and there are 2 ways to know it has, first one is a test through the last X bars:
12x = 10 //last 10 bars will be testedtestC1 = summation[x](c1)>0 //c1 was true at least one time in the last X barsor you can store the variable like this (but you’ll need to reset it to 0 when another trigger, but it depends on your strategy… so I do not when you’d like to reset the C1 has crossed)
123if c1 thentestc1 = 1endifNow that you know your c1 condition is true, let’s check the other conditions and put an order at market:
123if testc1 and c2 and c3 thenbuy 1 contract at marketendif1 user thanked author for this post.
12/12/2017 at 4:55 PM #55511Thanks for clarifying advice, Nicolas.
-
AuthorPosts
Find exclusive trading pro-tools on