К основному содержимому
Все коллекцииТорговые ботыSignal бот
Образец TradingView бота (скрипт indicator)

Образец TradingView бота (скрипт indicator)

Гайд: Бесплатный образец TradingView бота (основаннного на Study скрипте)

Gery avatar
Автор: Gery
Обновлено более 7 мес. назад

Этот пример кода создан для вас, чтобы вы могли проверить автоматизацию своего первого торгового бота на TradingView.

TradingView Bot Study включает как лонг, так и шорт позиции. Эта стратегия открывает лонг позицию, если цена актива увеличилась во время предыдущей свечи (цена закрытия была выше, чем цена открытия), и закрывает лонг позицию, если цена актива снизилась во время предыдущей свечи (цена закрытия была ниже, чем цена открытия). Обратное верно для шорт позиции. Следовательно, когда срабатывает сигнал выхода на лонг позицию, он автоматически запускает вход в шорт позицию. Этот код можно применить к любому таймфрейму и любому активу.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Wunderbit Trading (WBT)

//@version=5
indicator("Signal Tester", overlay=true)

///////////////// LONG //////////////////
isEntry_Long = false
isEntry_Long := nz(isEntry_Long[1], false)

isExit_Long = false
isExit_Long := nz(isExit_Long[1], false)

entry_long = not isEntry_Long and close>open
exit_long = not isExit_Long and open>close

if (entry_long)
isEntry_Long := true
isExit_Long := false

if (exit_long)
isEntry_Long := false
isExit_Long := true

///////////// SHORT //////////////

isEntry_Short = false
isEntry_Short := nz(isEntry_Short[1], false)

isExit_Short = false
isExit_Short := nz(isExit_Short[1], false)


entry_short=not isEntry_Short and open>close
exit_short= not isExit_Short and close>open

if (entry_short)
isEntry_Short := true
isExit_Short := false

if (exit_short)
isEntry_Short := false
isExit_Short := true

alertcondition(entry_long, title="Enter Long")
alertcondition(exit_long, title="Exit Long")
alertcondition(entry_short, title="Enter Short")
alertcondition(exit_short, title="Exit Short")

plotshape(series=entry_long, text="Long", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(series=exit_long, text="EXIT Long",style=shape.triangledown, location=location.abovebar, color=color.purple, size=size.small)
plotshape(series=entry_short, text="Short", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
plotshape(series=exit_short, text="EXIT Short",style=shape.triangleup, location=location.belowbar, color=color.purple, size=size.small)

Примечание

Вам нужна подписка TradingView Pro, чтобы иметь возможность получать Webhook уведомления на WunderTrading.

Нашли ответ на свой вопрос?