The resource loading... loading...

When the weekly quarterly difference chart plugin

Author: The grass, Date: 2020-02-29 21:42:15
Tags:

Quarterly-weekly spreads can be plotted for hedge analysis

The plug-in can be started at the touch of a button on the transaction terminal, without charging a fee, and facilitates manual transactions.https://www.fmz.com/digest-topic/5051



var chart = { 
    __isStock: true,    
    title : { text : '差价分析图'},                     
    xAxis: { type: 'datetime'},                 
    yAxis : {                                        
        title: {text: '差价'},                   
        opposite: false,                             
    },
    series : [                    
        {name : "diff", data : []}, 

    ]
}
function main() {
    exchange.SetContractType('quarter')
    var recordsA = exchange.GetRecords(PERIOD_M5)
    exchange.SetContractType('this_week')
    var recordsB = exchange.GetRecords(PERIOD_M5)
    
    for(var i=0;i<Math.min(recordsA.length,recordsB.length);i++){
        var diff = recordsA[recordsA.length-Math.min(recordsA.length,recordsB.length)+i].Close - recordsB[recordsB.length-Math.min(recordsA.length,recordsB.length)+i].Close
        chart.series[0].data.push([recordsA[recordsA.length-Math.min(recordsA.length,recordsB.length)+i].Time, diff])
    }
    return chart
}

More

topiori$Cross can't rewrite! What to do?

The grassYou can change the return to $.PlotLine ((dff), select the drawing library, add a loop, are you referring to the transaction library?

topioriI don't know if it's going to become an independent operation.

The grassIs the cross function redefined, can't it?