Hello, Happy new year!
Wondering if anyone can help me out , trying out this stratergy but it keeps getting stopped.
Tried to alter the stoploss but it doesnt help.
Any ideas ?
// Definition of code parameters
DEFPARAM CumulateOrders = True // Cumulating positions activated for HFT
// Initialize variables
entryPrice = 0
takeProfit = 0
maxDrawdown = 0
BBup = BollingerUp[20](close)
BBDn = BollingerDown[20](close)
EMA10 = ExponentialAverage[10](close)
EMA20 = ExponentialAverage[20](close)
EMA50 = ExponentialAverage[50](close)
EMA200 = ExponentialAverage[200](close)
// Check for trend
trend = EMA10 - EMA50
trend2 = EMA20 - EMA200
// Conditions to enter long positions
if (close > EMA20 and trend > 0 and trend2 > 0) or (close > BBup and RSI[14](close) < 60)THEN
// Set entry price, stop loss, and take profit
entryPrice = close
takeProfit = entryPrice * (1 + 0.03) // 3% take profit
BUY 0.5 CONTRACT AT MARKET
ENDIF
// Conditions to enter short positions
if (close < EMA20 and trend < 0 and trend2 < 0) or (close < BBDn and RSI[14](close) > 40)THEN
// Set entry price, stop loss, and take profit
entryPrice = close
takeProfit = entryPrice * (1 - 0.03) // 3% take profit
SELLSHORT 0.5 CONTRACT AT MARKET
ENDIF
// Stops and targets
SET STOP pTRAILING (5 + 1.2)
SET target profit takeProfit
BUY 0.5 CONTRACT AT MARKET SELLSHORT 0.5 CONTRACT AT MARKET
What Instrument? Is 0.5 allowed? What error message do you see when you click on the yellow disc after System has been stopped?
Change to 1.0 and see if makes any difference?
SET STOP pTRAILING (5 + 1.2)
Read the Topic on the link below to see why pTailing won’t work
S&P500 Backtest shows different numbers than the Report
What Instrument? Is 0.5 allowed? What error message do you see when you click on the yellow disc after System has been stopped?
Change to 1.0 and see if makes any difference?
Hi GraHal thanks for the reply.
Its on the Dax40 and yes i can use 0.5.
Ok will check later
Hi, topic moved from probuilder to proorder forum for housekeeping. Please use probuilder forum for custom coded indicators, and proorder forum for strategies and backtests, thanks. Best Wishes for the new year.
You where right. I deleted “SET target profit takeProfit” and only use SET STOP pTRAILING (5 + 1.2)
Seems like the Stop and Target profit was conflicting one another. At the moment it didnt not stop
Thanks for your help for now
The main issue is not using SET target profit or not, it’s changing the variable takeProfit almost each bar. That’s because, even if you have limited your code to ONE open trade, conditions are still evaluated and, when met, takeProfit is changed (be it the same or the opposite direction).
Add AND Not OnMarket to your conditions in both lines 19 and 26, to prevent the execution of lines 21-22 and 28-29 when a position is open.