Conversion code ICT CISD pour ProRealTime
Forums › ProRealTime forum Français › Support ProBuilder › Conversion code ICT CISD pour ProRealTime
- This topic has 0 replies, 1 voice, and was last updated 8 hours ago by
Alai-n.
Viewing 1 post (of 1 total)
-
-
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) -
AuthorPosts
Viewing 1 post (of 1 total)
Find exclusive trading pro-tools on
Similar topics: