iD EMARSI on Chart — Strategy by ennoiD
By ennoiD
Performance Metrics
- Author: ennoiD
- Symbol: COINBASE:BTCUSD
- Timeframe: 1 day
- Net P&L: +1,956.87 USD (+65.23%)
- Win Rate: 83.3%
- Profit Factor: 10.953
- Max Drawdown: 169.55 USD (4.27%)
- Total Trades: 54
- Sharpe Ratio: 0.201
Description
Mar 15SCRIPT OVERVIEWThe EMARSI indicator is an advanced technical analysis tool that maps RSI values directly onto price charts. With adaptive scaling capabilities, it provides a unique visualization of momentum that flows naturally with price action, making it particularly valuable for FOREX and low-priced securities trading.KEY FEATURES1 PRICE MAPPED RSI VISUALIZATIONUnlike traditional RSI that displays in a separate window, EMARSI plots the RSI directly on the price chart, creating a flowing line that identifies momentum shifts within the context of price action:Pine Script®// Map RSI to price chart with better scalingmappedRsi = useAdaptiveScaling ? median + ((rsi - 50) / 50 * (pQH - pQL) / 2 * math.min(1.0, 1/scalingFactor)) : down == pQL ? pQH : up == pQL ? pQL : median - (median / (1 + up / down))2 ADAPTIVE SCALING SYSTEMThe script features an intelligent scaling system that automatically adjusts to different market conditions and price levels:Pine Script®// Calculate adaptive scaling factor based on selected methodscalingFactor = if scalingMethod == "ATR-Based" math.min(maxScalingFactor, math.max(1.0, minTickSize / (atrValue/avgPrice)))else if scalingMethod == "Price-Based" math.min(maxScalingFactor, math.max(1.0, math.sqrt(100 / math.max(avgPrice, 0.01))))else // Volume-Based math.min(maxScalingFactor, math.max(1.0, math.sqrt(1000000 / math.max(volume, 100))))Expand 2 lines3 MODIFIED RSI CALCULATIONEMARSI uses a specially formulated RSI calculation that works with an adaptive base value to maintain consistency across different price ranges:Pine Script®// Adaptive RSI Base based on price levels to improve flowadaptiveRsiBase = useAdaptiveScaling ? rsiBase * scalingFactor : rsiBase// Calculate RSI components with adaptivityup = ta.rma(math.max(ta.change(rsiSourceInput), adaptiveRsiBase), emaSlowLength)down = ta.rma(-math.min(ta.change(rsiSourceInput), adaptiveRsiBase), rsiLengthInput)// Improved RSI calculation with value constraintrsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))Expand 4 lines4 MOVING AVERAGE CROSSOVER SYSTEMThe indicator creates a smooth moving average of the RSI line, enabling a crossover system that generates trading signals:Pine Script®// Calculate MA of mapped RSIrsiMA = ma(mappedRsi, emaSlowLength, maTypeInput)// Strategy entriesif ta.crossover(mappedRsi, rsiMA) strategy.entry("RSI Long", strategy.long)if ta.crossunder(mappedRsi, rsiMA) strategy.entry("RSI Short", strategy.short)Expand 3 lines5 VISUAL REFERENCE FRAMEWORKThe script includes visual guides that help interpret the RSI movement within the context of recent price action:Pine Script®// Calculate pivot high and lowpQH = ta.highest(high, hlLen)pQL = ta.lowest(low, hlLen)median = (pQH + pQL) / 2// Plottingplot(pQH, "Pivot High", color=color.rgb(82, 228, 102, 90))plot(pQL, "Pivot Low", color=color.rgb(231, 65, 65, 90))med = plot(median, style=plot.style_steplinebr, linewidth=1, color=color.rgb(238, 101, 59, 90))Expand 4 lines6 DYNAMIC COLOR SYSTEMThe indicator uses color fills to clearly visualize the relationship between the RSI and its moving average:Pine Script®// Color fills based on RSI vs MAcolUp = mappedRsi > rsiMA ? input.color(color.rgb(128, 255, 0), '', group= 'RSI > EMA', inline= 'up') : input.color(color.rgb(240, 9, 9, 95), '', group= 'RSI rsiMA ? input.color(color.rgb(0, 230, 35, 95), '', group= 'RSI > EMA', inline= 'up') : input.color(color.rgb(255, 47, 0), '', group= 'RSI rsiMA ? pQH : rsiMA, mappedRsi > rsiMA ? rsiMA : pQL, colUp, colDn)Expand 1 line7 REAL TIME PARAMETER MONITORINGA transparent information panel provides real-time feedback on the adaptive parameters being applied:Pine Script®// Information displayvar table infoPanel = table.new(position.top_right, 2, 3, bgcolor=color.rgb(0, 0, 0, 80))if barstate.islast table.cell(infoPanel, 0, 0, "Current Scaling Factor", text_color=color.white) table.cell(infoPanel, 1, 0, str.tostring(scalingFactor, "#.###"), text_color=color.white) table.cell(infoPanel, 0, 1, "Adaptive RSI Base", text_color=color.white) table.cell(infoPanel, 1, 1, str.tostring(adaptiveRsiBase, "#.####"), text_color=color.white)Expand 2 linesBENEFITS FOR TRADERSINTUITIVE MOMENTUM VISUALIZATIONBy mapping RSI directly onto the price chart, traders can immediately see the relationship between momentum and price without switching between different indicator windows.ADAPTIVE TO ANY MARKET CONDITIONThe three scaling methods (ATR-Based, Price-Based, and Volume-Based) ensure the indicator performs consistently across different market conditions, volatility regimes, and price levels.PREVENTS EXTREME VALUESThe adaptive scaling system prevents the RSI from generating extreme values that exceed chart boundaries when trading low-priced securities or during high volatility periods.CLEAR TRADING SIGNALSThe RSI and moving average crossover system provides clear entry signals that are visually reinforced through color changes, making it easy to identify potential trading opportunities.SUITABLE FOR MULTIPLE TIMEFRAMESThe indicator works effectively across multiple timeframes, from intraday to daily charts, making it versatile for different trading styles and strategies.TRANSPARENT PARAMETER ADJUSTMENTThe information panel provides real-time feedback on how the adaptive system is adjusting to current market conditions, helping traders understand why the indicator is behaving as it is.CUSTOMIZABLE VISUALIZATIONMultiple visualization options including Bollinger Bands, different moving average types, and customizable colors allow traders to adapt the indicator to their personal preferences.CONCLUSIONThe EMARSI indicator represents a significant advancement in RSI visualization by directly mapping momentum onto price charts with adaptive scaling. This approach makes momentum shifts more intuitive to identify and helps prevent the scaling issues that commonly affect RSI-based indicators when applied to low-priced securities or volatile markets.Mar 15Release Notes[h1]Overview of EMARSI Strategy[/h1][h2]Signal Generation[/h2]The script now generates signals based directly on RSI/MA crossovers:- Bullish Signal: When mapped RSI crosses above its MA- Bearish Signal: When mapped RSI crosses below its MA- Option to require minimum trend duration before triggeringPine Script®// Detect crossoversbullishCross = ta.crossover(mappedRsi, rsiMA)bearishCross = ta.crossunder(mappedRsi, rsiMA)// Simplified signal generationbool validBullishSignal = bullishCross and (not useFilteredSignals or bearishTrendBars >= minTrendDuration)bool validBearishSignal = bearishCross and (not useFilteredSignals or bullishTrendBars >= minTrendDuration)Expand 2 lines[h2]Key Components[/h2]- Custom RSI calculation with adaptive scaling options- Mapped RSI that aligns the indicator with price chart- Simple moving average of the mapped RSI for crossover detection- Trend duration tracking to filter signalsPine Script®// Calculate RSI components with adaptivityup = ta.rma(math.max(ta.change(rsiSourceInput), adaptiveRsiBase), emaSlowLength)down = ta.rma(-math.min(ta.change(rsiSourceInput), adaptiveRsiBase), rsiLengthInput)// RSI calculation with value constraintrsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))// Map RSI to price chartmappedRsi = useAdaptiveScaling ? median + ((rsi - 50) / 50 * (pQH - pQL) / 2 * math.min(1.0, 1/scalingFactor)) : down == pQL ? pQH : up == pQL ? pQL : median - (median / (1 + up / down))Expand 6 lines[h2]Visualization Elements[/h2]- RSI line and MA line with toggleable visibility- Signal arrows at crossover points- Color fills to indicate bullish/bearish conditions- Bollinger Bands option for additional referencePine Script®// Signal visualizationplotshape(showSignalMarkers and validBullishSignal, "Bullish Signal", style=shape.triangleup, location=location.belowbar, color=color.new(bullSignalColor, 0), size=size.large)plotshape(showSignalMarkers and validBearishSignal, "Bearish Signal", style=shape.triangledown, location=location.abovebar, color=color.new(bearSignalColor, 0), size=size.large)Expand 3 lines[h2]Strategy Implementation[/h2]- Entry signals on RSI/MA crossovers- Optional trend duration filter to reduce false signals- Trailing stop and take profit options for exits- Position sizing controlPine Script®// Strategy executionif bullishCross strategy.entry("Bull Signal", strategy.long, qty=positionSize, comment="Buy") if bearishCross strategy.entry("Bear Signal", strategy.short, qty=positionSize, comment="Sell")// Apply trailing stop and take profitif enableTrailingStop strategy.exit("Bull Trail", "Bull Signal", trail_points=close * trailingStopPercent / 100 * syminfo.pointvalue, trail_offset=0)Expand 7 lines[h2]Information Display[/h2]- Current scaling factor and RSI base values- Current trend direction and duration- Total bullish and bearish signals generatedPine Script®// Information displayvar table infoPanel = table.new(position.top_right, 2, 6, bgcolor=color.rgb(0, 0, 0, 80))if barstate.islast table.cell(infoPanel, 0, 2, "Current Trend", text_color=color.white) table.cell(infoPanel, 1, 2, mappedRsi > rsiMA ? "Bullish" : "Bearish", text_color=mappedRsi > rsiMA ? bullSignalColor : bearSignalColor) table.cell(infoPanel, 0, 3, "Trend Duration", text_color=color.white) table.cell(infoPanel, 1, 3, str.tostring(mappedRsi > rsiMA ? bullishTrendBars : bearishTrendBars), text_color=color.white)Expand 4 lines[h2]Recent Fixes[/h2]- Fixed plotshape syntax to be compatible with Pine Script v6- Removed complex staging system in favor of direct signals- Simplified codebase for better performance and clarity- Added toggle options for better control over visualizationPine Script®// Fixed plotshape calls// OLD (causing errors):// plotshape(showSignalMarkers and validBullishSignal ? true : na, ...)// NEW (fixed for Pine v6):plotshape(showSignalMarkers and validBullishSignal, ...)Expand 1 lineThe strategy is now focused solely on generating signals from RSI/MA crossovers, making it easier to understand and more reliable in signal generation.