Hi, first timer here and just learning ProRealTime with minimal prior coding experience, so apologize for naive questions. I’m building a mean reversion system, but I have certain scenarios where after some backtesting I can see that statistically at certain stop levels the odds are heavily indicating that it’s got caught in a trend. I’d like to in a sense “pause” the normal system rules and do a stop and reverse intrabar with a trailing stop when it hits the stop level. If I’m trading manually that’s easy enough, but I can’t figure out how to code that.
I know there’s a lot of logic likely involved there so not asking anyone to code stuff for me, but any pointers on the simple commands required to do a stop and reverse order instead of just a stop that I have at the end? My code is below, any assistance appreciated. Thanks.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = Stochastic[10,3](close)
c1 = (indicator1 CROSSES UNDER 20)
indicator2 = CALL “#MACD_Direction”[20, 30, 7]
c2 = (indicator2 > 0)
IF c1 AND c2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = Stochastic[10,3](close)
c3 = (indicator3 > 50)
IF c3 THEN
SELL AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 25