Topic: How to Force "Do Not Exit" Strategy in Express Generator
After months of effort, I've finally found a solution to a common problem many users face with the Express Generator. While we can't directly create strategies that only exit with TP and Stop Loss, we can modify how these strategies are saved. Here's a step-by-step guide to achieve this:
Open the file bin/lib/collection.js.
Locate the serializeCollection function. This function is responsible for converting strategies to the format saved in the JSON file.
Inside this function, find the part where strategies are mapped. It should look similar to:
return collectionRecords.map((rec) => {
// ... other code ...
strategy: {
properties: {
// ... properties ...
},
openFilters: rec.strategy.entryParams.map(mapIndParam),
closeFilters: rec.strategy.exitParams.map(mapIndParam),
timeUpdated: rec.strategy.timeUpdated,
},
// ... other code ...
});
Modify the closeFilters part to always use the "Do not Exit" indicator. Replace the line:
closeFilters: rec.strategy.exitParams.map(mapIndParam),
subscrube foir
closeFilters: [{
name: 'Do not Exit',
listIndexes: [0],
numValues: []
}],
5. Save the file after making these changes.
These modifications will ensure that all strategies are saved with the "Do not Exit" indicator as the only exit indicator, regardless of how they were originally generated.
Note: This change only affects how strategies are saved, not how they're generated or tested. For the generator to use only "Do not Exit" during generation and testing, additional changes to other files would be necessary, which only Popov can implement.
After making these changes, all your strategies will be generated with no exit. You should then perform a single test again using the Express Generator as a validator, or even optimize it, because by default, the "Do not Exit" will always be included, and it won't close positions prematurely before reaching TP or Stop Loss.
Another observation: in your .ini configuration file, it's necessary to set only one slot for closing operations as the default.
I sincerely hope this tutorial has made you as happy as it has made me. While it's not the ideal solution we'd prefer, consider this: if you generated 1 million strategies using Express and they were saved with these modifications, after performing a single test, you'd be left with 700,000 strategies. That's only a 30% reduction, which is truly remarkable as it doesn't make such a significant difference.
Trade safely, everyone!