Untitled
//@version=6 indicator('kadri Al Sat alarm', overlay = true) // Kullanıcı giriş parametreleri emaLength1 = input.int(8, title = 'EMA 1 Uzunluğu') emaLength2 = input.int(14, title = 'EMA 2 Uzunluğu') emaTimeframe = input.timeframe('W', title = 'EMA Zaman Dilimi') entryPrice = input.float(0.0, title = 'Giriş Fiyatı') exitPrice1 = input.float(0.0, title = 'Çıkış Fiyatı 1 (0.880)') exitPrice2 = input.float(0.0, title = 'Çıkış Fiyatı 2 (1.236)') stopLossPercent = input.float(2.0, title = 'Stop Loss (%)') // EMA hesaplamaları ema1 = request.security(syminfo.tickerid, emaTimeframe, ta.ema(close, emaLength1)) ema2 = request.security(syminfo.tickerid, emaTimeframe, ta.ema(close, emaLength2)) // Stop Loss hesaplama stopLossLevel = entryPrice * (1 - stopLossPercent / 100) // Basit çizgiler - her zaman görünür p1 = plot(entryPrice > 0 ? entryPrice : na, 'Giriş Fiyatı', color = #1b12ce, linewidth = 2) p2 = plot(entryPrice > 0 ? stopLossLevel : na, 'Stop Loss', color = color.red, linewidth = 2) p3 = plot(exitPrice1 > 0 ? exitPrice1 : na, 'Çıkış Fiyatı 1', color = #028be7, linewidth = 2) p4 = plot(exitPrice2 > 0 ? exitPrice2 : na, 'Çıkış Fiyatı 2', color = #02e747, linewidth = 2) // EMA çizgileri plot(ema1, 'EMA 8', color = color.green, linewidth = 1) plot(ema2, 'EMA 14', color = color.orange, linewidth = 1) // Uyarılar if close >= exitPrice1 and exitPrice1 > 0 alert('İlk Satış Rakamına Geldi (0.880): ' + str.tostring(exitPrice1)) if close >= exitPrice2 and exitPrice2 > 0 alert('İkinci Satış Rakamına Geldi (1.236): ' + str.tostring(exitPrice2)) if close <= stopLossLevel and entryPrice > 0 alert('Stop Loss seviyesine ulaşıldı: ' + str.tostring(stopLossLevel)) // Input to select the direction of the Fibonacci levels fibDirection = input.string('Top to Bottom', title = 'Fibonacci Direction', options = ['Bottom to Top', 'Top to Bottom'], display = display.none) // Input to set the number of bars to look back for Fibonacci levels lookbackBars = 144 // Input for the number of bars to look further back for the previous high/low lookbackPrevBars = 144 // Define the Fibonacci levels as input parameters fibLevel0 = 0 fibLevel3 = 0.380 fibLevel6 = 0.618 fibLevel7 = 0.880 fibLevel8 = 1 fibLevel9 = 1.236 // Calculate the highest high and lowest low within the lookback period highestHigh = ta.highest(high, lookbackBars) lowestLow = ta.lowest(low, lookbackBars) // Calculate the previous high and low within the extended lookback period previousHigh = ta.highest(high, lookbackPrevBars) previousLow = ta.lowest(low, lookbackPrevBars) // Calculate Fibonacci levels based on the selected direction fib0 = fibDirection == 'Bottom to Top' ? highestHigh - (highestHigh - lowestLow) * fibLevel0 : lowestLow + (highestHigh - lowestLow) * fibLevel0 fib3 = fibDirection == 'Bottom to Top' ? highestHigh - (highestHigh - lowestLow) * fibLevel3 : lowestLow + (highestHigh - lowestLow) * fibLevel3 fib6 = fibDirection == 'Bottom to Top' ? highestHigh - (highestHigh - lowestLow) * fibLevel6 : lowestLow + (highestHigh - lowestLow) * fibLevel6 fib7 = fibDirection == 'Bottom to Top' ? highestHigh - (highestHigh - lowestLow) * fibLevel7 : lowestLow + (highestHigh - lowestLow) * fibLevel7 fib8 = fibDirection == 'Bottom to Top' ? highestHigh - (highestHigh - lowestLow) * fibLevel8 : lowestLow + (highestHigh - lowestLow) * fibLevel8 fib9 = fibDirection == 'Bottom to Top' ? highestHigh - (highestHigh - lowestLow) * fibLevel9 : lowestLow + (highestHigh - lowestLow) * fibLevel9 // // Plot the Fibonacci levels // plot(fib0, color=color.gray, title="Fib Level 0", linewidth=2) // plot(fib3, color = #fde400cf, title="TUZAK 0.786", linewidth=2) // plot(fib6, color=color.new(color.green, 40), title="ONAY 0.618", linewidth=2) // plot(fib7, color = #ff370033, title="ÇIKIŞ 0.880", linewidth=2) // plot(fib8, color=color.new(color.red, 80), title="Fib Level 1.0", linewidth=2) // plot(fib9, color= color.rgb(80, 249, 2, 53), title="2. ÇIKIŞ 1.236", linewidth=2) // Persistent label variables for clearing old labels var array<label> fibLabels = array.new<label>() // Clear old labels only if the array is not empty if array.size(fibLabels) > 0 for i = 0 to array.size(fibLabels) - 1 by 1 label.delete(array.get(fibLabels, i)) array.clear(fibLabels) // Display Fibonacci levels as labels, shifted 8 bars forward and styled to the left label fibLabel0 = label.new(bar_index + 28, fib0, text = 'Dip - ' + str.tostring(fib0, format.mintick), color = color.rgb(234, 0, 255, 91), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.large) label fibLabel3 = label.new(bar_index + 28, fib3, text = 'GİRİŞ - ' + str.tostring(fib3, format.mintick), color = color.rgb(253, 228, 0, 80), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.large) label fibLabel6 = label.new(bar_index + 28, fib6, text = 'ONAY - ' + str.tostring(fib6, format.mintick), color = color.rgb(20, 81, 22, 80), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.large) label fibLabel7 = label.new(bar_index + 28, fib7, text = 'ÇIKIŞ - ' + str.tostring(fib7, format.mintick), color = #ff370033, textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.large) label fibLabel8 = label.new(bar_index + 28, fib8, text = 'Tepe - ' + str.tostring(fib8, format.mintick), color = color.rgb(225, 3, 254, 92), textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.large) label fibLabel9 = label.new(bar_index + 28, fib9, text = '2. ÇIKIŞ - ' + str.tostring(fib9, format.mintick), color = #dd480878, textcolor = color.rgb(255, 255, 255), style = label.style_label_left, size = size.large) // Add previous high/low labels, shifted 8 bars forward // label prevHighLabel = label.new(bar_index + 12, previousHigh, text="EN TEPE - " + str.tostring(previousHigh, format.mintick), color=color.rgb(19, 255, 7, 80), textcolor=color.rgb(255, 255, 255), style=label.style_label_left, size=size.large) // label prevLowLabel = label.new(bar_index + 12, previousLow, text="EN DUSUK - " + str.tostring(previousLow, format.mintick), color=color.rgb(251, 14, 6, 30), textcolor=color.rgb(255, 255, 255), style=label.style_label_left, size=size.large) // Add all labels to the array for tracking array.push(fibLabels, fibLabel0) array.push(fibLabels, fibLabel3) array.push(fibLabels, fibLabel6) array.push(fibLabels, fibLabel7) array.push(fibLabels, fibLabel8) array.push(fibLabels, fibLabel9) // array.push(fibLabels, prevHighLabel) // array.push(fibLabels, prevLowLabel) // Alerts for Fibonacci level crosses alertcondition(ta.crossunder(close, fib0), title = 'Cross Below Fib Level 0', message = 'Price crossed below Fibonacci Level 0') alertcondition(ta.crossover(close, fib0), title = 'Cross Above Fib Level 0', message = 'Price crossed above Fibonacci Level 0') alertcondition(ta.crossunder(close, fib3), title = 'Cross Below Fib Level 0.386', message = 'Price crossed below Fibonacci Level 0.386') alertcondition(ta.crossover(close, fib3), title = 'Cross Above Fib Level 0.386', message = 'Price crossed above Fibonacci Level 0.386')
Leave a Comment