0bps

Strategy vault / Other

Boll Fool Version

JavaScript strategy by sabar.

Author
sabar
Complexity
Starter · 24 lines
Parameters
0

The original spec has no written description. Read the source below.

Source JavaScript

 function main (){
    $.CTA("BTC_USDT", function(st){
        var r = st.records; //ObtainKLine array
        if (r.Length <20) return; // FilterKLine length
        var close = r[r.length - 2].close; //Get the upper rootKLine closing price
        var mp = st. positLon.amount; //Get Position Information

        var boll = TA.BOLL(r, 20, 2); // Calculate Bollinger Bands indicator
        var upLine = boll[0];
        //Get Upper Band Array
        var midLine = boll[1]; //Get Middle Band Array
        var downLine = boll[2];//Get Lower Band Array
        var upPrice = upLine [upLine.length -2];
        //Get the upper rootKLine's Upper Band Array
        var midPrice = midLine[midLine.length -2]; 
        //Get the upper rootKLine's Middle Band Array
        var downPrice = downLine[ downLine.length -2];
        //Get the upper rootKLine's Lower Band Array
        if(mp == 1 && (close < midPrice)) return -1; //If holding a long position and the closing price is below the middle band, close long
        if (mp == -1 && (close > midPrice)) return 1; //If holding a short position and the closing price is above the middle line, close the short.
        if (mp == 0 && close > midPrice) return 1; //If there is no position and the closing price is above the upper band, go long
        if (mp == 0 && close < midPrice) return -1; //If there is no position, and the closing price is below the lower band, open a short position
    });
 }     

Published by sabar on the FMZ strategy square · last modified 2021-09-23. 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 production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Boll-Fool-Version.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