IronBot v3
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «ironbot v3.pine» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
IronBot v3 — индикатор TradingView, который анализирует график с использованием уровней Фибоначчи и трендовой линии для определения направления движения цены. При обнаружении нового тренда индикатор инициирует торговую сессию с настройками входа, стоп-лосса и до четырёх уровней тейк-профита, отслеживая её прогресс в реальном времени.
Индикатор отображает на графике линии входа, стоп-лосса и тейк-профитов, графические отметки, а также зоны заливки между уровнями. Информационная панель в правом верхнем углу показывает статистику: количество сделок, серию побед и поражений, текущий баланс, комиссии и общую прибыль.
Важно: несмотря на наличие внутренней логики моделирования сделок, продукт объявлен как индикатор (indicator), а не как стратегия, поэтому он не интегрирован в тестер стратегий TradingView. Все торговые расчёты выполняются вручную в рамках отрисовки индикатора.
Настройки программы
| Настройка | Описание |
|---|---|
| ownerInput | Имя владельца бота, отображаемое как текстовый параметр. |
| analysisWindowInput | Количество исторических свечей для анализа ключевых уровней, таких как максимумы и минимумы, используемых при расчёте уровней Фибоначчи и трендовой линии. |
| fibHighInput | Уровень Фибоначи, определяющий границу восходящего тренда. Цена выше этого уровня и трендовой линии сигнализирует о возможном открытии длинной позиции. |
| fibLowInput | Уровень Фибоначи, определяющий границу нисходящего тренда. Цена ниже этого уровня и трендовой линии сигнализирует о возможном открытии короткой позиции. |
| firstTradeInput | Дата начала генерации торговых сигналов. До этой даты индикатор не отображает сигналы и не инициирует сделки. |
| showTPSLInput | Включает или отключает визуализацию уровней тейк-профита и стоп-лосса на графике, включая линии, метки и зоны заливки. |
| leverageInput | Кредитное плечо, применяемое к сделкам для расчёта размера позиции и итогового дохода с учётом риска. |
| initialCapitalInput | Начальный капитал, используемый для расчёта размера позиции и итоговой прибыли в процентах. |
| exchangeFeeInput | Процент комиссии биржи, учитываемый при расчёте прибыли и убытков по каждой сделке. |
| countryTaxInput | Процент налога страны, который вычитается из чистой прибыли при расчёте итогового баланса. |
| breakEvenEnabledInput | Включает динамическую корректировку уровня стоп-лосса по мере достижения уровней тейк-профита: при TP1 стоп-лосс переносится на цену входа, при TP2 — на TP1, при TP3 — на TP2, при TP4 — сделка закрывается. |
| slRatioInput | Процентное расстояние от цены входа до уровня стоп-лосса, определяющее максимальный допустимый убыток по сделке. |
| tp1RatioInput | Уровень первого тейк-профита, задаваемый как процент от цены входа. |
| tp1ProfitRatioInput | Процент размера позиции, аллоцированный на первый уровень тейк-профита, влияющий на итоговый доход от сделки. |
| tp2RatioInput | Уровень второго тейк-профита, задаваемый как процент от цены входа. |
| tp2ProfitRatioInput | Процент размера позиции, аллоцированный на второй уровень тейк-профита, влияющий на итоговый доход от сделки. |
| tp3RatioInput | Уровень третьего тейк-профита, задаваемый как процент от цены входа. |
| tp3ProfitRatioInput | Процент размера позиции, аллоцированный на третий уровень тейк-профита, влияющий на итоговый доход от сделки. |
| tp4RatioInput | Уровень четвёртого тейк-профита, задаваемый как процент от цены входа. |
| tp4ProfitRatioInput | Процент размера позиции, аллоцированный на четвёртый уровень тейк-профита, влияющий на итоговый доход от сделки. |
| showPanelInput | Включает или отключает информационную панель в правом верхнем углу графика со статистикой торгов. |
Поиск по коду файла
indicator(title = 'IronBot v3', shorttitle = 'IronBot v3', overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back = 1)
type Settings
int firstTrade
int analysisWindow = 0
float fibHigh = 0
float fibLow = 0
float initialCapital = 0
float leverage = 0
bool breakEvenEnabled = false
float slRatio = 0
float tp1Ratio = 0
float tp1ProfitRatio = 0
float tp2Ratio = 0
float tp2ProfitRatio = 0
float tp3Ratio = 0
float tp3ProfitRatio = 0
float tp4Ratio = 0
float tp4ProfitRatio = 0
bool showTPSL = true
bool showPanel = true
float countryTax = 0
float exchangeFees = 0
float accountBalance = 0.0
float accumulatedProfit = 0.0
int totalTrades = 0
int successfulTrades = 0
int failedTrades = 0
int consecutiveLosses = 0
int lossesInARow = 0
int consecutiveWins = 0
int winsInARow = 0
float totalExchangeFees = 0.0
type TradeSession
int startBarIndex = 0
string tradeDirection
float entryLevel
bool hasHitEntry = false
float positionRemaining = 100
bool isClosed = false
bool forceClosed = false
float closeLevel = 0
bool breakEvenAllowed = false
float profit = 0
line entryLine
float capital
line entryMarkerLine = na
label entryMarkerLabel = na
line closeMarkerLine = na
label signalLabel = na
float tp1Level
bool tp1Triggered = false
line tp1Line = na
label tp1Label = na
float tp2Level
bool tp2Triggered = false
line tp2Line = na
label tp2Label = na
float tp3Level
bool tp3Triggered = false
line tp3Line = na
label tp3Label = na
float tp4Level
bool tp4Triggered = false
line tp4Line = na
label tp4Label = na
float slLevel
bool slTriggered = false
float breakEvenLevel
line stopLossMarkerLine = na
label stopLossMarkerLabel = na
var TradeSession currentSession = na
var bool isBullishTrendStarted = false
var bool isBearishTrendStarted = false
var bool hasTrendChanged = false
var bool isBullishTrend = false
var bool isBearishTrend = false
var bool canBuy = false
var bool canSell = false
string ownerInput = input.string(title = 'Owner', defval = '', tooltip = 'Owner name of the bot')
int analysisWindowInput = input.int(title = 'Analysis window', step = 1, defval = 44, tooltip = 'Specifies the number of historical candles to analyze.\nThis influences the calculation of key levels such as highs and lows, which are critical for determining Fibonacci retracement levels.')
float fibHighInput = input.float(title = 'Fibonacci high sensibility', defval = 23.6, options = [23.6, 38.2], tooltip = 'Specifies the level of Fibonnaci where the trend must go up.')
float fibLowInput = input.float(title = 'Fibonacci low sensibility', defval = 78.6, options = [61.8, 78.6], tooltip = 'Specifies the level of Fibonnaci where the trend must go down.')
int firstTradeInput = input.time(defval = timestamp('1 September 2024'), title = 'First trade', tooltip = 'Defines the start date for generating trading signals.')
bool showTPSLInput = input.bool(defval = true, title = 'Display TP/SL', group = 'TRADES', inline = 'Display', tooltip = 'Enables or disables the visualization of take-profit and stop-loss levels on the chart.')
float leverageInput = input.float(title = 'Leverage', step = 1, defval = 15, group = 'TRADES', tooltip = 'Defines the leverage applied to trades for risk and position size calculations.')
float initialCapitalInput = input.float(title = 'Initial Capital', defval = 100, step = 100, group = 'TRADES', tooltip = 'Specifies the starting capital, which is used for calculating position sizes and profits.')
float exchangeFeeInput = input.float(title = 'Exchange Fees %', step = 5, defval = 8, group = 'TRADES', tooltip = 'Sets the percentage of fees applied by the exchange, which is factored into profit calculations.')
float countryTaxInput = input.float(title = 'Country tax %', step = 5, defval = 33, group = 'TRADES', tooltip = 'Allows users to define applicable taxes, which are subtracted from net profits.')
bool breakEvenEnabledInput = input.bool(title = 'Break Even', defval = true, group = 'STOP_LOSS', tooltip = 'When enabled, the stop-loss level adjusts dynamically as take-profit levels are reached.\n- TP1 reached: BE = entry price\n- TP2 reached: BE = TP1\n- TP3 reached: BE = TP2\n- TP4 reached: Trade closed')
float slRatioInput = input.float(title = 'Stop Loss %', step = 0.1, defval = 0.8, group = 'STOP_LOSS', tooltip = 'Defines the percentage distance from the entry price to the stop-loss level.')
float tp1RatioInput = input.float(title = 'TP 1', step = 0.05, defval = 0.65, minval = 0, group = 'TAKE_PROFITS', inline = 'TP1', tooltip = 'Specify the price levels for each take-profit target as a percentage of the entry price.')
float tp1ProfitRatioInput = input.float(title = 'Profit %', step = 5, defval = 60, group = 'TAKE_PROFITS', inline = 'TP1', tooltip = 'Allocate a percentage of the position size to each take-profit level.')
float tp2RatioInput = input.float(title = 'TP 2', step = 0.05, defval = 1.1, minval = 0, group = 'TAKE_PROFITS', inline = 'TP2')
float tp2ProfitRatioInput = input.float(title = 'Profit %', step = 5, defval = 40, group = 'TAKE_PROFITS', inline = 'TP2')
float tp3RatioInput = input.float(title = 'TP 3', step = 0.05, defval = 1.1, minval = 0, group = 'TAKE_PROFITS', inline = 'TP3')
float tp3ProfitRatioInput = input.float(title = 'Profit %', step = 5, defval = 0, group = 'TAKE_PROFITS', inline = 'TP3')
float tp4RatioInput = input.float(title = 'TP 4', step = 0.05, defval = 1.1, minval = 0, group = 'TAKE_PROFITS', inline = 'TP4')
float tp4ProfitRatioInput = input.float(title = 'Profit %', step = 5, defval = 0, group = 'TAKE_PROFITS', inline = 'TP4')
bool showPanelInput = input.bool(defval = true, title = 'Show Panel', group = 'PANELS')
roundUp(number, decimals) =>
factor = math.pow(10, decimals)
math.ceil(number * factor) / factor
riskToReward(float entryLevel, float slLevel, float tpLevel) =>
entryLevel > slLevel ? (tpLevel - entryLevel) / (entryLevel - slLevel) : (entryLevel - tpLevel) / (slLevel - entryLevel)
evaluateTradeProgress(Settings settings, TradeSession session) =>
float profit = 0.0
if not session.hasHitEntry and (session.tradeDirection == 'LONG' ? low <= session.entryLevel : high >= session.entryLevel)
session.startBarIndex := bar_index
session.hasHitEntry := true
tpLevel = session.tp1Level
if not session.tp1Triggered and (session.tradeDirection == 'LONG' ? high >= tpLevel : low <= tpLevel) and session.hasHitEntry
session.tp1Triggered := true
session.positionRemaining -= settings.tp1ProfitRatio
profit += riskToReward(session.entryLevel, session.slLevel, tpLevel) * settings.tp1ProfitRatio / 100 * settings.leverage
if settings.breakEvenEnabled
session.breakEvenAllowed := true
session.breakEvenLevel := session.entryLevel
tpLevel := session.tp2Level
if not session.tp2Triggered and (session.tradeDirection == 'LONG' ? high >= tpLevel : low <= tpLevel) and session.hasHitEntry
session.tp2Triggered := true
session.positionRemaining -= settings.tp2ProfitRatio
profit += riskToReward(session.entryLevel, session.slLevel, tpLevel) * settings.tp2ProfitRatio / 100 * settings.leverage
if settings.breakEvenEnabled
session.breakEvenAllowed := true
session.breakEvenLevel := session.tp1Level
tpLevel := session.tp3Level
if not session.tp3Triggered and (session.tradeDirection == 'LONG' ? high >= tpLevel : low <= tpLevel) and session.hasHitEntry
session.tp3Triggered := true
session.positionRemaining -= settings.tp3ProfitRatio
profit += riskToReward(session.entryLevel, session.slLevel, tpLevel) * settings.tp3ProfitRatio / 100 * settings.leverage
if settings.breakEvenEnabled
session.breakEvenAllowed := true
session.breakEvenLevel := session.tp2Level
tpLevel := session.tp4Level
if not session.tp4Triggered and (session.tradeDirection == 'LONG' ? high >= tpLevel : low <= tpLevel) and session.hasHitEntry
session.tp4Triggered := true
session.positionRemaining -= settings.tp4ProfitRatio
profit += riskToReward(session.entryLevel, session.slLevel, tpLevel) * settings.tp4ProfitRatio / 100 * settings.leverage
session.isClosed := true
if session.breakEvenAllowed and (session.tradeDirection == 'LONG' ? low <= session.breakEvenLevel : high >= session.breakEvenLevel) and bar_index != session.startBarIndex
session.isClosed := true
if not session.slTriggered and session.hasHitEntry and (session.tradeDirection == 'LONG' ? low <= session.slLevel : high >= session.slLevel) and bar_index != session.startBarIndex
session.slTriggered := true
session.isClosed := true
profit += settings.slRatio * -settings.leverage * session.positionRemaining
session.profit += profit
terminateTrade(Settings settings, TradeSession session) =>
session.forceClosed := true
if not session.slTriggered
session.closeLevel := close
session.isClosed := true
session.profit += riskToReward(session.entryLevel, session.slLevel, session.closeLevel) * session.positionRemaining / 100 * settings.leverage
updateLine(lineHandle, int startBar, float level) =>
line.set_xy1(lineHandle, startBar, level)
line.set_xy2(lineHandle, bar_index + 1, level)
updateTradeVisuals(Settings settings, TradeSession session) =>
var offsetDisplay = 1
label.set_x(session.entryMarkerLabel, bar_index + offsetDisplay)
label.set_text(session.entryMarkerLabel, (session.tradeDirection == 'LONG' ? '🔰' : '🔰') + str.tostring(session.entryLevel))
label.set_x(session.stopLossMarkerLabel, bar_index + offsetDisplay)
label.set_text(session.stopLossMarkerLabel, '⛔' + str.tostring(session.slLevel))
label.set_x(session.tp1Label, bar_index + offsetDisplay)
label.set_text(session.tp1Label, session.tp1Triggered ? '✅' : str.tostring((1)) + '️⃣' + str.tostring(session.tp1Level))
if settings.tp2ProfitRatio > 0
label.set_x(session.tp2Label, bar_index + offsetDisplay)
label.set_text(session.tp2Label, session.tp2Triggered ? '✅' : str.tostring((2)) + '️⃣' + str.tostring(session.tp2Level))
if settings.tp3ProfitRatio > 0
label.set_x(session.tp3Label, bar_index + offsetDisplay)
label.set_text(session.tp3Label, session.tp3Triggered ? '✅' : str.tostring((3)) + '️⃣' + str.tostring(session.tp3Level))
if settings.tp4ProfitRatio > 0
label.set_x(session.tp4Label, bar_index + offsetDisplay)
label.set_text(session.tp4Label, session.tp4Triggered ? '✅' : str.tostring((4)) + '️⃣' + str.tostring(session.tp4Level))
updateLine(session.entryMarkerLine, session.startBarIndex, session.entryLevel)
updateLine(session.stopLossMarkerLine, session.startBarIndex, session.slLevel)
updateLine(session.tp1Line, session.startBarIndex,session.tp1Level)
updateLine(session.tp2Line, session.startBarIndex,session.tp2Level)
updateLine(session.tp3Line, session.startBarIndex,session.tp3Level)
updateLine(session.tp4Line, session.startBarIndex,session.tp4Level)
signalLabelUpdate(Settings settings, TradeSession session) =>
label.set_x(session.signalLabel, int(math.avg(bar_index, session.startBarIndex)))
string sign = session.profit >= 0 ? '+' : '-'
label.set_text(session.signalLabel, sign + str.tostring(math.abs(session.profit), '#.##') + '%')
label.set_color(session.signalLabel, session.profit >= 0 ? color.green : color.red)
updateFillPositions(Settings settings, TradeSession session) =>
if session.tp1Triggered
linefill.new(session.entryMarkerLine, session.tp1Line, color = color.new(color.green, 85))
if session.tp2Triggered
linefill.new(session.tp1Line, session.tp2Line, color = color.new(color.green, 85))
if session.tp3Triggered
linefill.new(session.tp2Line, session.tp3Line, color = color.new(color.green, 85))
if session.tp4Triggered
linefill.new(session.tp3Line, session.tp4Line, color = color.new(color.green, 85))
if session.slTriggered
linefill.new(session.stopLossMarkerLine, session.entryMarkerLine, color = color.new(color.red, 85))
if session.forceClosed aПоказано первые 50% кода (символов: 21134)
Открыть по тарифу
Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.
Разовая покупка файла
На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.
Зачем нужен email? После подтверждения оплаты файл сохранится в кабинете на этот email. Если аккаунта ещё нет, мы создадим его и пришлём ссылку для задания пароля. Если аккаунт уже есть, покупка добавится в него. Укажите адрес, к которому у вас есть доступ.
Чтобы оформить заказ, введите email и перейдите к оплате.