Bollinger band error
Forums › ProRealTime English forum › ProOrder support › Bollinger band error
- This topic has 4 replies, 2 voices, and was last updated 1 year ago by 8278sv.
-
-
03/20/2023 at 11:02 PM #211848
Hi
I seem to be getting unexpected results when testing a strategy on Bollinger bands. For the purposes of trying to work out what the issue is, I’ve totally stripped down the code to just the below – from this it seems to be an issue with bollinger bands alone. Was wondering if anyone else had this issue.
It doesnt enter when I thought it should. I.e. when the close is above the lower bollinger band. INstead it enters at some random point – see screen shot. THis is EUR USD (1 hour)
123456bbl = BollingerDown[20](close)Bullish0 = close >= bblIF Bullish0 THENbuy 1 perpoint AT MARKET03/21/2023 at 8:15 AM #21185503/21/2023 at 10:56 AM #211866Hi Nicolas. It is set at the same properties. But looks like I made an error – many, many apologies all! The real issue seems to be with the average true range. I didnt include it in the previous message as didnt think there was an issue with this. Anyhow see below – full code. Any idea what the problem can be? I want to use the atr as part of the buy and stop loss as a risk management method. When i change it to for example ‘buy 1 perpoint at market’ and similar for stop loss then it seems to work fine.
123456789101112131415161718192021222324252627// Conditions to enter long positionsdefparam cumulateorders=falsebbu1 = BollingerUp[20](close)bbl1 = BollingerDown[20](close)atr= averagetruerange[1](close)Bullish0 = close >= bbl1IF Bullish0 THENbuy (10/(2.5*atr)) perpoint AT MARKETset stop loss (2.5*atr)ENDIFc1 = (close crosses over bbu1)IF c1 THENSELL AT MARKETENDIF03/21/2023 at 12:54 PM #211871Ok so the problem is located in your contract size calculation, if the size is too small, then no order will be triggered.
I suggest you set a minimal contract size like this:
123minSize = 0.1 //define here what would be the minimal sizebuy max(minSize,(10/(2.5*atr))) perpoint AT MARKET1 user thanked author for this post.
03/21/2023 at 3:31 PM #211881 -
AuthorPosts