Gunbot's AutoConfig supports global state via setVariable when filters pass. Use resetVariable to change or revert those globals when the job's main filters do not pass.
Nearly every option that follows can be set without editing files by hand.
Click the ⋮ (three-dots) menu ➜ AutoConfig, step through the wizard, and press Save; it will write a correct autoconfig.json for you.
setVariable vs. resetVariable
In a typical AutoConfig job that processes pairs:
setVariableruns when at least one pair passes the job'sfilters(orfilters2, etc.).resetVariableruns when the job executes but no pairs pass the filters.
For jobs that use a global filter (for example, a custom filter checking this.variables), setVariable applies on true and resetVariable on false.
Configuration Example
This example sets a global strongBuyActive flag when a filter passes, and clears it when the filter fails.
{
"strongSignalDetector": {
"enabled": true,
"type": "manageOverrides", // Type can vary; logic depends on filters
"schedule": "*/5 * * * *",
"pairs": {
"exchange": "binance",
"include": "USDT-BTC" // Used as index
},
"filters": {
"isStrongBuyConditionMet": { // Complex filter to detect strong buy
"filterType": "custom",
"script": "/* ... some logic returning true if strong buy ... */" // Example
}
},
"setVariable": { // Executed if 'isStrongBuyConditionMet' is true for USDT-BTC
"strongBuyActive": true,
"lastStrongBuySignalTime": " new Date().toISOString() "
},
"resetVariable": { // Executed if 'isStrongBuyConditionMet' is false for USDT-BTC
"strongBuyActive": false
// We might not want to clear 'lastStrongBuySignalTime' here,
// or set it to null, depending on desired logic.
}
}
}
In the strongSignalDetector job:
- If the
isStrongBuyConditionMetfilter passes forBTC-USDT:- The
setVariableblock executes, settingstrongBuyActivetotrueand updatinglastStrongBuySignalTime.
- The
- If the
isStrongBuyConditionMetfilter fails forBTC-USDT(meaning no pair passed the filters):- The
resetVariableblock executes, settingstrongBuyActivetofalse.
- The
This keeps strongBuyActive aligned with the latest check.
Dynamic Values in resetVariable
Like setVariable, values in resetVariable can be dynamic JavaScript expressions if the string value begins with a leading space.
"resetVariable": {
"consecutiveFails": " (this.variables.consecutiveFails || 0) + 1 ",
"lastFailReason": " 'Signal not strong enough at ' + new Date().toLocaleTimeString() "
}
" (this.variables.consecutiveFails || 0) + 1 ": Increments a counter specific to filter failures." 'Signal not strong enough at ' + new Date().toLocaleTimeString() ": Sets a descriptive string with a timestamp.
Use Cases for resetVariable
- Toggling flags: Set
trueon pass andfalseon fail. - Default states: Revert to a known default when conditions are not met.
- Clearing temporary data: Reset transient values when the opportunity disappears.
- Failure counters: Increment counters when a job fails to find qualifying pairs.
- Single-job state management: Keep "on" and "off" logic together.
Important Considerations
- Trigger condition:
resetVariableruns when the job's main filters do not pass. If a job has no filters,setVariablewill always run andresetVariablemay not. - No pairs vs. filter failure: For pair-processing jobs, the trigger is "no pairs pass filters." If
pairs.includeyields an empty list, the behavior may differ by version. - Order of operations:
setVariableandresetVariableare mutually exclusive per job run. - Clarity: If the set/reset logic grows complex, two separate jobs with inverted filters can be easier to maintain.
resetVariable is a clean way to manage "off" or default global state based on whether a job's filters pass.