Strategy Overview: Dynamic Grid & Martingale Bot (v6) by ozerh07

By ozerh07

Performance Metrics

Description

This is the English documentation for your Dynamic Grid & Martingale Strategy. You can use these descriptions for professional record-keeping or within the code comments.## Strategy Overview: Dynamic Grid & Martingale Bot (v6)This strategy is designed for trend-following automated trading with a built-in recovery mechanism. It combines momentum filters (ADX & EMA) with a Martingale-style "cost-averaging" logic to lower the break-even point during minor pullbacks.### 1. Key Technical LogicTrend Filter: The bot only enters a position if the trend is strong and bullish.ADX > 15: Ensures there is sufficient directional strength in the market.Price > EMA 200: Ensures the asset is in a long-term uptrend.Martingale Engine: If the price drops by a specific percentage (e.g., 2%) after the first entry, the bot automatically adds to the position.Multiplier: The position size increases by the martingaleMultiplier factor to lower the average cost.Take Profit (TP): The strategy exits the entire position once the price reaches a 1.5% profit above the Average Position Price (not the initial entry price).### 2. Input ParametersParameter DescriptionTake Profit (%) The target percentage for closing the entire position in profit.Martingale Multiplier The factor by which the position size is increased during a pullback.Drop Pct (%) The percentage drop from the average price required to trigger an additional buy.ADX Threshold The minimum ADX value required to confirm a strong trend.Time Filter Restricts the bot to operating only during specific exchange hours (e.g., BIST hours).### 3. Code Documentation (Technical English)strategy.position_avg_price: Calculates the break-even point dynamically as new orders are filled.ta.dmi: Used to calculate the ADX value for trend strength validation.alert_message: Contains a JSON-formatted string designed to communicate directly with Osmanlı Yatırım webhooks for automated execution.plot.style_linebr: Visualizes the average cost and target price only when a trade is active to keep the chart clean.### 4. Risk WarningNote: Martingale strategies involve significant risk. While cost-averaging helps recover from small dips, an extended downtrend (bear market) can lead to rapid capital depletion. It is recommended to use this strategy on BIST 30 blue-chip stocks with high liquidity.### 5. How to DeployCopy the code into the TradingView Pine Editor.Add to Chart and ensure the ADX/EMA Status Table is visible in the top right.Set an Alert with the condition set to the strategy name.Enable Webhook URL and paste your broker's endpoint.Message box must contain: {{strategy.order.alert_message}} for automated order routing.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView