Conversion code ICT CISD pour ProRealTime
Forums › ProRealTime forum Français › Support ProBuilder › Conversion code ICT CISD pour ProRealTime
- This topic has 3 replies, 2 voices, and was last updated 5 days ago by
Iván.
-
-
07/05/2025 at 6:17 PM #248671
Bonjour,
Serait-il possible de convertir le code joint en langage ProBuilder pour ProRealTime.
Je joins le lien original pour voir ce que devrait faire le code selon l’auteur!
Merci
https://fr.tradingview.com/script/vUg295KM-CISD-Levels-by-HAZED/123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344//@version=6indicator("CISD Levels by HAZED", "CISD →", overlay=true, max_lines_count=500, max_labels_count=500)// ═══════════════════════════════════════════════════════════════════════════════════════════════// 🎯 CISD LEVEL SETTINGS// ═══════════════════════════════════════════════════════════════════════════════════════════════g_cisd = "🎯 CISD Level Settings"bullishBreakColor = input.color(color.lime, "Bullish Color", group=g_cisd, inline="bull")bullStr = input.string("+CISD", "Text", group=g_cisd, inline="bull")bullishAlerts = input.bool(false, "Alert", group=g_cisd, inline="bull")bearishBreakColor = input.color(color.red, "Bearish Color", group=g_cisd, inline="bear")bearStr = input.string("-CISD", "Text", group=g_cisd, inline="bear")bearishAlerts = input.bool(false, "Alert", group=g_cisd, inline="bear")keepLevels = input.bool(false, "Historical Levels", group=g_cisd)maxLevels = input.int(15, "Max Historical Levels", minval=1, maxval=50, group=g_cisd)// ═══════════════════════════════════════════════════════════════════════════════════════════════// 🎨 LINE APPEARANCE// ═══════════════════════════════════════════════════════════════════════════════════════════════g_line = "🎨 Line Appearance"lineWidth = input.int(2, "Line Width", minval=1, maxval=5, group=g_line)styleOption = input.string("Solid (─)", "Line Style", ["Solid (─)", "Dotted (┈)", "Dashed (╌)"], group=g_line)lineTransparency = input.int(0, "Line Transparency", minval=0, maxval=100, group=g_line)lookAheadBars = input.int(15, "Line Extension Bars", minval=1, maxval=50, group=g_line)// ═══════════════════════════════════════════════════════════════════════════════════════════════// 📝 TEXT APPEARANCE// ═══════════════════════════════════════════════════════════════════════════════════════════════g_text = "📝 Text Appearance"showLabels = input.bool(true, "Show Labels", group=g_text)labelOffset = input.int(0, "Label Offset (Bars)", minval=0, maxval=20, group=g_text)textSizeOption = input.string("Small", "Text Size", ["Tiny", "Small", "Normal", "Large", "Huge"], group=g_text)textFontOption = input.string("Default", "Text Font", ["Default", "Monospace"], group=g_text)textBoldOption = input.bool(true, "Bold Text", group=g_text)// ═══════════════════════════════════════════════════════════════════════════════════════════════// 📊 STATISTICS TABLE// ═══════════════════════════════════════════════════════════════════════════════════════════════g_stats = "📊 Statistics Table"showTable = input.bool(true, "Enable Statistics Table", group=g_stats)tablePosition = input.string("Top Right", "Table Position", ["Top Right", "Bottom Right", "Middle Right", "Bottom Center", "Middle Left"], group=g_stats)tableFontOption = input.string("Default", "Table Font", ["Default", "Monospace"], group=g_stats)// ═══════════════════════════════════════════════════════════════════════════════════════════════// 🚨 ALERT SETTINGS// ═══════════════════════════════════════════════════════════════════════════════════════════════g_alerts = "🚨 Alert Settings"alertFrequency = input.string("Once Per Bar Close", "Alert Frequency", ["Once Per Bar", "Once Per Bar Close"], group=g_alerts)// ═══════════════════════════════════════════════════════════════════════════════════════════════// CONSTANTS & CACHED VALUES - OPTIMIZATION// ═══════════════════════════════════════════════════════════════════════════════════════════════// Pre-calculate constants to avoid repeated switch operationslineStyle = styleOption == "Dotted (┈)" ? line.style_dotted : styleOption == "Dashed (╌)" ? line.style_dashed : line.style_solidtextSize = textSizeOption == "Tiny" ? size.tiny : textSizeOption == "Small" ? size.small : textSizeOption == "Normal" ? size.normal : textSizeOption == "Large" ? size.large : size.hugetextFont = textFontOption == "Default" ? font.family_default : font.family_monospacetableFont = tableFontOption == "Default" ? font.family_default : font.family_monospacetablePos = tablePosition == "Top Right" ? position.top_right : tablePosition == "Bottom Right" ? position.bottom_right : tablePosition == "Middle Right" ? position.middle_right : tablePosition == "Bottom Center" ? position.bottom_center : position.middle_left// Pre-calculate colors to avoid repeated color.new() callsbullLineColor = color.new(bullishBreakColor, lineTransparency)bearLineColor = color.new(bearishBreakColor, lineTransparency)transparentWhite = color.new(color.white, 100)// Cache commonly used valuesmaxKeep = keepLevels ? maxLevels : 1adjustedOffset = labelOffset == 0 ? 0 : labelOffsetlookAheadX = bar_index + lookAheadBarslabelX = lookAheadX + adjustedOffset// ═══════════════════════════════════════════════════════════════════════════════════════════════// TYPE DEFINITIONS & HELPER FUNCTIONS - OPTIMIZED// ═══════════════════════════════════════════════════════════════════════════════════════════════type MarketStructurefloat topPricefloat bottomPricebool isBullishtype CisdLevelline levelLinelabel levelLabelbool isCompletedint creationBar// Optimized label creation - single function call pathcreateOptimizedLabel(x, y, txt, txtColor) =>if showLabelsif textBoldOptionlabel.new(x, y, txt, color=transparentWhite, textcolor=txtColor, style=label.style_label_left, text_font_family=textFont, size=textSize, text_formatting=text.format_bold)elselabel.new(x, y, txt, color=transparentWhite, textcolor=txtColor, style=label.style_label_left, text_font_family=textFont, size=textSize, text_formatting=text.format_none)elsena// Optimized cleanup with early exitcleanupOptimized(levels) =>levelCount = array.size(levels)if levelCount > maxKeepdeleteCount = levelCount - maxKeepfor i = 1 to deleteCountif array.size(levels) > 0oldLevel = array.shift(levels)line.delete(oldLevel.levelLine)if not na(oldLevel.levelLabel)label.delete(oldLevel.levelLabel)// ═══════════════════════════════════════════════════════════════════════════════════════════════// STATE VARIABLES - ORIGINAL LOGIC PRESERVED// ═══════════════════════════════════════════════════════════════════════════════════════════════var MarketStructure currentStructure = MarketStructure.new(0, 0, false)var array<CisdLevel> bullishLevels = array.new<CisdLevel>()var array<CisdLevel> bearishLevels = array.new<CisdLevel>()var bool isBullishPullback = falsevar bool isBearishPullback = falsevar float potentialTopPrice = navar float potentialBottomPrice = navar int bullishBreakIndex = navar int bearishBreakIndex = navar bool currentState = false// ═══════════════════════════════════════════════════════════════════════════════════════════════// MAIN CISD LOGIC - ORIGINAL ALGORITHM WITH OPTIMIZATIONS// ═══════════════════════════════════════════════════════════════════════════════════════════════// Cache OHLC values to avoid repeated lookupsc = closeo = openc1 = close[1]o1 = open[1]h = highl = lowh1 = high[1]l1 = low[1]bi = bar_indexbi1 = bar_index[1]// Optimized candle type detectionisBullishCandle = c > oisBearishCandle = c < oprevBullishCandle = c1 > o1prevBearishCandle = c1 < o1// Optimized pullback detectionbearishPullbackDetected = prevBullishCandle and not isBearishPullbackbullishPullbackDetected = prevBearishCandle and not isBullishPullback// Bearish Pullback Logic - ORIGINALif bearishPullbackDetectedisBearishPullback := truepotentialTopPrice := o1bullishBreakIndex := bi1// Bullish Pullback Logic - ORIGINALif bullishPullbackDetectedisBullishPullback := truepotentialBottomPrice := o1bearishBreakIndex := bi1// Update Potential Levels During Pullbacks - ORIGINAL with optimizationsif isBullishPullbackif o < potentialBottomPricepotentialBottomPrice := obearishBreakIndex := bielse if isBearishCandle and o > potentialBottomPricepotentialBottomPrice := obearishBreakIndex := biif isBearishPullbackif o > potentialTopPricepotentialTopPrice := obullishBreakIndex := bielse if isBullishCandle and o < potentialTopPricepotentialTopPrice := obullishBreakIndex := bi// Structure Updates - Bearish Break - ORIGINAL with optimizationsif l < currentStructure.bottomPricecurrentStructure.bottomPrice := lcurrentStructure.isBullish := falseif isBearishPullback and (bi - bullishBreakIndex != 0)indexDiff = bi - bullishBreakIndexcurrentStructure.topPrice := math.max(high[indexDiff], high[indexDiff - 1])isBearishPullback := falsebearishLine = line.new(bullishBreakIndex, potentialTopPrice, lookAheadX, potentialTopPrice, color=bullLineColor, width=lineWidth, style=lineStyle)bearishLabel = createOptimizedLabel(labelX, potentialTopPrice, bullStr, bullishBreakColor)newLevel = CisdLevel.new(bearishLine, bearishLabel, false, bi)array.push(bearishLevels, newLevel)else if prevBullishCandle and isBearishCandlecurrentStructure.topPrice := h1isBearishPullback := falsebearishLine = line.new(bullishBreakIndex, potentialTopPrice, lookAheadX, potentialTopPrice, color=bullLineColor, width=lineWidth, style=lineStyle)bearishLabel = createOptimizedLabel(labelX, potentialTopPrice, bullStr, bullishBreakColor)newLevel = CisdLevel.new(bearishLine, bearishLabel, false, bi)array.push(bearishLevels, newLevel)// Structure Updates - Bullish Break - ORIGINAL with optimizationsif h > currentStructure.topPricecurrentStructure.isBullish := truecurrentStructure.topPrice := hif isBullishPullback and (bi - bearishBreakIndex != 0)indexDiff = bi - bearishBreakIndexcurrentStructure.bottomPrice := math.min(low[indexDiff], low[indexDiff - 1])isBullishPullback := falsebullishLine = line.new(bearishBreakIndex, potentialBottomPrice, lookAheadX, potentialBottomPrice, color=bearLineColor, width=lineWidth, style=lineStyle)bullishLabel = createOptimizedLabel(labelX, potentialBottomPrice, bearStr, bearishBreakColor)newLevel = CisdLevel.new(bullishLine, bullishLabel, false, bi)array.push(bullishLevels, newLevel)else if prevBearishCandle and isBullishCandlecurrentStructure.bottomPrice := l1isBullishPullback := falsebullishLine = line.new(bearishBreakIndex, potentialBottomPrice, lookAheadX, potentialBottomPrice, color=bearLineColor, width=lineWidth, style=lineStyle)bullishLabel = createOptimizedLabel(labelX, potentialBottomPrice, bearStr, bearishBreakColor)newLevel = CisdLevel.new(bullishLine, bullishLabel, false, bi)array.push(bullishLevels, newLevel)// Optimized cleanupcleanupOptimized(bullishLevels)cleanupOptimized(bearishLevels)// Update active levels and handle alerts - ORIGINAL LOGIC with optimizationsbullishSize = array.size(bullishLevels)if bullishSize >= 1latest = array.get(bullishLevels, bullishSize - 1)if not latest.isCompletedlevelPrice = latest.levelLine.get_y2()// Optimized level managementif c >= levelPriceline.set_x2(latest.levelLine, lookAheadX)if not na(latest.levelLabel)label.set_x(latest.levelLabel, labelX)elselatest.isCompleted := truecurrentState := false// Optimized alert conditionif bearishAlerts and (alertFrequency == "Once Per Bar" or barstate.isconfirmed)alert("🔴 Bearish CISD Level Broken at " + str.tostring(levelPrice))bearishLine = line.new(bullishBreakIndex, potentialTopPrice, lookAheadX, potentialTopPrice, color=bullLineColor, width=lineWidth, style=lineStyle)bearishLabel = createOptimizedLabel(labelX, potentialTopPrice, bullStr, bullishBreakColor)newLevel = CisdLevel.new(bearishLine, bearishLabel, false, bi)array.push(bearishLevels, newLevel)bearishSize = array.size(bearishLevels)if bearishSize >= 1latest = array.get(bearishLevels, bearishSize - 1)if not latest.isCompletedlevelPrice = latest.levelLine.get_y2()// Optimized level managementif c <= levelPriceline.set_x2(latest.levelLine, lookAheadX)if not na(latest.levelLabel)label.set_x(latest.levelLabel, labelX)elselatest.isCompleted := truecurrentState := true// Optimized alert conditionif bullishAlerts and (alertFrequency == "Once Per Bar" or barstate.isconfirmed)alert("🟢 Bullish CISD Level Broken at " + str.tostring(levelPrice))bullishLine = line.new(bearishBreakIndex, potentialBottomPrice, lookAheadX, potentialBottomPrice, color=bearLineColor, width=lineWidth, style=lineStyle)bullishLabel = createOptimizedLabel(labelX, potentialBottomPrice, bearStr, bearishBreakColor)newLevel = CisdLevel.new(bullishLine, bullishLabel, false, bi)array.push(bullishLevels, newLevel)// ═══════════════════════════════════════════════════════════════════════════════════════════════// 📊 OPTIMIZED STATISTICS TABLE// ═══════════════════════════════════════════════════════════════════════════════════════════════if showTable and barstate.islastvar table statsTable = table.new(tablePos, 2, 3,bgcolor=color.new(color.white, 0),border_color=color.new(color.gray, 50),frame_color=color.new(color.gray, 30),frame_width=1, border_width=1)// Pre-calculate table colorslabelBg = color.new(color.gray, 90)valueBg = color.new(color.white, 0)stateColor = currentState ? color.new(color.green, 25) : color.new(color.red, 25)// Market State Rowtable.cell(statsTable, 0, 0, "Market State",text_size=size.small, text_color=color.black, text_font_family=tableFont,bgcolor=labelBg, text_formatting=text.format_bold)stateText = currentState ? "BULLISH 📈" : "BEARISH 📉"table.cell(statsTable, 1, 0, stateText,text_size=size.small, text_color=color.white,text_font_family=tableFont, text_formatting=text.format_bold, bgcolor=stateColor)// Bullish Level Rowtable.cell(statsTable, 0, 1, "+CISD Level",text_size=size.small, text_color=color.black, text_font_family=tableFont,bgcolor=labelBg, text_formatting=text.format_bold)bullText = "--"if bullishSize > 0latestBull = array.get(bullishLevels, bullishSize - 1)bullText := str.tostring(latestBull.levelLine.get_y2(), format.mintick)table.cell(statsTable, 1, 1, bullText,text_size=size.small, text_color=color.new(color.green, 0), text_font_family=tableFont,text_formatting=text.format_bold, bgcolor=valueBg)// Bearish Level Rowtable.cell(statsTable, 0, 2, "-CISD Level",text_size=size.small, text_color=color.black, text_font_family=tableFont,bgcolor=labelBg, text_formatting=text.format_bold)bearText = "--"if bearishSize > 0latestBear = array.get(bearishLevels, bearishSize - 1)bearText := str.tostring(latestBear.levelLine.get_y2(), format.mintick)table.cell(statsTable, 1, 2, bearText,text_size=size.small, text_color=color.new(color.red, 0), text_font_family=tableFont,text_formatting=text.format_bold, bgcolor=valueBg)07/07/2025 at 3:01 PM #248705Le voilà.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187// -----------------------------------------// PRC_CISD Levels by HAZED//version = 0//07.07.25//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge// ---------------------------------------------// ---------------------------------------------// INPUTS// ---------------------------------------------maxLevels = 15lookAheadBars = 15labelOffset = 5// ---------------------------------------------// CALCULATION// ---------------------------------------------ONCE bullLevelCount = 0ONCE bearLevelCount = 0isBullishCandle = close > openisBearishCandle = close < openprevBullishCandle = close[1] > open[1]prevBearishCandle = close[1] < open[1]ONCE isBullishPullback = 0ONCE isBearishPullback = 0bearishPullbackDetected = prevBullishCandle AND not isBearishPullbackbullishPullbackDetected = prevBearishCandle AND not isBullishPullbackIF bearishPullbackDetected THENisBearishPullback = 1potentialTopPrice = open[1]bullishBreakIndex = barindex[1]ENDIFIF bullishPullbackDetected THENisBullishPullback = 1potentialBottomPrice = open[1]bearishBreakIndex = barindex[1]ENDIFIF isBullishPullback THENIF open < potentialBottomPrice THENpotentialBottomPrice = openbearishBreakIndex = barindexELSIF isBearishCandle AND open > potentialBottomPrice THENpotentialBottomPrice = openbearishBreakIndex = barindexENDIFENDIFIF isBearishPullback THENIF open > potentialTopPrice THENpotentialTopPrice = openbullishBreakIndex = barindexELSIF isBullishCandle AND open < potentialTopPrice THENpotentialTopPrice = openbullishBreakIndex = barindexENDIFENDIFONCE isBullishStructure = 1ONCE currentBottomPrice = lowIF low < currentBottomPrice THENcurrentBottomPrice = lowisBullishStructure = 0IF isBearishPullback AND (barindex - bullishBreakIndex > 0) THENindexDiff=barindex-bullishBreakIndexisBearishPullback = 0currentTopPrice = max(high[indexDiff],high[indexDiff-1])// New level$bearPrice[bearLevelCount] = potentialTopPrice$bearStartIndex[bearLevelCount] = bullishBreakIndex$bearEndIndex[bearLevelCount]=barindex+lookAheadBars$bearIsCompleted[bearLevelCount] = 0$bearCreationBar[bearLevelCount]=barindexbearLevelCount = bearLevelCount + 1elsif prevBullishCandle and isBearishcandle thencurrentTopPrice=high[1]isBearishPullback=0// New level$bearPrice[bearLevelCount] = potentialTopPrice$bearStartIndex[bearLevelCount] = bullishBreakIndex$bearEndIndex[bearLevelCount]=barindex+lookAheadBars$bearIsCompleted[bearLevelCount] = 0$bearCreationBar[bearLevelCount]=barindexbearLevelCount = bearLevelCount + 1ENDIFENDIFONCE currentTopPrice = highIF high > currentTopPrice THENcurrentTopPrice = highisBullishStructure = 1IF isBullishPullback AND (barindex - bearishBreakIndex > 0) THENindexDiff=barindex-bearishBreakIndexcurrentBottomPrice=min(low[indexDiff],low[indexDiff-1])isBullishPullback = 0// New levelbullLevelCount = bullLevelCount + 1$bullPrice[bullLevelCount] = potentialBottomPrice$bullStartIndex[bullLevelCount] = bearishBreakIndex$bullEndIndex[bullLevelCount]=barindex+lookAheadBars$bullIsCompleted[bullLevelCount] = 0$bullCreationBar[bullLevelCount]=barindexelsif prevBearishCandle and isBullishCandle thencurrentBottomPrice=low[1]isBullishPullback = 0// New levelbullLevelCount = bullLevelCount + 1$bullPrice[bullLevelCount] = potentialBottomPrice$bullStartIndex[bullLevelCount] = bearishBreakIndex$bullEndIndex[bullLevelCount]=barindex+lookAheadBars$bullIsCompleted[bullLevelCount] = 0$bullCreationBar[bullLevelCount]=barindexENDIFENDIFif islastbarupdate thenfor i=bullLevelCount downto bullLevelCount-maxLevels doidx=barindex-$bullStartIndex[i]if $bullIsCompleted[i] = 0 thenfor j=idx-1 downto 0 doif close[j]<=$bullPrice[i] then$bullIsCompleted[i] = 1$bullEndIndex[i]=barindex[j]breakendifnextdrawsegment($bullStartIndex[i],$bullPrice[i],$bullEndIndex[i],$bullPrice[i])coloured("red")drawtext("-CISD",$bullEndIndex[i]+labelOffset,$bullPrice[i])coloured("red")elsedrawsegment($bullStartIndex[i],$bullPrice[i],$bullEndIndex[i],$bullPrice[i])coloured("red")drawtext("-CISD",$bullEndIndex[i]+labelOffset,$bullPrice[i])coloured("red")endifnextfor i=bearLevelCount downto bearLevelCount-maxLevels doidx=barindex-$bearStartIndex[i]if $bearIsCompleted[i] = 0 thenfor j=idx-1 downto 0 doif close[j]>=$bearPrice[i] then$bearIsCompleted[i] = 1$bearEndIndex[i]=barindex[j]breakendifnextdrawsegment($bearStartIndex[i],$bearPrice[i],$bearEndIndex[i],$bearPrice[i])coloured("green")drawtext("+CISD",$bearEndIndex[i]+labelOffset,$bearPrice[i])coloured("green")elsedrawsegment($bearStartIndex[i],$bearPrice[i],$bearEndIndex[i],$bearPrice[i])coloured("green")drawtext("+CISD",$bearEndIndex[i]+labelOffset,$bearPrice[i])coloured("green")endifnextendifreturn1 user thanked author for this post.
07/08/2025 at 9:16 AM #248714Bonjour Iván merci pour la conversion du code.
J’ai cependant un petit soucis dans le paramétrage ligne 11, pour des raisons de lisibilité du graphique je souhaiterais n’afficher que le dernier +CISD et le dernier -CISD !
Mais sur les images jointes on peut voir que c’est les deux derniers -CISD qui s’affichent toujours!
Aurais-tu une idée pour résoudre ce problème ?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187// -----------------------------------------// PRC_CISD Levels by HAZED//version = 0//07.07.25//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge// ---------------------------------------------// ---------------------------------------------// INPUTS// ---------------------------------------------maxLevels = 1lookAheadBars = 15labelOffset = 5// ---------------------------------------------// CALCULATION// ---------------------------------------------ONCE bullLevelCount = 0ONCE bearLevelCount = 0isBullishCandle = close > openisBearishCandle = close < openprevBullishCandle = close[1] > open[1]prevBearishCandle = close[1] < open[1]ONCE isBullishPullback = 0ONCE isBearishPullback = 0bearishPullbackDetected = prevBullishCandle AND not isBearishPullbackbullishPullbackDetected = prevBearishCandle AND not isBullishPullbackIF bearishPullbackDetected THENisBearishPullback = 1potentialTopPrice = open[1]bullishBreakIndex = barindex[1]ENDIFIF bullishPullbackDetected THENisBullishPullback = 1potentialBottomPrice = open[1]bearishBreakIndex = barindex[1]ENDIFIF isBullishPullback THENIF open < potentialBottomPrice THENpotentialBottomPrice = openbearishBreakIndex = barindexELSIF isBearishCandle AND open > potentialBottomPrice THENpotentialBottomPrice = openbearishBreakIndex = barindexENDIFENDIFIF isBearishPullback THENIF open > potentialTopPrice THENpotentialTopPrice = openbullishBreakIndex = barindexELSIF isBullishCandle AND open < potentialTopPrice THENpotentialTopPrice = openbullishBreakIndex = barindexENDIFENDIFONCE isBullishStructure = 1ONCE currentBottomPrice = lowIF low < currentBottomPrice THENcurrentBottomPrice = lowisBullishStructure = 0IF isBearishPullback AND (barindex - bullishBreakIndex > 0) THENindexDiff=barindex-bullishBreakIndexisBearishPullback = 0currentTopPrice = max(high[indexDiff],high[indexDiff-1])// New level$bearPrice[bearLevelCount] = potentialTopPrice$bearStartIndex[bearLevelCount] = bullishBreakIndex$bearEndIndex[bearLevelCount]=barindex+lookAheadBars$bearIsCompleted[bearLevelCount] = 0$bearCreationBar[bearLevelCount]=barindexbearLevelCount = bearLevelCount + 1elsif prevBullishCandle and isBearishcandle thencurrentTopPrice=high[1]isBearishPullback=0// New level$bearPrice[bearLevelCount] = potentialTopPrice$bearStartIndex[bearLevelCount] = bullishBreakIndex$bearEndIndex[bearLevelCount]=barindex+lookAheadBars$bearIsCompleted[bearLevelCount] = 0$bearCreationBar[bearLevelCount]=barindexbearLevelCount = bearLevelCount + 1ENDIFENDIFONCE currentTopPrice = highIF high > currentTopPrice THENcurrentTopPrice = highisBullishStructure = 1IF isBullishPullback AND (barindex - bearishBreakIndex > 0) THENindexDiff=barindex-bearishBreakIndexcurrentBottomPrice=min(low[indexDiff],low[indexDiff-1])isBullishPullback = 0// New levelbullLevelCount = bullLevelCount + 1$bullPrice[bullLevelCount] = potentialBottomPrice$bullStartIndex[bullLevelCount] = bearishBreakIndex$bullEndIndex[bullLevelCount]=barindex+lookAheadBars$bullIsCompleted[bullLevelCount] = 0$bullCreationBar[bullLevelCount]=barindexelsif prevBearishCandle and isBullishCandle thencurrentBottomPrice=low[1]isBullishPullback = 0// New levelbullLevelCount = bullLevelCount + 1$bullPrice[bullLevelCount] = potentialBottomPrice$bullStartIndex[bullLevelCount] = bearishBreakIndex$bullEndIndex[bullLevelCount]=barindex+lookAheadBars$bullIsCompleted[bullLevelCount] = 0$bullCreationBar[bullLevelCount]=barindexENDIFENDIFif islastbarupdate thenfor i=bullLevelCount downto bullLevelCount-maxLevels doidx=barindex-$bullStartIndex[i]if $bullIsCompleted[i] = 0 thenfor j=idx-1 downto 0 doif close[j]<=$bullPrice[i] then$bullIsCompleted[i] = 1$bullEndIndex[i]=barindex[j]breakendifnextdrawsegment($bullStartIndex[i],$bullPrice[i],$bullEndIndex[i],$bullPrice[i])coloured("red")drawtext("-CISD",$bullEndIndex[i]+labelOffset,$bullPrice[i])coloured("red")elsedrawsegment($bullStartIndex[i],$bullPrice[i],$bullEndIndex[i],$bullPrice[i])coloured("red")drawtext("-CISD",$bullEndIndex[i]+labelOffset,$bullPrice[i])coloured("red")endifnextfor i=bearLevelCount downto bearLevelCount-maxLevels doidx=barindex-$bearStartIndex[i]if $bearIsCompleted[i] = 0 thenfor j=idx-1 downto 0 doif close[j]>=$bearPrice[i] then$bearIsCompleted[i] = 1$bearEndIndex[i]=barindex[j]breakendifnextdrawsegment($bearStartIndex[i],$bearPrice[i],$bearEndIndex[i],$bearPrice[i])coloured("green")drawtext("+CISD",$bearEndIndex[i]+labelOffset,$bearPrice[i])coloured("green")elsedrawsegment($bearStartIndex[i],$bearPrice[i],$bearEndIndex[i],$bearPrice[i])coloured("green")drawtext("+CISD",$bearEndIndex[i]+labelOffset,$bearPrice[i])coloured("green")endifnextendifreturn07/08/2025 at 2:32 PM #248728ok.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187// -----------------------------------------// PRC_CISD Levels by HAZED//version = 0//07.07.25//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge// ---------------------------------------------// ---------------------------------------------// INPUTS// ---------------------------------------------maxLevels = 3lookAheadBars = 15labelOffset = 5// ---------------------------------------------// CALCULATION// ---------------------------------------------ONCE bullLevelCount = 0ONCE bearLevelCount = 0isBullishCandle = close > openisBearishCandle = close < openprevBullishCandle = close[1] > open[1]prevBearishCandle = close[1] < open[1]ONCE isBullishPullback = 0ONCE isBearishPullback = 0bearishPullbackDetected = prevBullishCandle AND not isBearishPullbackbullishPullbackDetected = prevBearishCandle AND not isBullishPullbackIF bearishPullbackDetected THENisBearishPullback = 1potentialTopPrice = open[1]bullishBreakIndex = barindex[1]ENDIFIF bullishPullbackDetected THENisBullishPullback = 1potentialBottomPrice = open[1]bearishBreakIndex = barindex[1]ENDIFIF isBullishPullback THENIF open < potentialBottomPrice THENpotentialBottomPrice = openbearishBreakIndex = barindexELSIF isBearishCandle AND open > potentialBottomPrice THENpotentialBottomPrice = openbearishBreakIndex = barindexENDIFENDIFIF isBearishPullback THENIF open > potentialTopPrice THENpotentialTopPrice = openbullishBreakIndex = barindexELSIF isBullishCandle AND open < potentialTopPrice THENpotentialTopPrice = openbullishBreakIndex = barindexENDIFENDIFONCE isBullishStructure = 1ONCE currentBottomPrice = lowIF low < currentBottomPrice THENcurrentBottomPrice = lowisBullishStructure = 0IF isBearishPullback AND (barindex - bullishBreakIndex > 0) THENindexDiff=barindex-bullishBreakIndexisBearishPullback = 0currentTopPrice = max(high[indexDiff],high[indexDiff-1])// New levelbearLevelCount = bearLevelCount + 1$bearPrice[bearLevelCount] = potentialTopPrice$bearStartIndex[bearLevelCount] = bullishBreakIndex$bearEndIndex[bearLevelCount]=barindex+lookAheadBars$bearIsCompleted[bearLevelCount] = 0$bearCreationBar[bearLevelCount]=barindexelsif prevBullishCandle and isBearishcandle thencurrentTopPrice=high[1]isBearishPullback=0// New levelbearLevelCount = bearLevelCount + 1$bearPrice[bearLevelCount] = potentialTopPrice$bearStartIndex[bearLevelCount] = bullishBreakIndex$bearEndIndex[bearLevelCount]=barindex+lookAheadBars$bearIsCompleted[bearLevelCount] = 0$bearCreationBar[bearLevelCount]=barindexENDIFENDIFONCE currentTopPrice = highIF high > currentTopPrice THENcurrentTopPrice = highisBullishStructure = 1IF isBullishPullback AND (barindex - bearishBreakIndex > 0) THENindexDiff=barindex-bearishBreakIndexcurrentBottomPrice=min(low[indexDiff],low[indexDiff-1])isBullishPullback = 0// New levelbullLevelCount = bullLevelCount + 1$bullPrice[bullLevelCount] = potentialBottomPrice$bullStartIndex[bullLevelCount] = bearishBreakIndex$bullEndIndex[bullLevelCount]=barindex+lookAheadBars$bullIsCompleted[bullLevelCount] = 0$bullCreationBar[bullLevelCount]=barindexelsif prevBearishCandle and isBullishCandle thencurrentBottomPrice=low[1]isBullishPullback = 0// New levelbullLevelCount = bullLevelCount + 1$bullPrice[bullLevelCount] = potentialBottomPrice$bullStartIndex[bullLevelCount] = bearishBreakIndex$bullEndIndex[bullLevelCount]=barindex+lookAheadBars$bullIsCompleted[bullLevelCount] = 0$bullCreationBar[bullLevelCount]=barindexENDIFENDIFif islastbarupdate thenfor i=bullLevelCount downto bullLevelCount+1-maxLevels doidx=barindex-$bullStartIndex[i]if $bullIsCompleted[i] = 0 thenfor j=idx-1 downto 0 doif close[j]<=$bullPrice[i] then$bullIsCompleted[i] = 1$bullEndIndex[i]=barindex[j]breakendifnextdrawsegment($bullStartIndex[i],$bullPrice[i],$bullEndIndex[i],$bullPrice[i])coloured("red")drawtext("-CISD",$bullEndIndex[i]+labelOffset,$bullPrice[i])coloured("red")elsedrawsegment($bullStartIndex[i],$bullPrice[i],$bullEndIndex[i],$bullPrice[i])coloured("red")drawtext("-CISD",$bullEndIndex[i]+labelOffset,$bullPrice[i])coloured("red")endifnextfor i=bearLevelCount downto bearLevelCount+1-maxLevels doidx=barindex-$bearStartIndex[i]if $bearIsCompleted[i] = 0 thenfor j=idx-1 downto 0 doif close[j]>=$bearPrice[i] then$bearIsCompleted[i] = 1$bearEndIndex[i]=barindex[j]breakendifnextdrawsegment($bearStartIndex[i],$bearPrice[i],$bearEndIndex[i],$bearPrice[i])coloured("green")drawtext("+CISD",$bearEndIndex[i]+labelOffset,$bearPrice[i])coloured("green")elsedrawsegment($bearStartIndex[i],$bearPrice[i],$bearEndIndex[i],$bearPrice[i])coloured("green")drawtext("+CISD",$bearEndIndex[i]+labelOffset,$bearPrice[i])coloured("green")endifnextendifreturn1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on