OPEN-SOURCE SCRIPT

Bollinger Bands strategy with RSI and MACD v1.0

This is a strategy based on the Bollinger Bands, where buy trades are made when the price crosses the lower line of the Bollinger Bands upwards, and sell trades are made when the price crosses the upper line downwards.

In addition, it is possible through the inputs to enable trading with RSI and MACD, so that buy or sell trades are supported by these two indicators.

Trades are partially and fully closed in the following way, a buy trade will close half of the position when the price touches the middle line of the Bollinger bands and will be fully closed when the price touches the upper band. In the case of a sell position, half of the position will be closed if the price touches the middle band and the entire position will be closed when the price touches the lower band. Alternatively, a fixed take profit can be placed. In case the price moves against us, trailing stops can be placed.

In case of selecting to use RSI, MACD, or MACD variation, trades will be executed as long as The Bollinger Bands, and all the above-mentioned indicators give the same signals, either buy or sell.

For example in the case of selecting only Use RSI, buy trades would be made as long as RSI and BB give buy signals.

Strategy inputs:

-BB source: Bollinger Bands price source.

-Bollinger Bands SMA length: Bollinger Bands simple moving average length.

-Bollinger Bands StdDev length: Bollinger Bands standard deviation length.

-Trail Long Loss (%): Distance in percentage at which the stop loss will initially be placed for buy trades.

-Trail Short Loss (%): Distance in percentage at which the stop loss will be initially placed for sell trades.

-Maximum orders: Maximum of simultaneous operations, for example, if it is 3, up to 3 parallel operations of buy and up to 3 parallel operations of sell will be carried out.

-Position size: Number of contracts per trade.

-Use RSI: If selected, the strategy will also trade based on oversold or overbought signals provided by the RSI.

-RSI source: RSI price source.

-RSI period: The RSI period to use.

-RSI value for buy: If the RSI is below this value, it will give a buy signal.

-RSI value for sell: If the RSI value is above this value, it will give a sell signal.

-Use MACD: If selected, buy trades will be made when the MACD crosses 0 upwards, and sell trades will be made when the MACD crosses 0 downwards.

-Use MACD variation: Only available if MACD is previously selected. In this case, buy trades are made if the MACD value in the last 3 candles has been decreasing, and sell trades are made if the MACD value has been increasing.

-MACD source: MACD price source.

-MACD fast length: MACD fast EMA lenght.

-MACD slow length: MACD slow EMA lenght.

-MACD signal length: MACD signal EMA lenght.

-Use maximum TP long: If selected, a fixed take profit will be placed for buy trades. The position could be closed before reaching this take profit if the price touches one of the lower or upper lines first.

-Maximum take profit long (%): Distance in percentage at which the take profit will be placed for buy trades.

-Use maximum TP short: if selected, a fixed take profit will be placed for sell trades. The position could be closed before reaching this take profit if the price touches one of the lower or upper lines first.

-Maximum take profit short (%): Distance in percentage at which the take profit will be set for sell trades.

I hope you like it and as always all feedback is welcome.
Bollinger Bands (BB)Moving Average Convergence / Divergence (MACD)Relative Strength Index (RSI)rsimacd

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור