Al Brooks Price Action with MACD Signals - Strategy - Rev 0.0
This code implements a trading strategy based on AL Brooks' price action principles, incorporating MACD (Moving Average Convergence Divergence) signals for confirmation. The strategy aims to identify potential buy and sell opportunities by analyzing price movements relative to a moving average and the MACD indicator.
I. Introduction:
Trading strategy based on Al Brooks' price action and MACD. Designed for TradingView platform. II. Inputs (User-Defined Parameters):
length: Moving average length. riskRewardRatio: Risk/reward ratio for trades. stopLossBuffer: Stop-loss buffer percentage. candleType: Price source (close or open). III. Indicators:
sma: Simple Moving Average (calculated based on length). macdLine, signalLine: MACD lines (using standard 12, 26, 9 periods). price: Price used for calculations (either close or open based on candleType). IV. Trend Identification:
uptrend: Price > SMA. downtrend: Price < SMA. V. Signal Generation:
buySignal: Uptrend AND macdLine > 0 AND macdLine crosses above signalLine. sellSignal: Downtrend AND macdLine < 0 AND macdLine crosses below signalLine. VI. Trade Execution:
Buy (Long) Entry: Triggered by buySignal. longStopLoss: Calculated based on close price and stopLossBuffer. longTakeProfit: Calculated based on close price, longStopLoss, and riskRewardRatio. strategy.entry("Buy", strategy.long): Enters a long position. strategy.exit("Take Profit", "Buy", limit=longTakeProfit, stop=longStopLoss): Sets take-profit and stop-loss orders. Sell (Short) Entry: Triggered by sellSignal. shortStopLoss: Calculated based on close price and stopLossBuffer. shortTakeProfit: Calculated based on close price, shortStopLoss, and riskRewardRatio. strategy.entry("Sell", strategy.short): Enters a short position. strategy.exit("Take Profit", "Sell", limit=shortTakeProfit, stop=shortStopLoss): Sets take-profit and stop-loss orders. VII. Position Closing:
strategy.close("Sell"): Closes any open short positions when neither buySignal nor sellSignal is active. strategy.close("Buy"): Closes any open long positions when neither buySignal nor sellSignal is active. VIII. Visualizations (Plots):
plotarrow: Plots buy (green) and sell (red) signals as arrows. plot: Plots SMA (blue), support (green stepline), and resistance (red stepline) levels. Support and resistance are based on the lowest and highest prices over the length period. IX. Alerts:
alertcondition: Triggers alerts for buy and sell signals. X. Licensing:
Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans des publications est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.