Just need some help – I would like to add in a hard stop loss in addition to these trailing stop codes.
For example, when i have a long position, i want the stop to be 5 pips below the previous candle and for short positions, 5 pips above the previous candle, can i code it something like this and put it in addition to your codes?
1
2
3
4
5
6
7
8
9
stoploss=close-(Low[1]-5*pointsize)
set stoplossstoploss
iflongonmarketthen
set stoplossstoploss
endif
stoploss1=close-(High[1]-5*pointsize)
set stoplossstoploss1
I’m new to PRT – any help would be greatly appreciated.
Do NOT append your questions to unrelated exixting topic. Create a new one, instead.
Thank you 🙂
Your code looks is almost correct, just use ABS() to make sure you get positive values and remove SET STOP LOSS outside IF…ENDIF to make sure you don’t overwrite the previous one when OnMarket:
1
2
3
4
5
6
7
8
9
stoploss=abs(close-Low[1])-5*pointsize
iflongonmarketthen
set stoplossstoploss
endif
stoploss1=abs(close-High[1])+5*pointsize
ifshortonmarketthen
set stoplossstoploss1
endif
You can append Nicolss’code to your code, for sure.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue