IRPParticipant
New
In automated trading, is it possible to instruct the PRT system not to enter a trade after a certain time has elapsed counting from the time the last trade was closed?
Also, is there any link to help in setting up a trailing stop?
Many thanks,
I. Petrie
You can search the forum for TRAILING STOP and you’ll be returned many links to code and posts. Nicolas’code is at https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/ (lines 17-56 are ready to be added to your code as is).
This code will allow you to stop trading for MaxBars bars (not tested):
ONCE TradeON = 1
ONCE Count = 0
ONCE MaxBars = 20 //Number of bars to wait before trading again
IF Count > 0 THEN
Count = Count + 1
IF Count >= MaxBars THEN
Count = 0
TradeON = 1
ENDIF
ENDIF
IF StrategyProfit <> StrategyProfit[1] THEN
Count = 1
TradeON = 0
ENDIF
IF LongConditions AND TradeON THEN
BUY 1 Contract AT Market
ENDIF
TradeON must be added to your conditions to enter a trade.