Help with my stratery , keeps getting stopped
Forums › ProRealTime English forum › ProOrder support › Help with my stratery , keeps getting stopped
- This topic has 6 replies, 4 voices, and was last updated 2 years ago by
robertogozzi.
-
-
01/02/2023 at 2:07 PM #206661
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 ?
1234567891011121314151617181920212223242526272829303132333435// Definition of code parametersDEFPARAM CumulateOrders = True // Cumulating positions activated for HFT// Initialize variablesentryPrice = 0takeProfit = 0maxDrawdown = 0BBup = 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 trendtrend = EMA10 - EMA50trend2 = EMA20 - EMA200// Conditions to enter long positionsif (close > EMA20 and trend > 0 and trend2 > 0) or (close > BBup and RSI[14](close) < 60)THEN// Set entry price, stop loss, and take profitentryPrice = closetakeProfit = entryPrice * (1 + 0.03) // 3% take profitBUY 0.5 CONTRACT AT MARKETENDIF// Conditions to enter short positionsif (close < EMA20 and trend < 0 and trend2 < 0) or (close < BBDn and RSI[14](close) > 40)THEN// Set entry price, stop loss, and take profitentryPrice = closetakeProfit = entryPrice * (1 - 0.03) // 3% take profitSELLSHORT 0.5 CONTRACT AT MARKETENDIF// Stops and targetsSET STOP pTRAILING (5 + 1.2)SET target profit takeProfit01/02/2023 at 2:21 PM #206663BUY 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?
01/02/2023 at 2:48 PM #206667SET STOP pTRAILING (5 + 1.2)
Read the Topic on the link below to see why pTailing won’t work
https://www.prorealcode.com/topic/sp500-backtest-shows-different-numbers-than-the-report/
01/02/2023 at 4:39 PM #206680What 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
01/02/2023 at 6:52 PM #206688Hi, 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.
1 user thanked author for this post.
01/02/2023 at 8:08 PM #20669501/03/2023 at 10:39 AM #206715The 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.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on