tip = 'In order for indicator to work, you need to keep at least one of the level groups on the chart' showl1 = input(true, title="Show Liquidations Level 1", tooltip = tip, group = 'Plotting Parameters') showl2 = input(true, title="Show Liquidations Level 2", tooltip = tip, group = 'Plotting Parameters') showl3 = input(true, title="Show Liquidations Level 3", tooltip = tip, group = 'Plotting Parameters') show_params = input(false, title="Show OI delta parameters", tooltip = tip, group = 'Plotting Parameters')
// Input Source src = input(ohlc4, title = 'Source', group = 'Indicator Source')
// Histogram Settings hist_amnt = input(30, 'Number of histograms (density)', group = 'Histogram settings') bars_amnt = input(1000, 'Number of bars to lookback', group = 'Histogram settings') dist_from_candle = input(5, 'Histgram distance from last candle', group = 'Histogram settings')
// Liquidation levels lines_amnt = input(1000, title="Number of lines to plot", group = 'Line settings') h3 = input.float(3.4, step = 0.1, title="Large Liquidation Level", group = 'Line settings') h2 = input.float(2.2, step = 0.1, title="Middle Liquidation Level", group = 'Line settings') h1 = input.float(1.8, step = 0.1, title="Small Liquidation Level", group = 'Line settings')
if OI_delta_open_h2 and not OI_delta_open_h3 and showl2 y_value := calculate_leverage(src, 0.01, true) l := f_drawLine(x1, x2, y_value, color_100x, line.style_solid, 2) f_append(h2_array, l)
if OI_delta_open_h1 and not OI_delta_open_h2 and not OI_delta_open_h3 and showl1 y_value := calculate_leverage(src, 0.01, true) l := f_drawLine(x1, x2, y_value, color_100x, line.style_dotted, 1) f_append(h1_array, l)
// Draw Histogram if barstate.islast and show_hist // Define lows and highs of the histograms for i = 0 to hist_amnt - 1 histogramLow = range_low + hist_height * i histogramHigh = range_low + hist_height * (i + 1) array.set(hist_lower_list, i, histogramLow) array.set(hist_higher_list, i, histogramHigh)
for i = 0 to array.size(hist_data) - 1 y = array.get(hist_data, i)
for j = 0 to hist_amnt - 1 histogramLow = array.get(hist_lower_list, j) histogramHigh = array.get(hist_higher_list, j) if y >= histogramLow and y <= histogramHigh array.set(hist_targets, j, array.get(hist_targets, j) + 1)
maxHistogramtarget = array.max(hist_targets) // add this line to get the max target value
for i = 0 to hist_amnt - 1 histogramLow = array.get(hist_lower_list, i) histogramHigh = array.get(hist_higher_list, i) histogramtarget = array.get(hist_targets, i) histogramWidth = math.floor((histogramtarget + 0.49) * 2)
// Compute alpha based on the size of the histogram, max alpha is 100 alpha = 100 - math.floor(histogramtarget / maxHistogramtarget * 100)
// Define color based on comparison with close price barColor = histogramHigh > close ? color.new(color.red, alpha) : color.new(color.teal, alpha)
ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.