Hi All,
Im hoping someone can help a new starter in this field. Ive created a (very) basic auto trade system but it wont allow me to have both a Stop Loss and Trailing stop. Looking at other forum posts for a few hours I can see this is a common issue. Ive found some scripts created by other then enable this feature but dont understand how I can incorporate this into my own script?
Appreciate this is a very cheeky ask, but would someone please amend my code so I have both a stop loss (20 points/pips) and a Trailing stop (5 points/pips) that I can run. Thanks in advance
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = BollingerDown[17](close)
c1 = (close CROSSES OVER indicator1)
IF c1 THEN
BUY 1 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator2 = BollingerUp[17](close)
c2 = (close CROSSES UNDER indicator2)
IF c2 THEN
SELL AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 20 pTRAILING 5
JSParticipant
Senior
Hi Bob,
Try this…
TimeFrame: 15 minuten
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = BollingerDown[17](close)
c1 = (close CROSSES OVER indicator1)
IF c1 THEN
BUY 1 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator2 = BollingerUp[17](close)
c2 = (close CROSSES UNDER indicator2)
IF c2 THEN
SELL AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 30
SET STOP PTRAILING 85
BTW,
your trail stop must be larger than your stop loss, otherwise only the trail stop works, so your position to be closed always ends up at your trail stop.
Ah, thank you both for the replies, think this is making more sense now.
Thanks again!
Hi JS,
Does a trailingstop and a stoploss work together in your systems? Beacause I have found out, that it isn’t the case, see my post in the Pro order support.
Thnx!
JSParticipant
Senior
Hi,
I don’t use them together in my systems, I just use a “(custom) trailing stop” in IB…
(I would make the “StopLoss” part of the TS myself…)