Iím trying to find a way to have at least a certain number of bars between each entry. For example, I want there be at least six bars between each entry. After another new entry, the strategy must wait at least six bars before it is allowed to add to the position again.
Iím unable to use BarsSinceEntry(0) since it refers to the first entry of the current open position. I tried to create my own function BarsSinceLastEntry to retrieve the information I need.
However, my current code isnít working properly. When I insert it the strategy will stop adding to existing positions. Below is my own code for my own function BarsSinceLastEntry. I plotted it as an indicator and the functions appears to be working as intented. Iím not sure where I went wrong. Any ideas or suggestions would be greatly appreciated.
You might want to take a look into the reserved words PosTradeExitBar and PosTradeEntryBar. They make it possible to receive the specific entry and exit bar even with multi-leg positions.
Another approach would be to monitor a change in your market position or number of trades and save the bar number at this moment. Then you can block new trade entries as long as the new bar number < saved bar number + X.
What is "the same issue"? QuantArb talks about two things that aren't necessarily related: 'bar delay between entries and 'code stops adding to new positions'. Please be more specific if you want help.
The following user says Thank You to Jura for this post: