Storing a met condition in a previous bar
Forums › ProRealTime English forum › ProOrder support › Storing a met condition in a previous bar
- This topic has 24 replies, 3 voices, and was last updated 5 years ago by
Mike Boorman.
-
-
01/05/2020 at 9:06 PM #115967
On the 3rd the average cross happened and crossflag was set to 1 and averagecrosslong was set to 1 but abovebollinger is 0.
On the 4th crossflag is still valid but abovebollinger is still 0 so no order is sent.
On the 5th crossflag switches to 0 because an order is sent to buy and abovebollinger is set to 1 because that condition is now true.
On the open of the 6th a trade is opened.
Everything is as it should be.
I would suggest graphing the value of the averages in your code and double check that they are the same as those on your chart.
01/05/2020 at 9:34 PM #115968So I’ve graphed the instrument values (see first screengrab). Now we can see the problem (finally!)
“Boll middle” is listed as 10,158
“Average[21]” is listed as 10,274
They are different values, but I’ve been working on the basis that Average[21] in code should refer to the black “Boll Middle” line. I’m using “Average[21]” because it is suggested to me as the code for the middle bollinger (as you can see from the other screengrab).
What is the code I should use to make sure I call up “Boll Middle” from Pro Order?
01/05/2020 at 10:35 PM #115974Check in your Bollinger Band indicator settings that everything is the same. Perhaps you have it set to use a simple average instead of an exponential average or maybe it is based on a different price to closing price?
Also consider using BOLLINGERUP and BOLLINGERDOWN and calculating the mid point between them.
.
01/05/2020 at 10:55 PM #115978It’s just the standard 21, 0.1 based on close (see screengrab). I’ve tried every combination in that box to try and return the value of 10,274, but none of them do. I can’t understand why indicator Average[21] is returning 10,274. There is also disparity between the EMoving Average 8 reading and my coded ExponentialAverage[8].
Is “Average[21](close)” the right syntax here? Or is there something else I should use?
01/05/2020 at 11:19 PM #115980You have something set wrong as your code uses a simple 21 period moving average of closing price. I have drawn it on my own chart four ways and they are all identical.
- Simple Bollinger mid line.
- Average[21](close) returned
- Average[21,0](close) returned
- and the PRT built in average indicator.
01/05/2020 at 11:26 PM #115982These are the only settings I can see for the Bollinger (see screengrabs). What should I change?
01/05/2020 at 11:46 PM #115985They are all the same for me!!!!
1 user thanked author for this post.
01/06/2020 at 2:34 PM #116060I tried to create a new chart from scratch and I got the same disparity. I then created a whole load of charts on different markets and there was no problem! It seems this is exclusive to the Bitcoin DFB chart (XBTUSD) on PRT linked to IG.
Thank you for your help. It is useful for me in future to know that I can graph instruments to double check unusual results.
01/06/2020 at 4:41 PM #116076Yes GRAPH and GRAPHONPRICE are very useful debugging tools.
I would send a technical report to PRT via your platform regarding the Bitcoin averaging problem if I was you (although it will go via IG so PRT may never receive it!)
01/08/2020 at 1:51 PM #116198On a similar theme to the above system, I’m trying to store met conditions for an entry that will only occur a number of bars after the first condition.
There are three entry rules for this system:
RSI goes above 80
RSI then drops below 75
RSI then rises above 80 again
I’ve coded it with similar principles to how you coded the two-rule code earlier in this thread, but I knew that it wouldn’t work because in code the first rule appears exactly the same as the third rule. When I use only the first two rules, it correctly enters when RSI drops below 75, so how do I store the first two conditions and then code a third rule to work after the first two? I’m aware that I can change the first and second rules to only act in previous bars with [5] or [6] for example, but this seems messy. Is there a clean way of creating three rules that act sequentially?
Three-rule code1234567891011121314151617181920212223242526272829303132DEFPARAM CumulateOrders = Falsefirstshortrule = RSI[6](close) >80secondshortrule = RSI[6](close) <75thirdshortrule = RSI[6](close) >80if firstshortrule and not firstshortrule[1] thenrise = 1endifif secondshortrule and not secondshortrule[1] thendrop = 1endifif thirdshortrule and not thirdshortrule[1] thensecondrise = 1endifif rise = 1 and drop = 1 thentworules = 1endifif tworules = 1 and secondrise = 1 thensellshort 1 perpoint at marketrise = 0drop = 0tworules= 0secondrise = 0endifset stop ptrailing 15 -
AuthorPosts
Find exclusive trading pro-tools on