This ProBuilder code snippet demonstrates how to implement a trading strategy that waits for a specific number of bars and a price movement condition before placing another trade after a loss. This approach can help in managing risk and avoiding immediate re-entry into the market under unfavorable conditions.
IF c1 AND NOT LongOnMarket THEN
BUY 2 PERPOINT AT MARKET
ENDIF
//let's add another order while price continue to move lower (more than 10 points) than the last order taken with a condition of 5 bars elapsed since then
IF BARINDEX-TRADEINDEX(1)>20 AND Close-TRADEPRICE(1)>20 AND LongOnMarket THEN
BUY 2 PERPOINT AT MARKET
ENDIF
The code snippet includes two main conditional statements that control when trades are placed:
IF statement checks if a certain condition c1 is true and ensures that there is no long position currently open in the market (NOT LongOnMarket). If both conditions are satisfied, a new trade is initiated by buying 2 points per point at the market price.IF statement adds complexity by introducing a time delay and a price movement condition for re-entry. It checks if:
BARINDEX-TRADEINDEX(1) > 20).Close-TRADEPRICE(1) > 20).LongOnMarket).If all these conditions are met, another trade is placed to buy 2 points per point at the market price.
This example is useful for understanding how to control trading actions with both time and price conditions, potentially increasing the strategy’s effectiveness by avoiding immediate re-entry into a losing position.
Check out this related content for more information:
https://www.prorealcode.com/topic/waiting-after-a-loss/#post-26739
Visit Link