TV to PRT
Forums › ProRealTime English forum › ProBuilder support › TV to PRT
- This topic has 1 reply, 2 voices, and was last updated 17 hours ago by
Iván.
Viewing 2 posts - 1 through 2 (of 2 total)
-
-
07/29/2025 at 1:23 PM #249195
Hi everyone, I know that’s a complex one, but definitely a solid one… Would be nice to see if anyone can translate this code to PRT… Thanks a lot and happy trading
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850//@version=5indicator("MARKET STRUCTURE", max_lines_count=500, max_labels_count=500, behind_chart=false) // SMM v5.01var bool disableWarning = false//Signals Inputsvar signalsGroupName = '----- Signal Settings -----'enableBuySellSignals = input.bool(true,title='Enable Buy & Sell Signals', group=signalsGroupName)enableBuySellPrice = input.bool(true,title='Enable Buy & Sell Price', group=signalsGroupName)buySignalColor = input.color(color.new(#4caf50, 0),'Buy Signal Color', group=signalsGroupName)sellSignalColor = input.color(color.new(#b22833, 0), 'Sell Signal Color', group=signalsGroupName)enableChopFilter = input.bool(true, title='Enable Chop Filter', group=signalsGroupName, tooltip='This helps to reduce signals during choppy markets, and will produce less signals overall when enabled.')enableMaFilter = input.bool(true, 'Enable MA Filter',group=signalsGroupName)maFilterType = input.string("EMA","MA Filter Type", options = ["EMA", "SMA", "VWMA", "RMA" , "Hull"],group=signalsGroupName)maFilterLength = input.int(200, 'MA Filter Period', minval=1,group=signalsGroupName)maFilterColor = input.color(color.new(color.white, 0), 'MA Filter Color', group=signalsGroupName)enableTimeFilter = input.bool(false,title='Enable Time Filter', group=signalsGroupName)usersTimezone = input.string('GMT-5', "Your Timezone", options = ['GMT-12','GMT-11','GMT-10','GMT-9','GMT-8','GMT-7','GMT-6','GMT-5','GMT-4','GMT-3','GMT-2','GMT-1','GMT+0','GMT+1','GMT+2','GMT+3','GMT+4','GMT+5','GMT+6','GMT+7','GMT+8','GMT+9','GMT+10','GMT+11','GMT+12','GMT+13','GMT+14'], group=signalsGroupName)startEndTime = input.session("0930-1600", "Start - End Time", group=signalsGroupName)// Profit Inputsvar profitWaveGroupName = '----- Profit Settings -----'enableProfitLines = input.bool(true, title='Enable Profit Target Lines', group=profitWaveGroupName)profitTarget = input.int(20, title='Profit Target (Ticks/Pips/Cents)', group=profitWaveGroupName, tooltip='Profit target value is based on the minimum move of the instrument. For Futures that is ticks, FX is pips, Stocks are cents, etc.')profitTargetMaxLines = input.int(10, title='Max Profit Target Lines', group=profitWaveGroupName, tooltip='Maximum amount of profit target lines to display on your chart.')profitTargetColor = input.color(color.new(color.yellow, 0),'Profit Target Lines Color', group=profitWaveGroupName)enableProfitWave = input.bool(true, "Enable Profit Wave", group=profitWaveGroupName)profitWaveUpperBullishColor = input.color(color.new(#00ff8480, 50),'Profit Wave Bullish Top Color', group=profitWaveGroupName)profitWaveLowerBullishColor = input.color(color.new(color.green, 50), 'Profit Wave Bullish Bottom Color', group=profitWaveGroupName)profitWaveLowerBearishColor = input.color(color.new(#8c0000, 50), 'Profit Wave Bearish Top Color', group=profitWaveGroupName)profitWaveUpperBearishColor = input.color(color.new(#ff0000, 50),'Profit Wave Bearish Bottom Color', group=profitWaveGroupName)// Background Trend Inputsvar backgroundTrendGroupName = '----- Background Trend Settings -----'enableBgColor = input.bool(true, "Enable Background Trend Color", group=backgroundTrendGroupName)bgTrendBullishCol = input.color(color.new(#66ff00, 70),'Bullish Background Color', group=backgroundTrendGroupName)bgTrendBearishCol = input.color(color.new(#ff0000, 70), 'Bearish Background Color', group=backgroundTrendGroupName)// Candle Coloring Inputsvar candleSettings = "----- Candle Settings -----"bullishCandleColor = input.color(color.new(#089981, 0),'Bullish Candle Color', group=candleSettings)bearishCandleColor = input.color(color.new(#f23645, 0), 'Bearish Candle Color', group=candleSettings)enableTrendCandleColoring = input.bool(true,title='Enable Candle Color Matching', group=candleSettings)candleColoringType = input.string("Profit Wave",title='Match Candle Colors To', options=["Profit Wave","Trend"], group=candleSettings)// Support / Resistance Inputsvar sdGroupName = '----- Support & Resistance Settings -----'ensr = input.bool(true,title='Enable Support & Resistance Lines', group=sdGroupName)resistanceColor = input.color(#ff0000,'Resistance Lines Color', group=sdGroupName)supportColor = input.color(#66ff00,'Support Lines Color', group=sdGroupName)srStyle = input.string("Dotted", options=["Dashed", "Dotted", "Solid"], title="Support & Resistance Lines Style", group=sdGroupName)srLineWidth = input.int(2, "Support & Resistance Lines Width", minval=1, maxval=5, step=1, group=sdGroupName)extendLinesType = input.string('Close', title='Extend Lines Until', options=['Touch', 'Close'], group=sdGroupName, tooltip='Extend the lines until price touches them or a candle closes beyond them.')pivotchopSensitivity = 20maxSrLines = 50// Real Price Inputsvar rplGroupName = '----- Real Price Settings -----'showrealprice = input(false, title="Enable Real Price Line", group=rplGroupName)extendLine = input(false, title="Extend Real Price Line", group=rplGroupName)showrealpricelinecolor = input(color.new(color.white, 0), title="Real Price Line Color", group=rplGroupName)realpricewidth = input.string("Thin", options=["Thin", "Thick"], title="Real Price Line Width", group=rplGroupName)realpricestyle = input.string("Dotted", options=["Dotted", "Solid", "Dashed"], title="Real Price Line Style", group=rplGroupName)plotrealsrcClosedots = input.bool(true, title="Enable Real Close Price Dots", group=rplGroupName)realsrcClosecolour = input(color.new(color.white, 0), title="Real Close Price Dot Color", group=rplGroupName)size = input.string("Small", options=["Auto", "Small", "Large"], title="Real Close Price Dot Size", group=rplGroupName)// Matrix Inputsvar matrixGroupName = '----- Matrix Settings -----'var matrixInlineName = "matrixInlineName"matrixStyle = input.string("Horizontal", "Layout Style", options=["Horizontal", "Vertical"], group=matrixGroupName)matrixPosition = input.string("Bottom Right", "Location On Chart", options=["Top Left", "Top Center", "Top Right", "Bottom Left", "Bottom Center", "Bottom Right"], group=matrixGroupName)matrixTimeframeColor = input.color(color.purple,'Timeframe Cell Color', group=matrixGroupName, inline="matrixTimeframeColors")matrixTimeframeTextColor = input.color(color.white,'Text Color', group=matrixGroupName, inline="matrixTimeframeColors")enableMatrixTF1 = input.bool(true, "Enable Matrix Timeframe 1", group=matrixGroupName, inline="matrixRow1")matrixTF1 = input.timeframe("1", "", group=matrixGroupName, inline="matrixRow1")enableMatrixTF2 = input.bool(true, "Enable Matrix Timeframe 2", group=matrixGroupName, inline="matrixRow2")matrixTF2 = input.timeframe("2", "", group=matrixGroupName, inline="matrixRow2")enableMatrixTF3 = input.bool(true, "Enable Matrix Timeframe 3", group=matrixGroupName, inline="matrixRow3")matrixTF3 = input.timeframe("5", "", group=matrixGroupName, inline="matrixRow3")matrixColumn1 = input.bool(true, "Show Avg True Range (ATR)", group=matrixGroupName)matrixAtrLength = input.int(defval=3, minval=1, title="Avg True Range (ATR) Length", group=matrixGroupName)matrixAtrColor = input.color(color.blue,'ATR Cell Color', group=matrixGroupName, inline="matrixAtrColors")matrixAtrTextColor = input.color(color.white,'Text Color', group=matrixGroupName, inline="matrixAtrColors")matrixColumn2 = input.bool(true, "Show Current Candle Column", group=matrixGroupName)matrixColumn3 = input.bool(true, "Show Trend Column", group=matrixGroupName)matrixColumn4 = input.bool(true, "Show Profit Wave Column", group=matrixGroupName)matrixColumn5 = input.bool(true, "Show Money Flow Column", group=matrixGroupName)matrixHeaderColor = input.color(color.black,'Header Cell Color', group=matrixGroupName, inline="matrixHeaderColors")matrixHeaderTextColor = input.color(color.white,'Text Color', group=matrixGroupName, inline="matrixHeaderColors")matrixBullishColor = input.color(color.green,'Bullish Cell Color', group=matrixGroupName, inline="matrixBullishColors")matrixBullishTextColor = input.color(color.white,'Text Color', group=matrixGroupName, inline="matrixBullishColors")matrixBearishColor = input.color(color.red,'Bearish Cell Color', group=matrixGroupName, inline="matrixBearishColors")matrixBearishTextColor = input.color(color.white,'Text Color', group=matrixGroupName, inline="matrixBearishColors")// Dashboard Inputsvar dashboardSettings = "----- Dashboard Settings -----"positionMatrixOnTop = input.bool(true, "Show Matrix History Above Money Flow?", group=dashboardSettings)enableMatrixDashboard1 = input.bool(true, "Enable Matrix History for Timeframe 1", group=dashboardSettings)enableMatrixDashboard2 = input.bool(true, "Enable Matrix History for Timeframe 2", group=dashboardSettings)enableMatrixDashboard3 = input.bool(true, "Enable Matrix History for Timeframe 3", group=dashboardSettings)enableMatrixDashboardLabels = input.bool(true, "Enable Matrix Timeframe Labels", group=dashboardSettings)enableDashboard = input.bool(true, "Enable Money Flow Display", group=dashboardSettings)enableDashboardBuySellSignals = input.bool(false,title='Enable Buy & Sell Signals on Dashboard', group=dashboardSettings)showInsideLines = input.bool(false, "Enable Level Lines", group=dashboardSettings)levelLinesStyle = input.string("Solid", options=["Solid", "Dotted", "Dashed"], title="Level Lines Style", group=dashboardSettings)trendDotsSize = input.int(1, "trendSwitch Dots Size", minval=1, maxval=10, step=1, group=dashboardSettings)crossoverDotsSize = input.int(3, "Signal Dots Size", minval=3, maxval=10, step=1, group=dashboardSettings)mfiBullishColor = input.color(color.lime,'Money Flow Bullish Color', group=dashboardSettings)mfiBearishColor = input.color(color.red,'Money Flow Bearish Color', group=dashboardSettings)// OthersdisableWarning := input.bool(false, title="Disable Heikin Ashi Warning", group="Other Settings")// ----------------------------------------------------------------------------------------------------------------------------------// startTime = timestamp(year, month, dayofmonth, startHour, startMinute)// endTime = timestamp(year, month, dayofmonth, endHour, endMinute)isValidTimeRange = enableTimeFilter ? not na(time(timeframe.period, startEndTime, usersTimezone)) : true// isValidTimeRange = enableTimeFilter ? (time >= startTime and time < endTime) : true// ________ Price & Candle Logic ___________________________var isHAChartType = chart.is_heikinashivar label myLabel = nalabelDisplayed = falsevar const string warningText = "\n⚠️ WARNING!!! ⚠️\n\nYou MUST set the chart candle type\nto Heikin Ashi for the signals to display correctly.\n\nThis message will disappear when you've done so.\n"if not isHAChartType and not disableWarning and not labelDisplayedenableBgColor := falseenableBuySellSignals := falseenableProfitLines := falseenableTrendCandleColoring := falseenableProfitWave := falseensr := false// plotrealsrcClosedots := falsemiddle_price = (high + low) / 2visible_bar_count = bar_index - ta.valuewhen(time == chart.left_visible_bar_time, bar_index, 0)middle_bar_index = bar_index[visible_bar_count / 2]if na(myLabel)myLabel := label.new(x=middle_bar_index, y=middle_price, text=warningText, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_center, color=color.red, textcolor=color.white, size=size.huge, textalign=text.align_center, force_overlay=true)elsemyLabel.set_x(middle_bar_index)myLabel.set_y(middle_price)labelDisplayed := trueelse if isHAChartType or disableWarningmyLabel := nasrcHlc3 = hlc3srcOpen = opensrcHigh = highsrcLow = lowsrcClose = closereal_price = ticker.new(prefix=syminfo.prefix, ticker=syminfo.ticker)real_close = request.security(symbol=real_price, timeframe='', expression=close, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)profitWaveEmaFast = ta.ema(srcClose, 8)profitWaveEmaMedium = ta.ema(srcClose, 13)profitWaveEmaSlow = ta.ema(srcClose, 21)chopSensitivity = 1trueRange = math.max(math.max(high-low, math.abs(high-nz(close[1]))), math.abs(low-nz(close[1])))diPlusCalculation = high-nz(high[1]) > nz(low[1])-low ? math.max(high-nz(high[1]), 0): 0diMinusCalculation = nz(low[1])-low > high-nz(high[1]) ? math.max(nz(low[1])-low, 0): 0smoothedTrueRange = 0.0smoothedTrueRange := nz(smoothedTrueRange[1]) - (nz(smoothedTrueRange[1])/chopSensitivity) + trueRangesmoothedDiPlus = 0.0smoothedDiPlus := nz(smoothedDiPlus[1]) - (nz(smoothedDiPlus[1])/chopSensitivity) + diPlusCalculationsmoothedDiMinus = 0.0smoothedDiMinus := nz(smoothedDiMinus[1]) - (nz(smoothedDiMinus[1])/chopSensitivity) + diMinusCalculationdiPlus = smoothedDiPlus / smoothedTrueRange * 100diMinus = smoothedDiMinus / smoothedTrueRange * 100dx = math.abs(diPlus-diMinus) / (diPlus+diMinus)*100ADX = ta.sma(dx, chopSensitivity)GetTrendDirection(srcHigh, srcLow) =>Up = (srcHigh + srcLow) / 2 - (1.3 * ta.atr(8))Dn = (srcHigh + srcLow) / 2 + (1.3 * ta.atr(8))float trendUp = nafloat trendDown = natrendSwitch = 0trendUp := srcClose[1] > trendUp[1] ? math.max(Up,trendUp[1]) : UptrendDown := srcClose[1] < trendDown[1] ? math.min(Dn,trendDown[1]) : DntrendSwitch := srcClose > trendDown[1] ? 1: srcClose < trendUp[1]? -1: nz(trendSwitch[1],1)trendDirection = trendSwitch == 1 ? trendUp : trendDown[trendDirection, trendUp, trendDown][trendDirection, trendUp, trendDown] = GetTrendDirection(srcHigh, srcLow)bullishTrend = trendDirection == trendUpbearishTrend = trendDirection == trendDownmaFilter = switch maFilterType"EMA" => ta.ema(srcClose, maFilterLength)"SMA" => ta.sma(srcClose, maFilterLength)"VWMA" => ta.vwma(srcClose, maFilterLength)"RMA" => ta.rma(srcClose, maFilterLength)"Hull" => ta.wma(2*ta.wma(srcClose, maFilterLength/2)-ta.wma(srcClose, maFilterLength), math.floor(math.sqrt(maFilterLength)))=> naplot(enableMaFilter ? maFilter : na, force_overlay=true, title = "Filter MA", color=maFilterColor, linewidth=2)// ________ Background Trend Logic ___________________________backgroundTrendColor = color.whiteif (trendDirection == trendUp)backgroundTrendColor := bgTrendBullishColelse if (trendDirection == trendDown)backgroundTrendColor := bgTrendBearishColelsebackgroundTrendColor := backgroundTrendColor[1]bgcolor(enableBgColor ? backgroundTrendColor : na, force_overlay = true)// Base Candle coloringcandleColor = color.graycandleColor := if (srcClose > srcOpen)bullishCandleColorelse if (srcClose < srcOpen)bearishCandleColorelsecandleColor[1]if (enableTrendCandleColoring and candleColoringType == "Trend")candleColor := if (backgroundTrendColor == bgTrendBullishCol)bullishCandleColorelse if (backgroundTrendColor == bgTrendBearishCol)bearishCandleColorelsecandleColor[1]else if (enableTrendCandleColoring and candleColoringType == "Profit Wave")candleColor := if (real_close > profitWaveEmaSlow)bullishCandleColorelse if (real_close < profitWaveEmaSlow)bearishCandleColorelsecandleColor[1]plotcandle(srcOpen, srcHigh, srcLow, srcClose, "SMM Candles", color=candleColor, wickcolor=candleColor, bordercolor=candleColor, force_overlay=true)// ________ Signals Logic ___________________________var bool buySignal = falsevar bool sellSignal = falsebuySignal := trendDirection == trendUpsellSignal := trendDirection == trendDownmfl = ta.mfi(srcHlc3, 10)enum Modebuy = "Buy Mode"sell = "Sell Mode"none = "none"var Mode currentMode = Mode.noneif (backgroundTrendColor != backgroundTrendColor[1])currentMode := Mode.nonestrongBullishCandle = srcClose > srcOpen and math.floor(srcOpen) == math.floor(srcLow) and real_close > profitWaveEmaFast and real_close > profitWaveEmaSlowstrongBearishCandle = srcClose < srcOpen and math.floor(srcOpen) == math.floor(srcHigh) and real_close < profitWaveEmaFast and real_close < profitWaveEmaSlowrealClosePriceText = enableBuySellPrice ? "\n$" + str.tostring(real_close, format.mintick) : ""bool canBuy = truebool canSell = trueif (enableChopFilter)canBuy := math.floor(diPlus) > math.floor(diMinus) and math.floor(diPlus) >= 45canSell := math.floor(diMinus) > math.floor(diPlus) and math.floor(diMinus) >= 45elsecanBuy := truecanSell := truevar int currentSignalBarIndex = na// Bullish signalsmaFilterBuy = enableMaFilter ? srcClose > maFilter and real_close > maFilter : truemfiBuy = enableChopFilter ? mfl > 52 : truebuy_con = buySignal and backgroundTrendColor == bgTrendBullishCol and strongBullishCandle and currentMode != Mode.buy and mfiBuy and canBuyif (buy_con and enableBuySellSignals)currentMode := Mode.buyif isValidTimeRange and maFilterBuylabel.new(bar_index, low, style=label.style_label_up, color=buySignalColor, size=size.normal, yloc=yloc.belowbar, text="Buy"+realClosePriceText, textcolor=color.white, force_overlay=true)currentSignalBarIndex := bar_index// Bearish signalsmaFilterSell = enableMaFilter ? srcClose < maFilter and real_close < maFilter : truemfiSell = enableChopFilter ? mfl < 52 : truesell_con = sellSignal and backgroundTrendColor == bgTrendBearishCol and strongBearishCandle and currentMode != Mode.sell and mfiSell and canSellif (sell_con and enableBuySellSignals)currentMode := Mode.sellif isValidTimeRange and maFilterSelllabel.new(bar_index, high, style=label.style_label_down, color=sellSignalColor, size=size.normal, yloc=yloc.abovebar, text="Sell"+realClosePriceText, textcolor=color.white, force_overlay=true)currentSignalBarIndex := bar_index// Profit Target linesvar line[] targetLines = array.new_line(0)var label[] targetLabels = array.new_label(0)var float targetPrice = naif (((buy_con and maFilterBuy) or (sell_con and maFilterSell)) and enableBuySellSignals and enableProfitLines and isValidTimeRange)if array.size(targetLines) >= profitTargetMaxLinesoldestLine = array.get(targetLines, 0)oldestLabel = array.get(targetLabels, 0)line.delete(oldestLine)label.delete(oldestLabel)array.remove(targetLines, 0)array.remove(targetLabels, 0)targetPrice := buy_con ? real_close + (profitTarget * syminfo.mintick) : sell_con ? real_close - (profitTarget * syminfo.mintick) : nanewLine = line.new(bar_index-7, targetPrice, bar_index + 5, targetPrice, color=profitTargetColor, width=2, force_overlay=true)array.push(targetLines, newLine)newLabel = label.new(bar_index-3, targetPrice, text="$"+str.tostring(targetPrice, format.mintick), style=label.style_none, textcolor=profitTargetColor, force_overlay=true)array.push(targetLabels, newLabel)// Reset for more signals within continuous trendif (currentMode == Mode.buy and real_close < profitWaveEmaSlow and srcClose < profitWaveEmaSlow)currentMode := Mode.nonecurrentSignalBarIndex := naif (currentMode == Mode.sell and real_close > profitWaveEmaSlow and srcClose > profitWaveEmaSlow)currentMode := Mode.nonecurrentSignalBarIndex := naprofitTargetCondition = if not na(currentSignalBarIndex) and bar_index > currentSignalBarIndexcurrentMode == Mode.buy ? srcHigh >= targetPrice : currentMode == Mode.sell ? srcLow <= targetPrice : na// Signal Alertsalertcondition(condition=buy_con and maFilterBuy and isValidTimeRange,title='Buy alert', message='Buy')alertcondition(condition=sell_con and maFilterSell and isValidTimeRange,title='Sell alert', message='Sell')alertcondition(condition=enableBuySellSignals and enableProfitLines ? profitTargetCondition : na, title="Profit Target", message="Profit Target Hit!")if profitTargetConditiontargetPrice := nacurrentSignalBarIndex := na// ________ Profit Wave Logic ___________________________pwPlot1 = plot(enableProfitWave ? profitWaveEmaFast : na, title="Profit Wave Line 1", color=color.new(color.white, 100), linewidth=1, force_overlay = true)pwPlot2 = plot(enableProfitWave ? profitWaveEmaMedium : na, title="Profit Wave Line 2", color=color.new(color.white, 100), linewidth=1, force_overlay = true)pwPlot3 = plot(enableProfitWave ? profitWaveEmaSlow : na, title="Profit Wave Line 3", color=color.new(color.white, 100), linewidth=1, force_overlay = true)pwUpperBullishColor = real_close > profitWaveEmaSlow ? profitWaveUpperBullishColor : color.new(color.lime, 100)pwLowerBullishColor = real_close > profitWaveEmaSlow ? profitWaveLowerBullishColor : color.new(color.green, 100)fill(pwPlot1, pwPlot2, pwUpperBullishColor)fill(pwPlot2, pwPlot3, pwLowerBullishColor)pwUpperBearishColor = real_close < profitWaveEmaSlow ? profitWaveUpperBearishColor : color.new(#ff0000, 100)pwLowerBearishColor = real_close < profitWaveEmaSlow ? profitWaveLowerBearishColor : color.new(#8c0000, 100)fill(pwPlot1, pwPlot2, pwUpperBearishColor)fill(pwPlot2, pwPlot3, pwLowerBearishColor)// ________ Support / Resistance Logic ___________________________srLineStyle = switch srStyle"Solid" => line.style_solid"Dotted" => line.style_dotted"Dashed" => line.style_dashed// Identify pivot highs and pivot lowspivotHigh = ta.pivothigh(srcHigh, pivotchopSensitivity, pivotchopSensitivity)pivotLow = ta.pivotlow(srcLow, pivotchopSensitivity, pivotchopSensitivity)// Initialize arrays to store the linesvar line[] resistanceLines = array.new_line(0)var line[] supportLines = array.new_line(0)var int[] resistanceTouchBars = array.new_int(0)var int[] supportTouchBars = array.new_int(0)lookbackchopSensitivity = 500// Function to manage line limits (removing the oldest line if limit is exceeded)f_manage_line_limit(array<line> linesArray, array<int> touchBarsArray) =>if array.size(linesArray) > maxSrLines// Delete the first (oldest) lineline.delete(array.shift(linesArray))// Remove the first touch bar valuearray.shift(touchBarsArray)// Draw new resistance line if a new pivot high is detectedif (ensr and not na(pivotHigh) and bar_index[pivotchopSensitivity] >= bar_index - lookbackchopSensitivity)pivotHighPrice = srcHigh[pivotchopSensitivity]pivotHighBar = bar_index[pivotchopSensitivity]resistanceLine = line.new(pivotHighBar, pivotHighPrice, bar_index + 1, pivotHighPrice, style=srLineStyle, width=srLineWidth, color=resistanceColor, extend=extend.right, force_overlay=true)array.push(resistanceLines, resistanceLine)array.push(resistanceTouchBars, na) // No touch yetf_manage_line_limit(resistanceLines, resistanceTouchBars) // Manage the line limit// Draw new support line if a new pivot low is detectedif (ensr and not na(pivotLow) and bar_index[pivotchopSensitivity] >= bar_index - lookbackchopSensitivity)pivotLowPrice = srcLow[pivotchopSensitivity]pivotLowBar = bar_index[pivotchopSensitivity]supportLine = line.new(pivotLowBar, pivotLowPrice, bar_index + 1, pivotLowPrice, style=srLineStyle, width=srLineWidth, color=supportColor, extend=extend.right, force_overlay=true)array.push(supportLines, supportLine)array.push(supportTouchBars, na) // No touch yetf_manage_line_limit(supportLines, supportTouchBars) // Manage the line limit// Loop through the resistance lines and stop their extension if the price touches themif array.size(resistanceLines) > 0resLineStop = extendLinesType == 'Close' ? srcClose : srcHighfor i = 0 to array.size(resistanceLines) - 1line currentResistanceLine = array.get(resistanceLines, i)resistancePrice = line.get_y1(currentResistanceLine)touchBar = array.get(resistanceTouchBars, i)// Update the line to the current candle unless already touchedif na(touchBar)line.set_x2(currentResistanceLine, bar_index)line.set_extend(currentResistanceLine, extend.none)// Check if the price touches the resistance and we haven't already stopped the lineif na(touchBar) and resLineStop >= resistancePriceline.set_x2(currentResistanceLine, bar_index)line.set_extend(currentResistanceLine, extend.none)array.set(resistanceTouchBars, i, bar_index) // Store the bar where the price touched// Loop through the support lines and stop their extension if the price touches themif array.size(supportLines) > 0supLineStop = extendLinesType == 'Close' ? srcClose : srcLowfor i = 0 to array.size(supportLines) - 1line currentSupportLine = array.get(supportLines, i)supportPrice = line.get_y1(currentSupportLine)touchBar = array.get(supportTouchBars, i)// Update the line to the current candle unless already touchedif na(touchBar)line.set_x2(currentSupportLine, bar_index)line.set_extend(currentSupportLine, extend.none)// Check if the price touches the support and we haven't already stopped the lineif na(touchBar) and supLineStop <= supportPriceline.set_x2(currentSupportLine, bar_index)line.set_extend(currentSupportLine, extend.none)array.set(supportTouchBars, i, bar_index) // Store the bar where the price touched// ________ Real Price Logic ___________________________Original open source code from Real Price + Dots by PHVNTOM_TRADERshowrealpricemicrodotsauto = (plotrealsrcClosedots and size=="Auto" ? display.all : display.none)showrealpricemicrodotssmall = (plotrealsrcClosedots and size=="Small" ? display.all : display.none)showrealpricedotslarge = (plotrealsrcClosedots and size=="Large" ? display.all : display.none)_width = switch realpricewidth"Thin" => 1"Thick" => 2// Real Price Lineif(showrealprice and (realpricestyle == "Solid"))real_price_line = line.new(bar_index[1], real_close, bar_index, real_close, xloc.bar_index, (extendLine ? extend.both : extend.right), showrealpricelinecolor, line.style_solid, _width, force_overlay = true)line.delete(real_price_line[1])if(showrealprice and (realpricestyle == "Dotted"))real_price_line = line.new(bar_index[1], real_close, bar_index, real_close, xloc.bar_index, (extendLine ? extend.both : extend.right), showrealpricelinecolor, line.style_dotted, _width, force_overlay = true)line.delete(real_price_line[1])if(showrealprice and (realpricestyle == "Dashed"))real_price_line = line.new(bar_index[1], real_close, bar_index, real_close, xloc.bar_index, (extendLine ? extend.both : extend.right), showrealpricelinecolor, line.style_dashed, _width, force_overlay = true)line.delete(real_price_line[1])// Real Price srcClose Dotsplotchar(series=real_close, title="Real Close dots", location=location.absolute, color=realsrcClosecolour, editable=false, char="•", size=size.auto, display=showrealpricemicrodotsauto, force_overlay = true)plotchar(series=real_close, title="Real Close dots", location=location.absolute, color=realsrcClosecolour, editable=false, char="•", size=size.tiny, display=showrealpricemicrodotssmall, force_overlay = true)plotshape(series=real_close, title="Real Close dots", location=location.absolute, color=realsrcClosecolour, editable=false, style=shape.circle, size=size.auto, display=showrealpricedotslarge, force_overlay = true)// ________ Dashboard Oscillator Logic ___________________________hlineStyle = switch levelLinesStyle"Dotted" => hline.style_dotted"Dashed" => hline.style_dashed=> hline.style_solidtop_1 = hline(enableDashboard ? 100 : na,color=color.new(#ff1b1b,50),linestyle=hline.style_solid)top_2 = hline(enableDashboard ? 90 : na,color=color.new(#ff2626,50),linestyle=hline.style_solid)top_3 = hline(enableDashboard ? 80 : na,color=color.new(#ff3f3f,50),linestyle=hline.style_solid)top_4 = hline(showInsideLines and enableDashboard ? 70 : na,color=color.new(#ff5050,50),linestyle=hlineStyle)top_5 = hline(showInsideLines and enableDashboard ? 60 : na,color=color.new(#ff6464,50),linestyle=hlineStyle)top_6 = hline(showInsideLines and enableDashboard ? 50 : na,color=color.new(#ff6464,100),linestyle=hlineStyle)bottom_1 = hline(enableDashboard ? 0 : na,color=color.new(#047200,50),linestyle=hline.style_solid)bottom_2 = hline(enableDashboard ? 10 : na,color=color.new(#047e00,50),linestyle=hline.style_solid)bottom_3 = hline(enableDashboard ? 20 : na,color=color.new(#048900,50),linestyle=hline.style_solid)bottom_4 = hline(showInsideLines and enableDashboard ? 30 : na,color=color.new(#059f00,50),linestyle=hlineStyle)bottom_5 = hline(showInsideLines and enableDashboard ? 40 : na,color=color.new(#06b200,50),linestyle=hlineStyle)bottom_6 = hline(showInsideLines and enableDashboard ? 50 : na,color=color.new(#06b200,100),linestyle=hlineStyle)fill(top_1, top_2, color=color.new(#ff1b1b,20), title="Overbought Extreme Background")fill(top_2, top_3, color=color.new(#ff2626,40), title="Overbought Start Background")fill(bottom_1, bottom_2, color=color.new(#047200,10), title="Oversold Start Background")fill(bottom_3, bottom_2, color=color.new(#047e00,40), title="Oversold Extreme Background")dotsColor = bullishTrend ? #66ff00 : #ff0000plot(enableDashboard ? 50 : na,color=dotsColor,style= plot.style_circles, title="Dashboard Center Line trendSwitch Dots", linewidth=trendDotsSize)plotDashboardBuy = buy_con and enableDashboardBuySellSignals and isValidTimeRange and maFilterBuyplotDashboardSell = sell_con and enableDashboardBuySellSignals and isValidTimeRange and maFilterSellplotshape(plotDashboardBuy and enableDashboard ? 10 : na,title='Dashboard Buy Signal',style=shape.labelup,location=location.absolute,text='Buy',textcolor=color.white,color=buySignalColor)plotshape(plotDashboardSell and enableDashboard ? 90 : na,title='Dashboard Sell Signal',style=shape.labeldown,location=location.absolute,text='Sell',textcolor=color.white,color=sellSignalColor)mfiTrendColor = if (mfl > 50)mfiBullishColorelse if (mfl < 50)mfiBearishColorelsecolor.whiteplot(enableDashboard ? mfl : na, "Dashboard Money Flow Line", color=mfiTrendColor, style=plot.style_stepline)plot(plotDashboardBuy and enableDashboard ? 50 : na, color=#66ff00, style=plot.style_circles,linewidth=crossoverDotsSize,title='Dashboard Crossover Up Dots')plot(plotDashboardSell and enableDashboard ? 50 : na, color=#ff0000, style=plot.style_circles,linewidth=crossoverDotsSize,title='Dashboard Crossover Down Dots')// ________ Matrix Data Table Logic ___________________________getMatrixRealClose(ticker, timeframe) =>request.security(ticker, timeframe, close, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)getMatrixTrendData(timeframe) =>[mTrendDirection, mTrendUp, mTrendDown] = request.security(syminfo.tickerid, timeframe, GetTrendDirection(srcHigh, srcLow))mBackgroundTrendColor = color.graymTrendTextColor = color.whitemTrendStatus = ""if (mTrendDirection == mTrendUp)mBackgroundTrendColor := matrixBullishColormTrendTextColor := matrixBullishTextColormTrendStatus := "Bullish"else if (mTrendDirection == mTrendDown)mBackgroundTrendColor := matrixBearishColormTrendTextColor := matrixBearishTextColormTrendStatus := "Bearish"elsemBackgroundTrendColor := mBackgroundTrendColor[1]mTrendTextColor := mTrendTextColor[1]mTrendStatus := mTrendStatus[1][mTrendStatus, mBackgroundTrendColor, mTrendTextColor]getMatrixProfitWaveData(timeframe, realClose) =>mProfitWaveEmaSlow = request.security(syminfo.tickerid, timeframe, ta.ema(srcClose, 21))mProfitWaveColor = color.graymProfitWaveTextColor = color.whitemProfitWaveStatus = ""if realClose > mProfitWaveEmaSlowmProfitWaveColor := color.new(matrixBullishColor,0)mProfitWaveTextColor := matrixBullishTextColormProfitWaveStatus := "Bullish"else if realClose < mProfitWaveEmaSlowmProfitWaveColor := color.new(matrixBearishColor,0)mProfitWaveTextColor := matrixBearishTextColormProfitWaveStatus := "Bearish"elsemProfitWaveColor := mProfitWaveColor[1]mProfitWaveTextColor := mProfitWaveTextColor[1]mProfitWaveStatus := mProfitWaveStatus[1][mProfitWaveStatus, mProfitWaveColor, mProfitWaveTextColor]getMatrixCandleData(timeframe, trendStatus, profitWaveStatus) =>[mOpen, mClose] = request.security(syminfo.tickerid, timeframe, [srcOpen, srcClose])mCandleColor = color.graymCandleStatus = ""if (mClose > mOpen)mCandleColor := matrixBullishColormCandleStatus := "↑"else if (mClose < mOpen)mCandleColor := matrixBearishColormCandleStatus := "↓"elsemCandleColor := mCandleColor[1]mCandleStatus := mCandleStatus[1]if (enableTrendCandleColoring and candleColoringType == "Trend")if (trendStatus == "Bullish")mCandleColor := matrixBullishColormCandleStatus := "↑"else if (trendStatus == "Bearish")mCandleColor := matrixBearishColormCandleStatus := "↓"elsemCandleColor := mCandleColor[1]mCandleStatus := mCandleStatus[1]else if (enableTrendCandleColoring and candleColoringType == "Profit Wave")if (profitWaveStatus == "Bullish")mCandleColor := matrixBullishColormCandleStatus := "↑"else if (profitWaveStatus == "Bearish")mCandleColor := matrixBearishColormCandleStatus := "↓"elsemCandleColor := mCandleColor[1]mCandleStatus := mCandleStatus[1][mCandleStatus, mCandleColor]getMatrixMfiData(timeframe) =>mMfi = request.security(syminfo.tickerid, timeframe, ta.mfi(srcHlc3, 10))mMfiColor = color.graymMfiTextColor = color.whitemMfiStatus = ""if (mMfi > 50)mMfiColor := matrixBullishColormMfiTextColor := matrixBullishTextColormMfiStatus := "Bullish"else if (mMfi < 50)mMfiColor := matrixBearishColormMfiTextColor := matrixBearishTextColormMfiStatus := "Bearish"elsemMfiColor := mMfiColor[1]mMfiTextColor := mMfiTextColor[1]mMfiStatus := mMfiStatus[1][str.tostring(mMfi, "#"), mMfiColor, mMfiTextColor]getMatrixAtr(timeframe) =>atrValue = request.security(syminfo.tickerid, timeframe, ta.atr(matrixAtrLength))str.tostring(atrValue, "#.#")getMatrixHeaderCol(col) =>matrixStyle == "Vertical" ? 0 : colgetMatrixHeaderRow(row) =>matrixStyle == "Vertical" ? row : 0getMatrixTfCol(col) =>matrixStyle == "Vertical" ? col : 0getMatrixTfRow(tf, row) =>matrixStyle == "Vertical" ? row : tfgetMatrixDataCol(tf, col) =>matrixStyle == "Vertical" ? tf : colgetMatrixDataRow(tf, row) =>matrixStyle == "Vertical" ? row : tfm1RealClose = getMatrixRealClose(real_price, matrixTF1)[m1TrendStatus, m1BackgroundTrendColor, m1TrendTextColor] = getMatrixTrendData(matrixTF1)[m1ProfitWaveStatus, m1ProfitWaveColor, m1ProfitWaveTextColor] = getMatrixProfitWaveData(matrixTF1, m1RealClose)[m1MfiStatus, m1MfiColor, m1MfiTextColor] = getMatrixMfiData(matrixTF1)m2RealClose = getMatrixRealClose(real_price, matrixTF2)[m2TrendStatus, m2BackgroundTrendColor, m2TrendTextColor] = getMatrixTrendData(matrixTF2)[m2ProfitWaveStatus, m2ProfitWaveColor, m2ProfitWaveTextColor] = getMatrixProfitWaveData(matrixTF2, m2RealClose)[m2MfiStatus, m2MfiColor, m2MfiTextColor] = getMatrixMfiData(matrixTF2)m3RealClose = getMatrixRealClose(real_price, matrixTF3)[m3TrendStatus, m3BackgroundTrendColor, m3TrendTextColor] = getMatrixTrendData(matrixTF3)[m3ProfitWaveStatus, m3ProfitWaveColor, m3ProfitWaveTextColor] = getMatrixProfitWaveData(matrixTF3, m3RealClose)[m3MfiStatus, m3MfiColor, m3MfiTextColor] = getMatrixMfiData(matrixTF3)if enableMatrixTF1 or enableMatrixTF2 or enableMatrixTF3tablePosition = switch matrixPosition"Top Left" => position.top_left"Top Center" => position.top_center"Top Right" => position.top_right"Bottom Left" => position.bottom_left"Bottom Center" => position.bottom_center=> position.bottom_rightvar columns = 6var rows = 4if matrixStyle == "Vertical"columns := 4rows := 6var table matrixDataTable = table.new(position=tablePosition, columns=columns, rows=rows, frame_color=color.gray, frame_width=1, border_width=1, bgcolor=color.new(color.gray, 0), force_overlay=true)table.cell(matrixDataTable, 0, 0, text="TimeFrame", text_color=matrixHeaderTextColor, bgcolor=matrixHeaderColor)if matrixColumn1atrText = "ATR(" + str.tostring(matrixAtrLength) + ")"table.cell(matrixDataTable, getMatrixHeaderCol(1), getMatrixHeaderRow(1), text=atrText, text_color=matrixHeaderTextColor, bgcolor=matrixHeaderColor)if matrixColumn2table.cell(matrixDataTable, getMatrixHeaderCol(2), getMatrixHeaderRow(2), text="Candle", text_color=matrixHeaderTextColor, bgcolor=matrixHeaderColor)if matrixColumn3table.cell(matrixDataTable, getMatrixHeaderCol(3), getMatrixHeaderRow(3), text="Background", text_color=matrixHeaderTextColor, bgcolor=matrixHeaderColor)if matrixColumn4table.cell(matrixDataTable, getMatrixHeaderCol(4), getMatrixHeaderRow(4), text="Profit Wave", text_color=matrixHeaderTextColor, bgcolor=matrixHeaderColor)if matrixColumn5table.cell(matrixDataTable, getMatrixHeaderCol(5), getMatrixHeaderRow(5), text="Money Flow", text_color=matrixHeaderTextColor, bgcolor=matrixHeaderColor)if enableMatrixTF1m1Atr = getMatrixAtr(matrixTF1)[m1CandleStatus, m1CandleColor] = getMatrixCandleData(matrixTF1, m1TrendStatus, m1ProfitWaveStatus)table.cell(matrixDataTable, getMatrixTfCol(1), getMatrixTfRow(1, 0), text=matrixTF1, text_color=matrixTimeframeTextColor, bgcolor=matrixTimeframeColor)if matrixColumn1table.cell(matrixDataTable, getMatrixDataCol(1,1), getMatrixDataRow(1,1), text=m1Atr, text_color=matrixAtrTextColor, bgcolor=matrixAtrColor)if matrixColumn2table.cell(matrixDataTable, getMatrixDataCol(1,2), getMatrixDataRow(1,2), text=m1CandleStatus, text_color=color.white, bgcolor=m1CandleColor)if matrixColumn3table.cell(matrixDataTable, getMatrixDataCol(1,3), getMatrixDataRow(1,3), text=m1TrendStatus, text_color=m1TrendTextColor, bgcolor=color.new(m1BackgroundTrendColor,0))if matrixColumn4table.cell(matrixDataTable, getMatrixDataCol(1,4), getMatrixDataRow(1,4), text=m1ProfitWaveStatus, text_color=m1ProfitWaveTextColor, bgcolor=m1ProfitWaveColor)if matrixColumn5table.cell(matrixDataTable, getMatrixDataCol(1,5), getMatrixDataRow(1,5), text=m1MfiStatus, text_color=m1MfiTextColor, bgcolor=m1MfiColor)if enableMatrixTF2m2Atr = getMatrixAtr(matrixTF2)[m2CandleStatus, m2CandleColor] = getMatrixCandleData(matrixTF2, m2TrendStatus, m2ProfitWaveStatus)table.cell(matrixDataTable, getMatrixTfCol(2), getMatrixTfRow(2, 0), text=matrixTF2, text_color=matrixTimeframeTextColor, bgcolor=matrixTimeframeColor)if matrixColumn1table.cell(matrixDataTable, getMatrixDataCol(2,1), getMatrixDataRow(2,1), text=m2Atr, text_color=matrixAtrTextColor, bgcolor=matrixAtrColor)if matrixColumn2table.cell(matrixDataTable, getMatrixDataCol(2,2), getMatrixDataRow(2,2), text=m2CandleStatus, text_color=color.white, bgcolor=m2CandleColor)if matrixColumn3table.cell(matrixDataTable, getMatrixDataCol(2,3), getMatrixDataRow(2,3), text=m2TrendStatus, text_color=m2TrendTextColor, bgcolor=color.new(m2BackgroundTrendColor,0))if matrixColumn4table.cell(matrixDataTable, getMatrixDataCol(2,4), getMatrixDataRow(2,4), text=m2ProfitWaveStatus, text_color=m2ProfitWaveTextColor, bgcolor=m2ProfitWaveColor)if matrixColumn5table.cell(matrixDataTable, getMatrixDataCol(2,5), getMatrixDataRow(2,5), text=m2MfiStatus, text_color=m2MfiTextColor, bgcolor=m2MfiColor)if enableMatrixTF3m3Atr = getMatrixAtr(matrixTF3)[m3CandleStatus, m3CandleColor] = getMatrixCandleData(matrixTF3, m3TrendStatus, m3ProfitWaveStatus)table.cell(matrixDataTable, getMatrixTfCol(3), getMatrixTfRow(3, 0), text=matrixTF3, text_color=matrixTimeframeTextColor, bgcolor=matrixTimeframeColor)if matrixColumn1table.cell(matrixDataTable, getMatrixDataCol(3,1), getMatrixDataRow(3,1), text=m3Atr, text_color=matrixAtrTextColor, bgcolor=matrixAtrColor)if matrixColumn2table.cell(matrixDataTable, getMatrixDataCol(3,2), getMatrixDataRow(3,2), text=m3CandleStatus, text_color=color.white, bgcolor=m3CandleColor)if matrixColumn3table.cell(matrixDataTable, getMatrixDataCol(3,3), getMatrixDataRow(3,3), text=m3TrendStatus, text_color=m3TrendTextColor, bgcolor=color.new(m3BackgroundTrendColor,0))if matrixColumn4table.cell(matrixDataTable, getMatrixDataCol(3,4), getMatrixDataRow(3,4), text=m3ProfitWaveStatus, text_color=m3ProfitWaveTextColor, bgcolor=m3ProfitWaveColor)if matrixColumn5table.cell(matrixDataTable, getMatrixDataCol(3,5), getMatrixDataRow(3,5), text=m3MfiStatus, text_color=m3MfiTextColor, bgcolor=m3MfiColor)lw_plots = 4plotStyle = plot.style_steplinevar int md1Trend = enableMatrixDashboard1 ? -10 : 0var int md1Profit = enableMatrixDashboard1 ? -15 : 0var int md1Mfi = enableMatrixDashboard1 ? -20 : 0var int md2Trend = enableMatrixDashboard2 ? md1Mfi - 10 : md1Trendvar int md2Profit = enableMatrixDashboard2 ? md2Trend - 5 : md1Profitvar int md2Mfi = enableMatrixDashboard2 ? md2Profit - 5 : md1Mfivar int md3Trend = enableMatrixDashboard3 ? md2Mfi - 10 : 0var int md3Profit = enableMatrixDashboard3 ? md3Trend - 5 : 0var int md3Mfi = enableMatrixDashboard3 ? md3Profit - 5 : 0if positionMatrixOnTopmd1Trend := enableMatrixDashboard1 ? md1Profit + 5 : 100md1Profit := enableMatrixDashboard1 ? md1Mfi + 5 : 100md1Mfi := enableMatrixDashboard1 ? md2Trend + 10 : 100md2Trend := enableMatrixDashboard2 ? md2Profit + 5 : md3Trendmd2Profit := enableMatrixDashboard2 ? md2Mfi + 5 : md3Profitmd2Mfi := enableMatrixDashboard2 ? md3Trend + 10 : md3Mfimd3Trend := enableMatrixDashboard3 ? 120 : 100md3Profit := enableMatrixDashboard3 ? 115 : 100md3Mfi := enableMatrixDashboard3 ? 110 : 100var label md1TrendLabel = navar label md1ProfitLabel = navar label md1MfiLabel = navar label md2TrendLabel = navar label md2ProfitLabel = navar label md2MfiLabel = navar label md3TrendLabel = navar label md3ProfitLabel = navar label md3MfiLabel = naif barstate.islast and enableMatrixDashboardLabelsif enableMatrixDashboard1 and na(md1TrendLabel)md1TrendLabel := label.new(x=bar_index[0], y=md1Trend, text="Background - "+matrixTF1, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)md1ProfitLabel := label.new(x=bar_index[0], y=md1Profit, text="Profit Wave - "+matrixTF1, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)md1MfiLabel := label.new(x=bar_index[0], y=md1Mfi, text="Money Flow - "+matrixTF1, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)else if enableMatrixDashboard1label.set_x(md1TrendLabel, bar_index[0])label.set_x(md1ProfitLabel, bar_index[0])label.set_x(md1MfiLabel, bar_index[0])if enableMatrixDashboard2 and na(md2TrendLabel)md2TrendLabel := label.new(x=bar_index[0], y=md2Trend, text="Background - "+matrixTF2, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)md2ProfitLabel := label.new(x=bar_index[0], y=md2Profit, text="Profit Wave - "+matrixTF2, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)md2MfiLabel := label.new(x=bar_index[0], y=md2Mfi, text="Money Flow - "+matrixTF2, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)else if enableMatrixDashboard2label.set_x(md2TrendLabel, bar_index[0])label.set_x(md2ProfitLabel, bar_index[0])label.set_x(md2MfiLabel, bar_index[0])if enableMatrixDashboard3 and na(md3TrendLabel)md3TrendLabel := label.new(x=bar_index[0], y=md3Trend, text="Background - "+matrixTF3, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)md3ProfitLabel := label.new(x=bar_index[0], y=md3Profit, text="Profit Wave - "+matrixTF3, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)md3MfiLabel := label.new(x=bar_index[0], y=md3Mfi, text="Money Flow - "+matrixTF3, style=label.style_label_left, textcolor=color.white, color=color.new(color.white, 100), size=size.tiny)else if enableMatrixDashboard3label.set_x(md3TrendLabel, bar_index[0])label.set_x(md3ProfitLabel, bar_index[0])label.set_x(md3MfiLabel, bar_index[0])elselabel.delete(md1TrendLabel)md1TrendLabel := nalabel.delete(md1ProfitLabel)md1ProfitLabel := nalabel.delete(md1MfiLabel)md1MfiLabel := nalabel.delete(md2TrendLabel)md2TrendLabel := nalabel.delete(md2ProfitLabel)md2ProfitLabel := nalabel.delete(md2MfiLabel)md2MfiLabel := nalabel.delete(md3TrendLabel)md3TrendLabel := nalabel.delete(md3ProfitLabel)md3ProfitLabel := nalabel.delete(md3MfiLabel)md3MfiLabel := naplot(series=enableMatrixDashboard1 ? md1Trend : na, title="Trend", color=m1BackgroundTrendColor, linewidth=lw_plots, style=plotStyle, editable=false)plot(series=enableMatrixDashboard1 ? md1Profit : na, title="Profit Wave", color=m1ProfitWaveColor, linewidth=lw_plots, style=plotStyle, editable=false)plot(series=enableMatrixDashboard1 ? md1Mfi : na, title="MFI", color=m1MfiColor, linewidth=lw_plots, style=plotStyle, editable=false)plot(series=enableMatrixDashboard2 ? md2Trend : na, title="Trend 2", color=m2BackgroundTrendColor, linewidth=lw_plots, style=plotStyle, editable=false)plot(series=enableMatrixDashboard2 ? md2Profit : na, title="Profit Wave 2", color=m2ProfitWaveColor, linewidth=lw_plots, style=plotStyle, editable=false)plot(series=enableMatrixDashboard2 ? md2Mfi : na, title="MFI 2", color=m2MfiColor, linewidth=lw_plots, style=plotStyle, editable=false)plot(series=enableMatrixDashboard3 ? md3Trend : na, title="Trend 3", color=m3BackgroundTrendColor, linewidth=lw_plots, style=plotStyle, editable=false)plot(series=enableMatrixDashboard3 ? md3Profit : na, title="Profit Wave 3", color=m3ProfitWaveColor, linewidth=lw_plots, style=plotStyle, editable=false)plot(series=enableMatrixDashboard3 ? md3Mfi : na, title="MFI 3", color=m3MfiColor, linewidth=lw_plots, style=plotStyle, editable=false)07/29/2025 at 4:27 PM #249202Here you have:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585//---------------------------------------------//// PRC_MARKET STRUCTURE//version = 0//29.07.25//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//---------------------------------------------//// ----- Configuración de Señales -----enableBuySellSignals = 1 // 1=SI, 0=NO// Colores de Señales (RGB)buySignalColorR = 76buySignalColorG = 175buySignalColorB = 80sellSignalColorR = 178sellSignalColorG = 40sellSignalColorB = 51// Filtros de SeñaleschopSensitivity = 1enableChopFilter = 1 // 1=SI, 0=NO - Filtro de Mercado Lateral (Chop Filter)enableMaFilter = 1 // 1=SI, 0=NO - Filtro de Media MóvilmaFilterType = 1 // Tipo de MA: 1=EMA, 2=SMA, 3=VWMA, 4=RMA, 5=HullmaFilterLength = 200 // Periodo del Filtro de MA// Color del Filtro de MA (RGB)maFilterColorR = 120maFilterColorG = 120maFilterColorB = 255// Filtro de TiempoenableTimeFilter = 0 // 1=SI, 0=NO - Filtro de TiempostartTime = 093000 // Hora de inicio en formato HHMMSSendTime = 180000 // Hora de finalización en formato HHMMSS// ----- Configuración de Objetivos de Beneficio -----enableProfitLines = 1 // 1=SI, 0=NO - Líneas de Objetivo de BeneficioprofitTarget = 20 // Objetivo de beneficio en Ticks/Pips/CéntimosprofitTargetMaxLines = 10 // Máximo de líneas de objetivo a mostrarprofitTargetColorR = 120 // Color Líneas de Objetivo (RGB)profitTargetColorG = 180profitTargetColorB = 255enableProfitWave = 1 // 1=SI, 0=NO - Onda de Beneficio (Profit Wave)// Colores Onda de Beneficio Alcista (RGB, Alpha)profitWaveUpperBullishColorR = 0profitWaveUpperBullishColorG = 255profitWaveUpperBullishColorB = 132profitWaveUpperBullishColorA = 127 // Transparencia (0-255)profitWaveLowerBullishColorR = 0profitWaveLowerBullishColorG = 128profitWaveLowerBullishColorB = 0profitWaveLowerBullishColorA = 127// Colores Onda de Beneficio Bajista (RGB, Alpha)profitWaveLowerBearishColorR = 140profitWaveLowerBearishColorG = 0profitWaveLowerBearishColorB = 0profitWaveLowerBearishColorA = 127profitWaveUpperBearishColorR = 255profitWaveUpperBearishColorG = 0profitWaveUpperBearishColorB = 0profitWaveUpperBearishColorA = 127// ----- Configuración de Tendencia de Fondo -----enableBgColor = 1 // 1=SI, 0=NO - Color de Fondo de Tendencia// Colores de Fondo (RGB, Alpha)bgTrendBullishColR = 102bgTrendBullishColG = 255bgTrendBullishColB = 0bgTrendBullishColA = 76 // Transparencia ajustada de 70 a 76/255bgTrendBearishColR = 255bgTrendBearishColG = 0bgTrendBearishColB = 0bgTrendBearishColA = 76// ----- Configuración de Velas -----// Colores de Velas (RGB)bullishCandleColorR = 8bullishCandleColorG = 153bullishCandleColorB = 129bearishCandleColorR = 242bearishCandleColorG = 54bearishCandleColorB = 69enableTrendCandleColoring = 1 // 1=SI, 0=NO - Coloreado de Velas según TendenciacandleColoringType = 1 // 1=Profit Wave, 2=Trend - Colorear velas según// ----- Configuración de Soportes y Resistencias -----ensr = 1 // 1=SI, 0=NO - Líneas de Soporte y Resistencia// Colores S&R (RGB)resistanceColorR = 255resistanceColorG = 0resistanceColorB = 0supportColorR = 102supportColorG = 255supportColorB = 0extendLinesType = 2 // 1=Touch, 2=Close - Extender líneas hastapivotchopSensitivity = 20maxSrLines = 50// Colores Money Flow (RGB)mfiBullishColorR = 0mfiBullishColorG = 255mfiBullishColorB = 0mfiBearishColorR = 255mfiBearishColorG = 0mfiBearishColorB = 0// ----- Lógica de Precio y Velas (Heikin Ashi) -----ONCE haOpen = openhaClose = (open + high + low + close) / 4IF barindex > 0 THENhaOpen = (haOpen[1] + haClose[1]) / 2ENDIFhaLow = min(low, min(haClose, haOpen))haHigh = max(high, max(haClose, haOpen))// Asignamos las velas HA como fuente principal para los cálculossrcOpen = haOpensrcHigh = haHighsrcLow = haLowsrcClose = haClosesrcHlc3 = (haHigh + haLow + haClose) / 3// El "Precio Real" se refiere al cierre estándar del gráficorealclose = close// ----- Lógica de la Onda de Beneficio (Profit Wave) -----profitWaveEmaFast = ExponentialAverage[8](srcClose)profitWaveEmaMedium = ExponentialAverage[13](srcClose)profitWaveEmaSlow = ExponentialAverage[21](srcClose)// ----- Lógica del Filtro de Mercado Lateral (Chop Filter) -----// Cálculo manual de DMI+ y DMI- para el filtrotrueRange = TRdiPlusCalculation = 0diMinusCalculation = 0IF high - high[1] > low[1] - low THENdiPlusCalculation = max(0, high - high[1])ELSEdiPlusCalculation = 0ENDIFIF low[1] - low > high - high[1] THENdiMinusCalculation = max(0, low[1] - low)ELSEdiMinusCalculation = 0ENDIF// Si se desea suavizar, se debe aumentar la variable 'chopSensitivity'.smoothedTrueRange = WilderAverage[chopSensitivity](trueRange)smoothedDiPlus = WilderAverage[chopSensitivity](diPlusCalculation)smoothedDiMinus = WilderAverage[chopSensitivity](diMinusCalculation)idiPlus = 0idiMinus = 0IF smoothedTrueRange > 0 THENidiPlus = smoothedDiPlus / smoothedTrueRange * 100idiMinus = smoothedDiMinus / smoothedTrueRange * 100ENDIF// ----- Lógica de Dirección de Tendencia -----// Esta sección traduce la función GetTrendDirectionatrPeriod = 8atrFactor = 1.3atr=AverageTrueRange[atrPeriod]upLevel = (srcHigh + srcLow) / 2 - (atrFactor * atr)downLevel = (srcHigh + srcLow) / 2 + (atrFactor * atr)ONCE trendUp = 0ONCE trendDown = 0ONCE trendSwitch = 1 // Inicializamos en 1 (tendencia alcista)IF srcClose[1] > trendUp[1] THENtrendUp = max(upLevel, trendUp[1])ELSEtrendUp = upLevelENDIFIF srcClose[1] < trendDown[1] THENtrendDown = min(downLevel, trendDown[1])ELSEtrendDown = downLevelENDIFIF srcClose > trendDown[1] THENtrendSwitch = 1ELSIF srcClose < trendUp[1] THENtrendSwitch = -1ENDIFtrendDirection = 0IF trendSwitch = 1 THENtrendDirection = trendUpELSEtrendDirection = trendDownENDIFbullishTrend = (trendDirection = trendUp)bearishTrend = (trendDirection = trendDown)// ----- Lógica del Filtro de Media Móvil -----IF enableMaFilter THENIF maFilterType = 1 THENmaFilter = ExponentialAverage[maFilterLength](srcClose)ELSIF maFilterType = 2 THENmaFilter = Average[maFilterLength](srcClose)ELSIF maFilterType = 3 THEN// VWMA calculada manualmentesumVolPrice = Summation[maFilterLength](srcClose * volume)sumVol = Summation[maFilterLength](volume)IF sumVol > 0 THENmaFilter = sumVolPrice / sumVolENDIFELSIF maFilterType = 4 THENmaFilter = WilderAverage[maFilterLength](srcClose)ELSIF maFilterType = 5 THEN// Hull MA calculada manualmentehalfLength = round(maFilterLength / 2)sqrtLength = round(sqrt(maFilterLength))wma1 = WeightedAverage[halfLength](srcClose)wma2 = WeightedAverage[maFilterLength](srcClose)maFilter = WeightedAverage[sqrtLength](2 * wma1 - wma2)ENDIFENDIF// ----- Lógica de Color de Fondo -----// Define el color del fondo basado en la dirección de la tendenciabackgroundR = 0backgroundG = 0backgroundB = 0backgroundA = 0IF enableBgColor = 1 THENIF bullishTrend = 1 THENbackgroundR = bgTrendBullishColRbackgroundG = bgTrendBullishColGbackgroundB = bgTrendBullishColBbackgroundA = bgTrendBullishColAELSIF bearishTrend = 1 THENbackgroundR = bgTrendBearishColRbackgroundG = bgTrendBearishColGbackgroundB = bgTrendBearishColBbackgroundA = bgTrendBearishColAENDIFENDIF// ----- Lógica de Coloreado de Velas -----// Define el color de las velas Heikin Ashi que se dibujaráncandleR = 128candleG = 128candleB = 128// Color base de la velaIF srcClose > srcOpen THENcandleR = bullishCandleColorRcandleG = bullishCandleColorGcandleB = bullishCandleColorBELSIF srcClose < srcOpen THENcandleR = bearishCandleColorRcandleG = bearishCandleColorGcandleB = bearishCandleColorBENDIF// Color según la tendencia (si está activado)IF enableTrendCandleColoring = 1 THENIF candleColoringType = 1 THEN // Profit WaveIF realclose > profitWaveEmaSlow THENcandleR = bullishCandleColorRcandleG = bullishCandleColorGcandleB = bullishCandleColorBELSIF realclose < profitWaveEmaSlow THENcandleR = bearishCandleColorRcandleG = bearishCandleColorGcandleB = bearishCandleColorBENDIFELSIF candleColoringType = 2 THEN // TrendIF bullishTrend = 1 THENcandleR = bullishCandleColorRcandleG = bullishCandleColorGcandleB = bullishCandleColorBELSIF bearishTrend = 1 THENcandleR = bearishCandleColorRcandleG = bearishCandleColorGcandleB = bearishCandleColorBENDIFENDIFENDIF// ----- Lógica de Señales -----mfl = MoneyFlowIndex[10]// Variable para gestionar el estado y no repetir señales (0=none, 1=buy, 2=sell)ONCE currentMode = 0// Reiniciar el modo si la tendencia cambiaIF bullishTrend <> bullishTrend[1] OR bearishTrend <> bearishTrend[1] THENcurrentMode = 0ENDIF// Condiciones para una vela fuertestrongBullishCandle = (srcClose > srcOpen AND srcOpen = srcLow AND realclose > profitWaveEmaFast AND realclose > profitWaveEmaSlow)strongBearishCandle = (srcClose < srcOpen AND srcOpen = srcHigh AND realclose < profitWaveEmaFast AND realclose < profitWaveEmaSlow)// Condiciones del filtro ChopcanBuy = 0canSell = 0IF enableChopFilter = 1 THENIF floor(idiPlus) > floor(idiMinus) AND floor(idiPlus) >= 45 THENcanBuy = 1ENDIFIF floor(idiMinus) > floor(idiPlus) AND floor(idiMinus) >= 45 THENcanSell = 1ENDIFELSEcanBuy = 1canSell = 1ENDIF// Condiciones del filtro de TiempoisValidTimeRange = 0IF enableTimeFilter = 0 OR (opentime >= startTime AND opentime < endTime) THENisValidTimeRange = 1ENDIF// Condiciones de CompramaFilterBuy = 0IF enableMaFilter = 0 OR (srcClose > maFilter AND realclose > maFilter) THENmaFilterBuy = 1ENDIFmfiBuy = 0IF enableChopFilter = 0 OR mfl > 52 THENmfiBuy = 1ENDIFbuycondition = (bullishTrend = 1 AND strongBullishCandle = 1 AND currentMode <> 1 AND mfiBuy = 1 AND canBuy = 1 AND isValidTimeRange = 1 AND maFilterBuy = 1)// Condiciones de VentamaFilterSell = 0IF enableMaFilter = 0 OR (srcClose < maFilter AND realclose < maFilter) THENmaFilterSell = 1ENDIFmfiSell = 0IF enableChopFilter = 0 OR mfl < 52 THENmfiSell = 1ENDIFsellcondition = (bearishTrend = 1 AND strongBearishCandle = 1 AND currentMode <> 2 AND mfiSell = 1 AND canSell = 1 AND isValidTimeRange = 1 AND maFilterSell = 1)// --- DIBUJO DE OBJETOS ---// Aplicar color de fondoIF enableBgColor = 1 AND (backgroundR+backgroundG+backgroundB) > 0 THENBACKGROUNDCOLOR(backgroundR, backgroundG, backgroundB, backgroundA)ENDIF// Dibujar las velas Heikin Ashi personalizadasDRAWCANDLE(srcOpen, srcHigh, srcLow, srcClose) COLOURED(candleR, candleG, candleB)// Dibujar Señal de CompraIF buycondition AND buycondition[1] = 0 AND enableBuySellSignals = 1 THENDRAWARROWUP(barindex, srcLow - (atr*0.2)) COLOURED(buySignalColorR, buySignalColorG, buySignalColorB)DRAWTEXT("Buy", barindex, srcLow - (atr*1)) COLOURED("darkdarkblue")currentMode = 1ENDIF// Dibujar Señal de VentaIF sellcondition AND sellcondition[1] = 0 AND enableBuySellSignals = 1 THENDRAWARROWDOWN(barindex, srcHigh + (atr*0.2)) COLOURED(sellSignalColorR, sellSignalColorG, sellSignalColorB)DRAWTEXT("Sell", barindex, srcHigh + (atr*1)) COLOURED("darkblue")currentMode = 2ENDIF// Reiniciar modo para permitir nuevas señalesIF currentMode = 1 AND realclose < profitWaveEmaSlow AND srcClose < profitWaveEmaSlow THENcurrentMode = 0ENDIFIF currentMode = 2 AND realclose > profitWaveEmaSlow AND srcClose > profitWaveEmaSlow THENcurrentMode = 0ENDIF// ----- Lógica de Líneas de Objetivo de Beneficio -----ONCE currentSignalBarIndex = -1ONCE targetPrice = 0// Reiniciar modo para permitir nuevas señalesIF currentMode = 1 AND realclose < profitWaveEmaSlow AND srcClose < profitWaveEmaSlow THENcurrentMode = 0currentSignalBarIndex = -1ENDIFIF currentMode = 2 AND realclose > profitWaveEmaSlow AND srcClose > profitWaveEmaSlow THENcurrentMode = 0currentSignalBarIndex = -1ENDIF// Dibujar Señal de CompraIF buycondition AND buycondition[1] = 0 AND enableBuySellSignals = 1 THENDRAWARROWUP(barindex, srcLow - (atr*0.2)) COLOURED(buySignalColorR, buySignalColorG, buySignalColorB)DRAWTEXT("Buy", barindex, srcLow - (atr*1)) COLOURED("darkblue")currentMode = 1currentSignalBarIndex = barindex // Guardamos el índice de la barra de la señalENDIF// Dibujar Señal de VentaIF sellcondition AND sellcondition[1] = 0 AND enableBuySellSignals = 1 THENDRAWARROWDOWN(barindex, srcHigh + (atr*0.2)) COLOURED(sellSignalColorR, sellSignalColorG, sellSignalColorB)DRAWTEXT("Sell", barindex, srcHigh + (atr*1)) COLOURED("darkblue")currentMode = 2currentSignalBarIndex = barindex // Guardamos el índice de la barra de la señalENDIF// ----- Lógica de Soportes y Resistencias -----pivotHigh = (high[pivotchopSensitivity] = highest[2*pivotchopSensitivity+1](high))pivotLow = (low[pivotchopSensitivity] = lowest[2*pivotchopSensitivity+1](low))ONCE pivotPriceArray = 0ONCE pivotStartBarArray = 0ONCE pivotEndBarArray = 0 // Almacena la barra donde la línea se detieneONCE pivotTypeArray = 0 // 1=Resistencia, -1=SoporteONCE pivotCounter = 0// Añadir nuevo pivote si se detectaIF ensr = 1 THENnewPivot = 0IF pivotHigh THENnewPivotPrice = high[pivotchopSensitivity]newPivotType = 1newPivot = 1ELSIF pivotLow THENnewPivotPrice = low[pivotchopSensitivity]newPivotType = -1newPivot = 1ENDIFIF newPivot = 1 THENidx = pivotCounter MOD maxSrLines$pivotPriceArray[idx] = newPivotPrice$pivotStartBarArray[idx] = barindex - pivotchopSensitivity$pivotEndBarArray[idx] = -1 // -1 indica que la línea está activa y extendiéndose$pivotTypeArray[idx] = newPivotTypepivotCounter = pivotCounter + 1ENDIFENDIF// Gestión de las líneas de objetivoONCE targetPriceArray = 0ONCE targetStartBarArray = 0ONCE targetModeArray = 0 // 1 para Buy, -1 para SellONCE targetCounter = 0// Añadir nueva línea de objetivo al array cuando hay una señalIF (buycondition OR sellcondition) AND enableProfitLines = 1 THENIF buycondition THENnewTargetPrice = realclose + (profitTarget * ticksize)newTargetMode = 1ELSE // sellconditionnewTargetPrice = realclose - (profitTarget * ticksize)newTargetMode = -1ENDIF// Usamos un array como buffer circularidx = targetCounter MOD profitTargetMaxLines$targetPriceArray[idx] = newTargetPrice$targetStartBarArray[idx] = barindex$targetModeArray[idx] = newTargetModetargetCounter = targetCounter + 1ENDIF// Dibujar y gestionar las líneas existentes en cada barraIF enableProfitLines = 1 AND IsSet($targetPriceArray[0]) THENFOR i = 0 TO min(targetCounter - 1, profitTargetMaxLines - 1) DO// Si la línea aún no ha sido alcanzada (precio > 0)IF $targetPriceArray[i] > 0 THEN// Dibujar la línea de objetivo extendida hasta la barra actualDRAWSEGMENT($targetStartBarArray[i], $targetPriceArray[i], barindex, $targetPriceArray[i]) STYLE(DottedLine,2)COLOURED(profitTargetColorR, profitTargetColorG, profitTargetColorB)// Comprobar si el objetivo ha sido alcanzadotargetHit = 0IF $targetModeArray[i] = 1 AND high >= $targetPriceArray[i] THEN // Objetivo de CompratargetHit = 1ELSIF $targetModeArray[i] = -1 AND low <= $targetPriceArray[i] THEN // Objetivo de VentatargetHit = 1ENDIF// Si el objetivo es alcanzado, lo "desactivamos" poniendo su precio a 0IF targetHit = 1 THEN$targetPriceArray[i] = 0ENDIFENDIFNEXTENDIF// Dibujar y gestionar líneas de Soportes y ResistenciasIF ensr = 1 AND IsSet($pivotPriceArray[0]) THENFOR i = 0 TO min(pivotCounter - 1, maxSrLines - 1) DO// Si la línea está activaIF $pivotEndBarArray[i] < 0 THENstartBar = $pivotStartBarArray[i]priceLevel = $pivotPriceArray[i]// Extender la línea hasta la barra actualif $pivotTypeArray[i]=1 thenDRAWSEGMENT(startBar, priceLevel, barindex, priceLevel) STYLE(line, 2) COLOURED(resistanceColorR, resistanceColorG,resistanceColorB)elseDRAWSEGMENT(startBar, priceLevel, barindex, priceLevel) STYLE(line, 2) COLOURED( supportColorR, supportColorG, supportColorB)endif// Comprobar si se debe detener la extensión de la líneastopLine = 0IF extendLinesType = 1 THEN // TouchIF $pivotTypeArray[i] = 1 AND high >= priceLevel THENstopLine = 1ELSIF $pivotTypeArray[i] = -1 AND low <= priceLevel THENstopLine = 1ENDIFELSE // CloseIF $pivotTypeArray[i] = 1 AND close >= priceLevel THENstopLine = 1ELSIF $pivotTypeArray[i] = -1 AND close <= priceLevel THENstopLine = 1ENDIFENDIFIF stopLine = 1 THEN$pivotEndBarArray[i] = barindexENDIFELSE // Si la línea ya ha sido detenidastartBar = $pivotStartBarArray[i]endBar = $pivotEndBarArray[i]priceLevel = $pivotPriceArray[i]if $pivotTypeArray[i]=1 thenDRAWSEGMENT(startBar, priceLevel, endBar, priceLevel) STYLE(line, 2) COLOURED(resistanceColorR, resistanceColorG,resistanceColorB)elseendifDRAWSEGMENT(startBar, priceLevel, endBar, priceLevel) STYLE(line, 2) COLOURED( supportColorR, supportColorG, supportColorB)ENDIFNEXTENDIF// ----- Lógica y Dibujo de la Onda de Beneficio (Profit Wave) -----IF enableProfitWave = 1 THEN// Coloreado entre las EMAs si la tendencia es alcistaIF realclose > profitWaveEmaSlow THENrfm=profitWaveUpperBullishColorRgfm=profitWaveUpperBullishColorGbfm=profitWaveUpperBullishColorBafm=profitWaveUpperBullishColorArms=profitWaveLowerBullishColorRgms=profitWaveLowerBullishColorGbms=profitWaveLowerBullishColorBams=profitWaveLowerBullishColorAENDIF// Coloreado entre las EMAs si la tendencia es bajistaIF realclose < profitWaveEmaSlow THENrfm=profitWaveUpperBearishColorRgfm=profitWaveUpperBearishColorGbfm=profitWaveUpperBearishColorBafm=profitWaveUpperBearishColorArms=profitWaveLowerBearishColorRgms=profitWaveLowerBearishColorGbms=profitWaveLowerBearishColorBams=profitWaveLowerBearishColorAENDIFCOLORBETWEEN(profitWaveEmaFast, profitWaveEmaMedium, rfm, gfm, bfm, afm)COLORBETWEEN(profitWaveEmaMedium, profitWaveEmaSlow, rms, gms, bms, ams)ENDIF// ----- RETURN FINAL -----RETURN maFilter COLOURED(maFilterColorR, maFilterColorG, maFilterColorB) AS "MA Filter", profitWaveEmaFast, profitWaveEmaMedium, profitWaveEmaSlow -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
Find exclusive trading pro-tools on
Similar topics: