Help: Autotrade making incorrect trades?
Forums › ProRealTime English forum › ProOrder support › Help: Autotrade making incorrect trades?
- This topic has 5 replies, 3 voices, and was last updated 3 years ago by
GraHal.
-
-
04/21/2022 at 3:57 PM #192026
I made a pretty basic auto trading algo that trades off both 200DEMA and supertrend. It looks something like this
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from creating new orders to enter the market or increase position size before the specified timenoEntryBeforeTime = 100000timeEnterBefore = time >= noEntryBeforeTime// Prevents the system from placing new orders to enter the market or increase position size after the specified timenoEntryAfterTime = 163000timeEnterAfter = time < noEntryAfterTime// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// Conditions to enter long positionsindicator1 = DEMA[200](close)c1 = (close > indicator1)indicator2 = SuperTrend[3,12]c2 = (close > indicator2)IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENBUY 250 CONTRACT AT MARKETENDIF// Conditions to exit long positionsindicator3 = SuperTrend[3,12]c3 = (indicator3 >= close)IF c3 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator4 = DEMA[200](close)c4 = (close <= indicator4)indicator5 = SuperTrend[3,12]c5 = (close <= indicator5)IF (c4 AND c5) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THENSELLSHORT 250 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator6 = SuperTrend[3,12]c6 = (close >= indicator6)IF c6 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP %LOSS 2SET TARGET %PROFIT 6It ran well in backtesting so I thought i’d enter a position with it today and test it out. Unfortunately it doesn’t follow my code???
As you can see from the picture I uploaded, it entered a short position at 215, which doesn’t make sense as the price wasn’t under the 200DEMA line which I specified it should. Why is this? I am really confused
04/21/2022 at 5:45 PM #19203004/21/2022 at 5:55 PM #192032From the attached pic I can’t see the time and date of entry, and the values of the price and indicators, so I can’t replicate exactly.
Moreover “It looks something like this“, isn’t accurate. To compare results the code must be absolutely IDENTICAL to the one you used.
My backtests are all good, though.
I suggest that you add these lines to your code, maybe this will help detect something wrong (though they only work in backtests):
12graph (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry AS "Long"graph (c4 AND c5) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry AS "Short"04/21/2022 at 6:35 PM #192035Hey, thanks for the reply.
The trade happened at 10:45am US time, which would be 3:45pm UK Time. For some reason my DEMA line is glitched? Its completely different to yours.
From this image here, it shows my DEMA line only crossed above price at 11:45am US time, which is 4:45pm UK time. This is consistent with my graph on tradingview. How come yours is different?
04/21/2022 at 6:39 PM #19203604/21/2022 at 7:16 PM #192040For some reason my DEMA line is glitched? Its completely different to yours.
Try it on Spreadbet as you are showing NVIDIA on CFD?
It shouldn’t make any difference, except the figures shown for Price (multiplied by 100 on SB)
-
AuthorPosts
Find exclusive trading pro-tools on