0bps

Strategy vault / Other

Demo on How to Dynamically Adjust Strategy Parameters Using Strategy Interactions

The strategy requires constant testing and adjustment, and the parameters are often changed. Stopping and restarting every time is laborious and laborious, and the original profit progress will be lost (although it…

JavaScriptOther
Author
momox
Complexity
Starter · 39 lines
Parameters
2

The strategy requires constant testing and adjustment, and the parameters are often changed. Stopping and restarting every time is laborious and laborious, and the original profit progress will be lost (although it can also be restored through global parameters). In fact, botvs has provided a way to dynamically adjust parameters-"Strategy Interaction""

Parameters

NameDefaultWhat it controls
A3999AAAParameters of
B3BotvsBBBParameters of

Source JavaScript

var Interval=2000;

//AAA,BBBParameters in the strategy that are intended to be dynamically adjusted
var AAA=0;
var BBB="hello world";

function main() {
    while(true){
        onTick();
        Sleep(Interval);
    }
}

function onTick(){
    set_command();
    Log("AAA="+AAA,"       BBB="+BBB);
}

//Obtain dynamic parameters (strategy interaction content))
 function set_command() {

     var get_command = GetCommand();//  GetCommandThe method is to get parameters, the obtained parameters are in string format, format is "Parameter Name:Parameter Value" SeeBotVS APIDocumentation
     if (get_command != null) {
         if (get_command.indexOf("A3:") == 0) {  //If the incoming parameter is namedA3(with"A3:"Leading, indicatingA3Parameters)

             AAA = (get_command.replace("A3:", "")); //Assign to the value in the strategyAAA(Replace the leading string with empty, and the remaining is our parameter value)

             Log("AAABecome:" + AAA);
         }
         
          if (get_command.indexOf("B3:") == 0) {  //If the incoming parameter is namedB3(with"B3:"Leading, indicatingB3Parameters)

             BBB = (get_command.replace("B3:", "")); //Assign to the value in the strategyBBB(Replace the leading string with empty, and the remaining is our parameter value)

             Log("BBBBecome:" + BBB);
         }

     }
 }

Published by momox on the FMZ strategy square · last modified 2016-01-09. 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/Demo-on-How-to-Dynamically-Adjust-Strategy-Parameters-Using-Strategy-Interactions.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