Conversion indicateur TradingView / Pinescript
Forums › ProRealTime forum Français › Support ProBuilder › Conversion indicateur TradingView / Pinescript
- This topic has 1 reply, 2 voices, and was last updated 1 month ago by Iván.
Viewing 2 posts - 1 through 2 (of 2 total)
-
-
09/23/2024 at 12:28 PM #237934
Bonjour à tous,
Est-ce que quelqu’un aurait le temps et la gentillesse de pouvoir convertir un indicateur TradingView pour PRT.
C’est un indicateur 2 en 1, il y a un AMDx (Accumulation Manipulation Distribution) cela trace des rectangles à heure fixe. De même pour le second qui est un indicateur OPR, cela trace un rectangle de telle heure à heure, en prenant en compte par exemple le plus haut et le plus bas des bougies de 15h00 et 15h01.
Je vous poste le code et des captures.
je vous remercie beaucoup par avance.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264/@version=5indicator("OPR", overlay=true)// --- Paramètres personnalisables --- //inputHour = input.int(15, "Heure de la bougie (heure de Paris)", minval=0, maxval=23) // Heure cible que tu peux ajuster (heure de Paris)inputMinute = input.int(32, "Minute de la bougie", minval=0, maxval=59) // Minute cible que tu peux ajusterendHour = 18 // Heure de fin fixe (23h59 heure de Paris)endMinute = 48inputHour1 = input.int(09, "Heure de la bougie (heure de Paris)", minval=0, maxval=23) // Heure cible que tu peux ajuster (heure de Paris)inputMinute1 = input.int(29, "Minute de la bougie", minval=0, maxval=59) // Minute cible que tu peux ajusterendHour1 = 15 // Heure de fin fixe (23h59 heure de Paris)endMinute1 = 31inputHour2 = input.int(18, "Heure de la bougie (heure de Paris)", minval=0, maxval=23) // Heure cible que tu peux ajuster (heure de Paris)inputMinute2 = input.int(49, "Minute de la bougie", minval=0, maxval=59) // Minute cible que tu peux ajusterendHour2 = 19 // Heure de fin fixe (23h59 heure de Paris)endMinute2 = 30inputHour3 = input.int(19, "Heure de la bougie (heure de Paris)", minval=0, maxval=23) // Heure cible que tu peux ajuster (heure de Paris)inputMinute3 = input.int(30, "Minute de la bougie", minval=0, maxval=59) // Minute cible que tu peux ajusterendHour3 = 23 // Heure de fin fixe (23h59 heure de Paris)endMinute3 = 59// --- Fuseau horaire (GMT+2) --- //gmt_offset_hours = -7// Calculer l'heure UTC à partir de l'heure de Parishour_utc = (hour - gmt_offset_hours + 24) % 24 // Ajuste l'heure en UTC (évite les valeurs négatives en ajoutant 24)// Convertir les heures d'entrée en minutes depuis minuit (heure de Paris)target_minutes = inputHour * 60 + inputMinuteend_minutes = endHour * 60 + endMinutetarget_minutes1 = inputHour1 * 60 + inputMinute1end_minutes1 = endHour1 * 60 + endMinute1target_minutes2 = inputHour2 * 60 + inputMinute2end_minutes2 = endHour2 * 60 + endMinute2target_minutes3 = inputHour3 * 60 + inputMinute3end_minutes3 = endHour3 * 60 + endMinute3// --- Variables pour stocker les plus hauts et plus bas de la bougie cible --- //var float opr_high = navar float opr_low = navar int opr_day = na // Stocker le jour pour chaque rectanglevar box opr_box = na // Variable pour tracer le rectanglevar float opr_high1 = navar float opr_low1 = navar int opr_day1 = na // Stocker le jour pour chaque rectanglevar box opr_box1 = na // Variable pour tracer le rectanglevar float opr_high2 = navar float opr_low2 = navar int opr_day2 = na // Stocker le jour pour chaque rectanglevar box opr_box2 = na // Variable pour tracer le rectanglevar float opr_high3 = navar float opr_low3 = navar int opr_day3 = na // Stocker le jour pour chaque rectanglevar box opr_box3 = na // Variable pour tracer le rectangle// Calcul des minutes depuis minuit pour la bougie actuelle (en UTC)current_minutes = hour_utc * 60 + minutecurrent_minutes1 = hour_utc * 60 + minutecurrent_minutes2 = hour_utc * 60 + minutecurrent_minutes3 = hour_utc * 60 + minute// Détection de la bougie cible (heure de Paris définie par l'utilisateur, convertie en UTC)is_target_candle = (hour_utc == inputHour and minute == inputMinute)is_target_candle1 = (hour_utc == inputHour1 and minute == inputMinute1)is_target_candle2 = (hour_utc == inputHour2 and minute == inputMinute2)is_target_candle3 = (hour_utc == inputHour3 and minute == inputMinute3)// Si la bougie est celle définie (ex : 16h25 heure de Paris), on stocke le plus haut et le plus basif (is_target_candle)opr_high := highopr_low := lowopr_day := dayofmonth // On enregistre le jour où la bougie cible est trouvée//if (is_target_candle1)opr_high1 := highopr_low1 := lowopr_day1 := dayofmonth // On enregistre le jour où la bougie cible est trouvée//if (is_target_candle2)opr_high2 := highopr_low2 := lowopr_day2 := dayofmonth // On enregistre le jour où la bougie cible est trouvée//if (is_target_candle3)opr_high3 := highopr_low3 := lowopr_day3 := dayofmonth // On enregistre le jour où la bougie cible est trouvée// Si on est après la bougie cible et avant 23h59 heure de Paris, on trace le rectangleis_after_target = (current_minutes >= target_minutes) and (current_minutes <= end_minutes)is_after_target1 = (current_minutes1 >= target_minutes1) and (current_minutes1 <= end_minutes1)is_after_target2 = (current_minutes2 >= target_minutes2) and (current_minutes2 <= end_minutes2)is_after_target3 = (current_minutes3 >= target_minutes3) and (current_minutes3 <= end_minutes3)if (is_after_target and not na(opr_high) and not na(opr_low) and opr_day == dayofmonth)if na(opr_box)// Création du rectangleopr_box := box.new(left=bar_index, top=opr_high, right=bar_index, bottom=opr_low, border_color=color.orange, bgcolor=color.new(color.orange, 85))else// Mise à jour du côté droit du rectangle pour le prolonger au fur et à mesure de la journéebox.set_right(opr_box, bar_index)//if (is_after_target1 and not na(opr_high1) and not na(opr_low1) and opr_day1 == dayofmonth)if na(opr_box1)// Création du rectangleopr_box1 := box.new(left=bar_index, top=opr_high1, right=bar_index, bottom=opr_low1, border_color=#E9C9B1, bgcolor=color.new(#E9C9B1, 80))else// Mise à jour du côté droit du rectangle pour le prolonger au fur et à mesure de la journéebox.set_right(opr_box1, bar_index)//if (is_after_target2 and not na(opr_high2) and not na(opr_low2) and opr_day2 == dayofmonth)if na(opr_box2)// Création du rectangleopr_box2 := box.new(left=bar_index, top=opr_high2, right=bar_index, bottom=opr_low2, border_color=color.green, bgcolor=color.new(#A5D152, 85))else// Mise à jour du côté droit du rectangle pour le prolonger au fur et à mesure de la journéebox.set_right(opr_box2, bar_index)//if (is_after_target3 and not na(opr_high3) and not na(opr_low3) and opr_day3 == dayofmonth)if na(opr_box3)// Création du rectangleopr_box3 := box.new(left=bar_index, top=opr_high3, right=bar_index, bottom=opr_low3, border_color=#425320, bgcolor=color.new(#425320, 85))else// Mise à jour du côté droit du rectangle pour le prolonger au fur et à mesure de la journéebox.set_right(opr_box3, bar_index)// Réinitialisation des variables pour le jour suivantif (dayofmonth != opr_day)opr_high := naopr_low := naopr_day := naopr_box := na // On réinitialise le rectangle pour le jour suivant//if (dayofmonth != opr_day1)opr_high1 := naopr_low1 := naopr_day1 := naopr_box1 := na // On réinitialise le rectangle pour le jour suivant//if (dayofmonth != opr_day2)opr_high2 := naopr_low2 := naopr_day2 := naopr_box2 := na // On réinitialise le rectangle pour le jour suivant//if (dayofmonth != opr_day3)opr_high3 := naopr_low3 := naopr_day3 := naopr_box3 := na // On réinitialise le rectangle pour le jour suivant//------------//---------------//----------------//-----------------//----------------//-----------------//----------// Input settings for the session box colors, border width, and transparencycolorA = input.color(color.new(color.red, 80), title="Color for Session A and Vertical Lines")colorM = input.color(color.new(color.green, 80), title="Color for Session M and Vertical Lines")colorD = input.color(color.new(color.blue, 80), title="Color for Session D and Vertical Lines")colorX = input.color(color.new(color.yellow, 80), title="Color for Session X and Vertical Lines")borderWidth = input.int(1, title="Border Width", minval=1, maxval=5)transparency = input.int(80, title="Transparency", minval=0, maxval=100)// Input to choose between AMDX and XAMD sessionssessionType = input.string("AMDX", title="Choose Session Type", options=["AMDX", "XAMD"])// Input to choose the drawing styledrawingStyle = input.string("Box", title="Drawing Style", options=["Box", "Line"])// Input to enable or disable vertical dashed linesshowVerticalLines = input.bool(true, title="Show Vertical Lines")showVerticalTimeLabels = input.bool(true, title="Show Vertical Time Labels")// Input to choose vertical line styleverticalLineStyle = input.string("Dashed", title="Vertical Line Style", options=["Solid", "Dotted", "Dashed"])// Convert vertical line style input to line stylevar line_style = line.style_solidif verticalLineStyle == "Dotted"line_style := line.style_dottedelse if verticalLineStyle == "Dashed"line_style := line.style_dashed// Input for session time label transparencytimeLabelTransparency = input.int(80, title="Time Label Transparency", minval=0, maxval=100)// Define the session start and end times based on the selected session type in UTC-4var int startTimeA = navar int endTimeA = navar int startTimeM = navar int endTimeM = navar int startTimeD = navar int endTimeD = navar int startTimeX = navar int endTimeX = naif sessionType == "AMDX"startTimeA := timestamp("GMT-4", year, month, dayofmonth - 1, 18, 00)endTimeA := timestamp("GMT-4", year, month, dayofmonth, 3, 00)startTimeM := timestamp("GMT-4", year, month, dayofmonth, 3, 00)endTimeM := timestamp("GMT-4", year, month, dayofmonth, 9, 00)startTimeD := timestamp("GMT-4", year, month, dayofmonth, 9, 00)endTimeD := timestamp("GMT-4", year, month, dayofmonth, 12, 00)startTimeX := timestamp("GMT-4", year, month, dayofmonth, 12, 00)endTimeX := timestamp("GMT-4", year, month, dayofmonth, 18, 00)elsestartTimeX := timestamp("GMT-4", year, month, dayofmonth - 1, 18, 00)endTimeX := timestamp("GMT-4", year, month, dayofmonth, 0, 00)startTimeA := timestamp("GMT-4", year, month, dayofmonth, 0, 00)endTimeA := timestamp("GMT-4", year, month, dayofmonth, 9, 00)startTimeM := timestamp("GMT-4", year, month, dayofmonth, 9, 00)endTimeM := timestamp("GMT-4", year, month, dayofmonth, 12, 00)startTimeD := timestamp("GMT-4", year, month, dayofmonth, 12, 00)endTimeD := timestamp("GMT-4", year, month, dayofmonth, 18, 00)// Function to format time for labelsformat_time(ts) =>hourx = hour(ts, "GMT-4")minutex = minute(ts, "GMT-4")secondx = second(ts, "GMT-4")str.tostring(hour, "00") + ":" + str.tostring(minute, "00") + ":" + str.tostring(second, "00")// Function to draw session boxes or vertical lines and labelsdrawSession(sessionStartTime, sessionEndTime, color, transparency, labelText) =>var float sessionLow = navar float sessionHigh = navar box sessionBox = navar label sessionLabel = naif (time >= sessionStartTime and time < sessionEndTime)sessionLow := na(sessionLow) ? low : math.min(low, sessionLow)sessionHigh := na(sessionHigh) ? high : math.max(high, sessionHigh)else if (time == sessionEndTime)// Ensure the last bar of the session is included in the high/low calculationsessionLow := na(sessionLow) ? low : math.min(low, sessionLow)sessionHigh := na(sessionHigh) ? high : math.max(high, sessionHigh)if (not na(sessionLow) and not na(sessionHigh))if drawingStyle == "Box"// Draw the session boxsessionBox := box.new(left=sessionStartTime, top=sessionHigh, right=sessionEndTime, bottom=sessionLow, xloc=xloc.bar_time, border_color=color, border_width=borderWidth, bgcolor=color.new(color, 92))// Draw the session labelmidTime = (sessionStartTime + sessionEndTime) / 2sessionLabel := label.new(midTime, sessionHigh, text=labelText, xloc=xloc.bar_time, yloc=yloc.abovebar, color=color.new(color.black, 75), textcolor=color.new(color.yellow, 0), style=label.style_label_center)// Draw the session labelsessionLabel := label.new(sessionStartTime, high, xloc=xloc.bar_time, yloc=yloc.abovebar, color=color.new(color.black, 100), textcolor=color.new(color.white, 0), style=label.style_label_center)sessionLow := nasessionHigh := na// Draw boxes and vertical dashed lines for the specified sessionsdrawSession(startTimeA, endTimeA, colorA, transparency, "A")drawSession(startTimeM, endTimeM, colorM, transparency, "M")drawSession(startTimeD, endTimeD, colorD, transparency, "D")drawSession(startTimeX, endTimeX, colorX, transparency, "X")10/02/2024 at 4:49 PM #238429Holà. Il n'y a pas exactement le même indicateur qu'il a créé :
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108//timeframe(1minute)//------------------------------------------------------------//inputHour1=09inputMinute1=30endhour1=15endminute1=30//------------------------------------------------------------//inputHour2=15inputMinute2=30endhour2=18endminute2=50//------------------------------------------------------------//inputHour3=18inputMinute3=50endhour3=19endminute3=30//------------------------------------------------------------//inputHour4=19inputMinute4=30endhour4=22endminute4=00//------------------------------------------------------------//// Draw Rectangle Range 1//------------------------------------------------------------//if hour=inputhour1 and minute>=inputminute1 and check1=0 theninbar1=barindexcheck1=1endifif check1=1 thenbars1=bars1+1elsebars1=0endifif hour=endhour1 and minute>=endminute1 and check1=1 thenrecH1=highest[max(1,bars1)](high)recL1=lowest[max(1,bars1)](low)endbar1=barindexcheck1=2drawrectangle(inbar1,recH1,endbar1,recL1)coloured("green",80)fillcolor("green",80)endif//------------------------------------------------------------//// Draw Rectangle Range 2//------------------------------------------------------------//if hour=inputhour2 and minute>=inputminute2 and check2=0 theninbar2=barindexcheck2=1endifif check2=1 thenbars2=bars2+1elsebars2=0endifif hour=endhour2 and minute>=endminute2 and check2=1 thenrecH2=highest[max(1,bars2)](high)recL2=lowest[max(1,bars2)](low)endbar2=barindexcheck2=2drawrectangle(inbar2,recL2,endbar2,recH2)coloured("red",80)fillcolor("red",80)endif//------------------------------------------------------------//// Draw Rectangle Range 3//------------------------------------------------------------//if hour=inputhour3 and minute>=inputminute3 and check3=0 theninbar3=barindexcheck3=1endifif check3=1 thenbars3=bars3+1elsebars3=0endifif hour=endhour3 and minute>=endminute3 and check3=1 thenrecH3=highest[max(1,bars3)](high)recL3=lowest[max(1,bars3)](low)endbar3=barindexcheck3=2drawrectangle(inbar3,recL3,endbar3,recH3)coloured("blue",80)fillcolor("blue",80)endif//------------------------------------------------------------//// Draw Rectangle Range 4//------------------------------------------------------------//if hour=inputhour4 and minute>=inputminute4 and check4=0 theninbar4=barindexcheck4=1endifif check4=1 thenbars4=bars4+1elsebars4=0endifif hour>=endhour4 and minute>endminute4 and check4=1 thenendbar4=barindexrecH4=highest[max(1,bars4)](high)recL4=lowest[max(1,bars4)](low)check4=2drawrectangle(inbar4,recH4,endbar4,recL4)coloured("yellow",80)fillcolor("yellow",80)endif//------------------------------------------------------------//// Reset checks//------------------------------------------------------------//if intradaybarindex=0 thencheck1=0check2=0check3=0check4=0endifreturn -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
Find exclusive trading pro-tools on
Similar topics: