Coding cross over problem
Forums › ProRealTime English forum › ProOrder support › Coding cross over problem
- This topic has 7 replies, 4 voices, and was last updated 6 years ago by didi059.
Tagged: Cross over, detrended price oscillator, dpo
-
-
09/22/2018 at 10:06 PM #81081
What is wrong in this code ?
I have an indicator that crosses an average of the indicator as a buy/sell signal , in this case going short.
The closing of this position is done by the reverse cross. (see picture test)
However the execution in backtest shows that the position is covered randomness without taking in account the “closing condition” ; worse it opens a new short without satisfying the “condition”…
Where is the problem in this code?
Any suggestion is welcome.
123456789101112131415161718192021222324252627// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Prevents the system from placing new orders on specified days of the weekdaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0// Conditions to enter long positionsindicator1 = DPO[8](close)indicator2 = Average[5](DPO[8](close))c1 = (indicator1 CROSSES OVER indicator2)//IF c1 AND not daysForbiddenEntry THEN//BUY 1 SHARES AT MARKET//ENDIF// Conditions to enter short positionsindicator3 = DPO[8](close)indicator4 = Average[5](DPO[8](close))c2 = (indicator3[1] CROSSES UNDER indicator4[1])//c3 = (indicator3[1] CROSSES OVER indicator4[1])IF c2 AND not daysForbiddenEntry THENSELLSHORT 1 SHARES AT MARKETENDIFIF c1 THENEXITSHORT AT MARKETENDIF09/23/2018 at 11:00 PM #81139Were the settings the same in the strategy and on the chart?
Which instruments?
Which TF?
Which date/time is the trade under investigation?
09/24/2018 at 9:36 AM #81163and keep in mind that DPO is not suitable for automatic trading, as the internal instruction make use of future datas, which is obviously not possible in real time.
1 user thanked author for this post.
09/24/2018 at 6:14 PM #81231Nicolas,
According to the definition the Detrended Price Oscillator (DPO) measures the difference between a past price and a moving average. The detrended price oscillator is calculated and utilized from the variables shown below:
X is first determined by the number of periods; 20 day or 30 day periods are common. Simple moving average over an “n” day period is needed.
DPO = Closing price – Simple moving average [from (n / 2 + 1) days ago]. It is possible to displace the Detrended Price Oscillator (DPO) with a horizontal shift to the right. (see picture of the setting Prorealtime in attachment.)
So I do not understand what you mean by : ” the internal instruction make use of future datas” . Can you clarify ? Thank you for your efforts.
Brgds
J-P
09/24/2018 at 6:18 PM #81233Robberto
The answers on your questions:
Were the settings the same in the strategy and on the chart? YES
Which instruments? DAX Futures
Which TF? Day
Which date/time is the trade under investigation? from 28 november 2015 till 20 september 2018
Thank you for your reply.
Brgds
J-P
09/24/2018 at 7:08 PM #81237So I do not understand what you mean by : ” the internal instruction make use of future datas” . Can you clarify ?
If you try to run a strategy live with DPO then you will get a message telling you that it is not an indicator that can be used for live trading. This is the same for all similar indicators that re-paint in the future such as the zig-zag They look great because they change in the future. For this reason it is not worth continuing to develop strategies based on these type of indicators.
1 user thanked author for this post.
09/25/2018 at 7:19 AM #81252You are right, but if you look carefully at the oscillator by reloading the chart, let’s say each 10 minutes, you’ll see different information, because that’s how the DPO is made in the platform. You have the choice to choose between the future and past datas in its settings.
There are plenty of topics in the forums which deal about the DPO and its repainting behavior. You can also have a look at this one where you’ll find the code for the DPO that use the past data: (but indeed not as accurate than the one which has the crystal ball!! 😆 ) https://www.prorealcode.com/topic/detrended-price-oscillator-dpo/#post-13747
1 user thanked author for this post.
09/25/2018 at 3:12 PM #81286 -
AuthorPosts
Find exclusive trading pro-tools on