TradingView
ROBO_Trading
3 Th08 2019 01:13

Robot WhiteBox MultiMA 

Bitcoin / US Dollar Perpetual Inverse Swap ContractBitMEX

Mô tả

Script for backtesting of the trading strategy of the robot.
Strategy similar to the strategy of ShiftMA, but is used on 3 limit orders, instead of one.

Lime lines - for opening of a long position.
Red lines - for opening of a short position.
The blue line (always one) - for closing of any positions.

Phát hành các Ghi chú

+

Phát hành các Ghi chú

+ cancel order

Phát hành các Ghi chú

+ lots 4 long & short

Phát hành các Ghi chú

+ MA Offset

Phát hành các Ghi chú

Strategy.exit

Phát hành các Ghi chú

+MA Closing

Phát hành các Ghi chú

+checkboxes
Bình luận
OutsourcE
Hi,noro!
Could you please replace the ma logic in the strategy with this formula:
src = input(close)
xa= input(25, title="杠杆倍数")
xb= input(20, title="杠杆倍数")
xd= input(15, title="杠杆倍数")
xc= input(10, title="杠杆倍数")
xe= input(5, title="杠杆倍数")
maval=input(1, title="合并几个柱子")
ma = sma(src,maval)*xa/(xa+1-(xa*0.005))
ma2 = sma(src, maval)*xb/(xb+1-(xb*0.005))
ma3 =sma(src, maval)*xc/(xc+1-(xc*0.005))
ma4 = sma(src, maval)*xd/(xd+1-(xd*0.005))
ma5 = sma(src, maval)*xe/(xe+1-(xe*0.005))
ICEKI
Such a great strategy robot; appreciated your generosity noro =D
a00lekseykolos
спасибо. отличная логика. прекрасно можно натянуть стратегию
HowardLuchinsky
Не могу разобраться почему стратегия входит в сделку не со 100% как указано в лотлонг. Всегда меньше
ivnsv222
Как писали уже выше, есть проблема с размерами ордеров.
Конкретный пример - ETHUSDT 1H, дата сделки 2021-05-19 (та самая, когда рынок обвалился на 30-50%)
Стартовый капитал 1000, размер ставки на весь банкролл.
Вначале идут три ордера по 0.4036 (L1,L2,L3).
Далее в тот же день чуть позже три ордера по уже 1.6144 (S1, S2, S3)
И наконец ордер L1 по 5.2468 - это более чем в 10 раз больше нашего баланса.
Это сильно искажает результаты стратегии. Вместо 10-кратного зароботка мы бы в тот день получили маржин-колл.
ivnsv222
Наконец разобрался почему размер ордеров увеличивается в разы время от времени.
Вот исправленый код, который исправляет это:

if ma > 0
if lotlong > 0
lotslong = 0.0
lotslong := strategy.position_size >= 0 ? round(strategy.position_size / lotlong) : -1.0
strategy.entry("L1", strategy.long, lotlong, limit = longline1, when = (lotslong == 0 and long1 and truetime))
lotslong := strategy.position_size >= 0 ? round(strategy.position_size / lotlong) : -1.0
strategy.entry("L2", strategy.long, lotlong, limit = longline2, when = (lotslong <= 1 and lotslong >= 0 and long2 and truetime))
lotslong := strategy.position_size >= 0 ? round(strategy.position_size / lotlong) : -1.0
strategy.entry("L3", strategy.long, lotlong, limit = longline3, when = (lotslong <= 2 and lotslong >= 0 and long3 and truetime))
if lotshort > 0
lotsshort = 0.0
lotsshort := strategy.position_size <= 0 ? round(strategy.position_size / lotshort) : 1.0
strategy.entry("S1", strategy.short, lotshort, limit = shortline1, when = (lotsshort == 0 and short1 and truetime))
lotsshort := strategy.position_size <= 0 ? round(strategy.position_size / lotshort) : 1.0
strategy.entry("S2", strategy.short, lotshort, limit = shortline2, when = (lotsshort >= -1 and lotsshort <= 0 and short2 and truetime))
lotsshort := strategy.position_size <= 0 ? round(strategy.position_size / lotshort) : 1.0
strategy.entry("S3", strategy.short, lotshort, limit = shortline3, when = (lotsshort >= -2 and lotsshort <= 0 and short3 and truetime))

Можно просто скопипастить вместо аналогичного кода в оригинальном скрипте.
P.S. Табуляция не работает при вставке кода, поэтому после каждого if нужно сделать вручную по 4 отступа в каждой сточке.
nehaker
@ivnsv222, спасибо, дружище!!!
sizovw
@ROBO_Trading Привет,какая то проблема с датами,хотел посмотреть профитность стратегии с 2021,но не получается,тупо пропадают все сделки.В коде тоже попробовал поменять дату,тоже самое...
HowardLuchinsky
Здравствуйте. А подскажите, где про настройки скрипта почитать?
HowardLuchinsky
Здравствуйте. Скажите, а где про настройки прочитать?
Thêm nữa