Type/to search

50行网格策略(教学)

Study
8
Follow
1363
Followers
Source
JavaScript
var _StopLoss = 0
var _StopWin = 0
var _Grid = []

function UpdateGrid(nowBidsPrice, nowAsksPrice, direction){    // up 1, down -1
    if(_Grid.length == 0 || (direction == 1 && nowBidsPrice - _Grid[_Grid.length - 1].price > _GridPointDis) || 
        (direction == -1 && _Grid[_Grid.length - 1].price - nowAsksPrice > _GridPointDis)){

        var nowPrice = direction == 1 ? nowBidsPrice : nowAsksPrice
        _Grid.push({
            price: _Grid.length == 0 ? nowPrice : _Grid[_Grid.length - 1].price + _GridPointDis * direction,
            hold : {price: 0, amount: 0}, 
Strategy parameters
Strategy parameters
网格方向
网格节点数量
网格节点下单量
网格节点间距
网格节点平仓差价
Comment
All comments (7)

    bitmex回测显示没设置合约

    5 years ago

    这个策略是个现货的,BITMEX是期货交易所。

    5 years ago

    大神有空写个python版的吗?我小白好多看不懂,

    7 years ago

    好的。

    7 years ago

    提问:期货软件平仓时,得选择某个开仓,平掉该仓。我看代码里在平仓的时候,操作和开仓一样的,只是新开了一个和之前相反的仓位。所以就比较纠结,希望小梦老大有时间了解答下:)

    7 years ago

    哦 这个策略仅仅是个现货版的,有兴趣可以改造成期货版的。
    现货只有买卖。买了就是开多了,卖了就是 平多(如果之前有个对应的买入操作)或者开空。

    7 years ago

    好的,我再看下期货相关的:)

    7 years ago
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)