Hi,
I have been learning the PRT-language for coding a proven system that i currently trade manually on daily bars. I have done a Montecarlo and it should work on other timeframes hence the need for automated trading . I use an ATR-trailing stop and when price during the day touches the ATR-trail it gets out of the position. The problem i have is that ProOrder always exits on the next candle, which is a big problem since it can lead to bigger losses. I know there is no way around this when using the EXIT command, but i think there might be a solution with some sort of adaptive stop (or trailing stop) that changes as the trade progresses, I just haven’t been able to work around it. Please have a look at the attached graph for better understanding.
Any help will be greatly appreciated. Thank you.
This is a simplified sample code for reference.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions to enter long positions
indicator1 = ExponentialAverage[8](close)
indicator2 = ExponentialAverage[50](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 AND not daysForbiddenEntry THEN
BUY 5 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = CALL "2ATR trailing stop"
c2 = (low < indicator3)
StopLoss=Close[1]-indicator3[1]
IF c2 THEN
SET STOP TRAILING StopLoss
ENDIF
Use a SELL STOP at the chosen price.
SELL at <your chosen price> STOP
Hi Vonasi:
It worked! and so simple… Thanks a lot.
Cheers,