向3Commas购买pine脚本策略的信号



我正在学习Pine Script(尽管速度很慢(。我有一个借来的策略脚本,我想创建一个警报,这样我就可以向3Commas机器人发送买入和收盘信号。到目前为止,我找到的最接近的帮助是https://www.youtube.com/watch?v=-d_rFRd3o-0&t=1292s然而,我正在尝试的脚本有不止一个入口和出口。有什么想法吗?脚本如下:

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AliNotty
// with thanks to MarketShree 
//@version=5
strategy('Supertrend Strategy', overlay=true)
atrPeriod1 = input(7, 'ATR Length-1')
factor1 = input(1.5, 'Factor-1')
atrPeriod2 = input(10, 'ATR Length-2')
factor2 = input(2, 'Factor-2')
atrPeriod3 = input(20, 'ATR Length-3')
factor3 = input(3, 'Factor-3')
[superTrend1, direction1] = ta.supertrend(factor1, atrPeriod1)
[superTrend2, direction2] = ta.supertrend(factor2, atrPeriod2)
[superTrend3, direction3] = ta.supertrend(factor3, atrPeriod3)
if ta.change(direction1) < 0
strategy.entry('LONG', strategy.long)
if ta.change(direction1) > 0
strategy.entry('SHORT', strategy.short)
if ta.change(direction2) < 0
strategy.entry('LONG', strategy.long)
if ta.change(direction2) > 0
strategy.entry('SHORT', strategy.short)
if ta.change(direction3) < 0
strategy.entry('LONG', strategy.long)
if ta.change(direction3) > 0
strategy.entry('SHORT', strategy.short)
colResistance = direction1 == 1 and direction1 == direction1[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport = direction1 == -1 and direction1 == direction1[1] ? color.new(color.green, 0) : color.new(color.green, 100)
plot(superTrend1, color=colResistance, linewidth=2)
plot(superTrend1, color=colSupport, linewidth=2)
colResistance1 = direction2 == 1 and direction2 == direction2[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport1 = direction2 == -1 and direction2 == direction2[1] ? color.new(color.green, 0) : color.new(color.green, 100)
plot(superTrend2, color=colResistance, linewidth=2)
plot(superTrend2, color=colSupport, linewidth=2)
colResistance2 = direction3 == 1 and direction3 == direction3[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport2 = direction3 == -1 and direction3 == direction3[1] ? color.new(color.green, 0) : color.new(color.green, 100)
plot(superTrend3, color=colResistance1, linewidth=2)
plot(superTrend3, color=colSupport1, linewidth=2)

您的脚本使用3个supertrend也许你只需要3个逗号长/短机器人中的一个,不是吗?不要忘记编辑strategy.entry函数中的alert_message参数:(

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AliNotty
// with thanks to MarketShree 
//@version=5
strategy('Supertrend Strategy', overlay=true)
atrPeriod1 = input(7, 'ATR Length-1')
factor1 = input(1.5, 'Factor-1')

[superTrend1, direction1] = ta.supertrend(factor1, atrPeriod1)
if ta.change(direction1) < 0
strategy.entry('LONG', strategy.long, alert_message = "3 commas open long deal command")
if ta.change(direction1) > 0
strategy.entry('SHORT', strategy.short, alert_message = "3 commas open short deal command")
colResistance = direction1 == 1 and direction1 == direction1[1] ? color.new(color.red, 0) : color.new(color.red, 100)
colSupport = direction1 == -1 and direction1 == direction1[1] ? color.new(color.green, 0) : color.new(color.green, 100)
plot(superTrend1, color=colResistance, linewidth=2)
plot(superTrend1, color=colSupport, linewidth=2)

最新更新