Skip to main content

AutoConfig's 'setITB' option: Ignoring trades before a set time

ยท 6 min read

When managing trading pairs with Gunbot's AutoConfig, especially when adding new pairs or making significant changes to existing ones, you might want to prevent the trading strategy from immediately acting on historical chart data. The setITB option in AutoConfig jobs provides an automated way to set the IGNORE_TRADES_BEFORE (ITB) override for affected pairs to the current time, effectively telling the strategy to only consider market data from that point forward.

Use the AutoConfig wizard

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.

The IGNORE_TRADES_BEFORE (ITB) Strategy Parameterโ€‹

Before understanding setITB, it's important to know about the IGNORE_TRADES_BEFORE parameter in Gunbot strategies. When you set IGNORE_TRADES_BEFORE for a pair to a specific Unix timestamp (milliseconds since epoch), the trading strategy assigned to that pair will:

  • Ignore all historical candle data prior to this timestamp.
  • Calculate indicators (like MAs, RSI, MACD) based only on data from this timestamp forward.
  • Effectively start its analysis "fresh" from that point in time.

This is useful to prevent strategies from making decisions based on outdated market conditions, especially after a pair is newly added or its core logic has been changed.

The setITB AutoConfig Job Optionโ€‹

The setITB option in an AutoConfig job automates the process of setting this IGNORE_TRADES_BEFORE override. When an AutoConfig job includes setITB: true and its conditions are met for a pair:

  1. AutoConfig determines the current Unix timestamp (in milliseconds).
  2. It then adds or updates the IGNORE_TRADES_BEFORE key within the override object for that specific pair in your config.js file, setting its value to this current timestamp.

Configuration Example:

{
"newPairInitializer": {
"enabled": true,
"type": "addPairs", // Commonly used with addPairs
"schedule": "0 * * * *", // Hourly
"setITB": true, // User setting: Automatically set ITB for new pairs
"pairs": {
"exchange": "binance",
"include": "USDT-"
},
"filters": {
"minVolumeForNewPairs": {
"filterType": "minVolume24h",
"minVol": 1000000
}
},
"strategy": "stepgrid",
"overrides": { // Other initial overrides
"STOP_LIMIT": 0.5 // Example for a numeric override
}
},
"strategyChangeManager": {
"enabled": true,
"type": "changeStrategy", // Also useful when changing strategy
"schedule": "0 0 * * 1", // Weekly on Monday
"setITB": true, // User setting: Reset ITB when strategy changes
"pairs": { /* ... */ },
"filters": {
"isUsingOldStrategy": {
"filterType": "strategyName",
"currentStrategy": "oldStrategyVersion1"
}
},
"strategy": "newImprovedStrategy" // The new strategy to apply
}
}

In newPairInitializer:

  • When a new USDT pair on Binance passes the volume filter and is added by this job, because setITB: true is present, its override block in config.js will automatically include an IGNORE_TRADES_BEFORE key set to the timestamp of when the job ran and added the pair. For example: "override": { "STOP_LIMIT": 0.5, "IGNORE_TRADES_BEFORE": 1678890000000 }

In strategyChangeManager:

  • When this job changes a pair's strategy from "oldStrategyVersion1" to "newImprovedStrategy", setITB: true ensures that the IGNORE_TRADES_BEFORE for that pair is updated to the current time. This makes the "newImprovedStrategy" start its analysis fresh, without being influenced by indicator values calculated based on the old strategy's logic or prior market conditions irrelevant to the new strategy.

Benefits of Using setITB: trueโ€‹

  1. Fresh Start for New Pairs: When adding new pairs, setITB: true ensures the assigned strategy doesn't immediately react to potentially misleading historical data that existed long before the pair was deemed suitable by your filters.
  2. Clean Slate After Strategy Changes: If an AutoConfig job changes a pair's strategy (using type: "changeStrategy"), setting ITB ensures the new strategy begins its calculations and decision-making based only on market data from the point of the switch. This prevents indicators from the old strategy from influencing the new one.
  3. Resetting State After Significant Override Changes: If a manageOverrides job applies drastic changes to a pair's core parameters (e.g., significantly altering indicator periods, buy/sell levels), setITB: true can force the strategy to re-evaluate based on current data with the new parameters.
  4. Consistency: Automates a best-practice step that might otherwise be forgotten when manually adding pairs or changing strategies.

Important Considerationsโ€‹

  • Timestamp Value: AutoConfig sets IGNORE_TRADES_BEFORE to the current timestamp (in milliseconds) when the job executes and affects the pair.
  • Interaction with Other Overrides: setITB: true adds/updates one specific key (IGNORE_TRADES_BEFORE) in the override object. It works alongside any other overrides defined in the job's overrides section.
  • No Effect if setITB: false or Omitted: If setITB is false or not present in the job definition, AutoConfig will not automatically manage the IGNORE_TRADES_BEFORE parameter for pairs affected by that job. Any existing ITB value for the pair will remain unless explicitly changed by another override in the job.
  • Impact on Indicator Calculation: Remember that setting ITB causes all strategy indicators to recalculate using only data from the ITB timestamp forward. This means for a short period after ITB is set, indicators that require many periods (e.g., a 200-period moving average) might not have enough data to be meaningful or might behave differently until sufficient new candles have formed.

The setITB: true option is a valuable utility in AutoConfig for ensuring that your trading strategies operate with a clean slate of market data when significant configuration changes occur for a pair, whether it's a new addition or a modification to its core trading logic. This promotes more relevant and timely decision-making by your Gunbot strategies.