按价格区间记录累积成交量

//假如以当天的开盘价为基数,以10个跳点为区间,计算每个区间的成交量
//1
Params
    integer set(10);
Vars
    series<numeric> base_price;
    series<numeric> index;
    global map<Integer,numeric> vol_value;
    numeric temp;
    numeric temp_index;

Defs
    
Events
    OnInit()
    {
        printclear;
    }
    OnBar(ArrayRef<Integer> indexes)
    {
        print("------");
        If(TRUEDATE(0)<>TRUEDATE(1))//判断当天第一根tick
        {
            mapClear(vol_value);
            printclear;
            vol_value[(open)/PriceScale] = vol;
            vol_value[(open+set*minmove*PriceScale)/PriceScale] = 0;
            //last_price = open;
        }
        Else
        {
            numeric val;
            Integer ret = MapUpperBound(vol_value, close);
            print("ret:"+text(ret));
            If(ret==0)//需要往前插入
            {
                integer key;
                GetMapKey(vol_value,0,key);
                numeric delt = roundup((key-close)/(set*minmove*pricescale),0);
                print("delta:"+text(delt));
                integer i;
                for i = 1 to delt
                {
                    If(i <> delt)
                    {
                        vol_value[key - i * minmove * PriceScale * set] = 0;
                    }Else
                    {
                        vol_value[key - i * minmove * PriceScale * set] = vol;
                    }
                }
            }else if(ret<>InvalidInteger)//中间插入
            {
                integer key;
                GetMapKey(vol_value,ret-1,key);
                numeric val;
                GetMapValue(vol_value,ret-1,val);
                vol_value[key] = val+vol;
            }else //尾部插入
            {
                array<integer> keys;
                GetMapKeys(vol_value,keys);
                numeric size = GetArraySize(keys);
                print("size:"+text(size));
                integer bottom = keys[size-1];
                print("bottom:"+text(bottom));
                numeric delt = RoundDown((close-bottom)/(set*minmove*pricescale),0);
                print("delta:"+text(delt));
                integer i;
                If(delt == 0)//只移动一格
                {
                    vol_value[bottom] = vol_value[bottom] + vol;
                    vol_value[bottom+set*minmove*PriceScale] = 0;
                }Else//移动多格
                {
                    for i = 1 to delt
                    {
                        If(i <> delt)
                        {
                            vol_value[bottom + i * minmove * PriceScale * set] = 0;
                        }
                        Else
                        {
                            vol_value[bottom + i * minmove * PriceScale * set] = vol;
                        }
                    }
                    vol_value[bottom+(delt+1)*set*minmove*PriceScale] = 0;
                }
            }
        }
        
        PlotString("mark",text(currentbar));
        {
            
            print("close:"+text(close));
            print("vol:"+text(vol));
            print("cb:"+text(currentbar));
            print("vol_value:" + TextMap(vol_value));
        }
        
    }


委托价格不是按指定价格,而是按最新价格的对手价发单
按哪个价格发送委托
记录开仓价格的函数有异常
成交量达到某一数值时的对应价格
为什么buy不按指定价格发单
你好老师,如何调用分价表里面的价格,成交量,比例,竞买率
如何获取实时成交量或成交额对应的期货价格
统计TICK成交量
预测成交量
获取成交量