Hello, I’m trying to add Bollinger bands into my code, I have used the “insert function” tab to add the upper and lower band into my code. It gives the option to select the period in brackets. How can I adjust the standard deviation?
if mastrategy then //moving average trade entry
macrossbuy = open crosses over BollingerUp[20](close)
macrosssell = open crosses under BollingerDown[20](close)
I want the bot to take a buy trade when the price crosses over the upper bollinger, and a sell trade when the price crosses under the the lower bollinger.
I need to be able to adjust both the the bollinger band period and standard deviation.
thanks
You can’t change the built-in standard deviation. To do this, you need to code the BB yourself. This the code to be used in your strategy:
BB = 20 //20 periods
BBdev = 2.0 //2.0 standard deviation
BBavg = average[BB,0](close) //BB mean (middle line)
UPboll = BBavg + ((std[BB](close)) * BBdev) //BB Upper Band
LOboll = BBavg - ((std[BB](close)) * BBdev) //BB Lower Band
Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
Below you can read the basic rules (highlighted in yellow).
Thank you 🙂
You’ve already been given an answer (above).
The double post was accidental i havent used this platform much at all and couldn’t see that my first post successfully got submitted.