This ProBuilder script is designed to pause trading for one hour if a significant loss occurs. It’s a useful example for understanding conditional trading halts based on profit thresholds in automated trading systems.
DEFPARAM CumulateOrders = False // timeframe(1 hour, updateonclose)
ONCE MyProfit = 0
pause = 0
IF Not OnMarket THEN
MyProfit = StrategyProfit
SumSP = StrategyProfit - MyProfit[1]
pause = (SumSP <= -500)
ENDIF
// timeframe(default)
IF close CROSSES OVER average[200] AND Not OnMarket AND Not Pause THEN
BUY AT MARKET
ENDIF
SET TARGET pPROFIT 50
SET STOP pLOSS 20
graph pause
graph SumSP
Explanation of the Code:
CumulateOrders to False, ensuring that orders do not stack up and are treated individually. The variables MyProfit and pause are initialized to zero.IF Not OnMarket condition checks if there are no open positions. If true, it updates MyProfit to the current strategy profit and calculates the difference from the previous profit (SumSP). If this difference is less than or equal to -500, it sets pause to true (1).pause status and the SumSP value to visually track when trading is paused and the profit/loss changes.This snippet is a practical example of how to manage risk by pausing trading following a significant loss, which can be crucial in automated trading to prevent further losses.