0bps

Strategy vault / Tools & templates

Weekly Quarter Price Difference Drawing Plugin

Can plot the price difference chart between quarterly and this week for hedging analysis The plug-in can be started with one click on the trading terminal, free of charge, and convenient for manual trading. Detailed…

Author
小草
Complexity
Starter · 26 lines
Parameters
0

Can plot the price difference chart between quarterly and this week for hedging analysis

The plug-in can be started with one click on the trading terminal, free of charge, and convenient for manual trading. Detailed introduction:https://www.fmz.com/digest-topic/5051

Source JavaScript


var chart = { 
    __isStock: true,    
    title : { text : 'Spread analysis chart'},                     
    xAxis: { type: 'datetime'},                 
    yAxis : {                                        
        title: {text: 'Spread'},                   
        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
}

Published by 小草 on the FMZ strategy square · last modified 2020-03-24. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a tested, production-ready module from strategies/Weekly-Quarter-Price-Difference-Drawing-Plugin.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open