掘金社区

请教,收盘价连续5个bar站在20均线上就买进,怎么写?Pinned highlighted

fw 发表在策略研究 2019-02-17 10:12:21

策略研究
244
1
0

请教,RB1905收盘价连续5条K线站在20均线(3分钟周期)上就买进,怎么写?

评论: 1
  • import talib
    data = history_n(symbol='SHFE.rb1905', frequency='180s', end_time='2019-02-18 20:00:20', fields='close', count=30, df=True)['close'].values
    ma20 = talib.MA(data, timeperiod=20)[-5:]
    if data[-5:].all()>ma20.all():
    order_value(symbol='SHFE.rb1905', value=1,side=OrderSide_Buy, order_type=OrderType_Market, position_effect=PositionEffect_Open)
    大概这样,你试试看

    2019-02-19 14:33:17

Looks like your connection to 掘金量化社区 - 量化交易者的策略交流学习社区 was lost, please wait while we try to reconnect.