Counting of Bars Incorrect Results
Forums › ProRealTime English forum › ProOrder support › Counting of Bars Incorrect Results
- This topic has 15 replies, 4 voices, and was last updated 6 years ago by JC_Bywan.
-
-
05/18/2018 at 1:59 PM #70774
I wrote a very simple strategy to test some ideas but I noticed that it was not opening every position that it should. It should simply open a position if there has been four red candles after a green candle and then closes the position after holding for one bar. I used a FOR DO NEXT loop to count but when compared to my Same Candle Run Graph indicator that is in the library which uses multiples of close < open it can clearly be seen that trading opportunities are being missed.
Can anyone explain why this should be?
Tested on FTSE100 Weekly.
123456789101112131415161718192021222324252627DEFPARAM cumulateOrders = FalseQtyBars = 4PositionSize = 1Count = 0IF close[QtyBars] > open[QtyBars] THENFor i = 0 to (QtyBars-1) doIF close[i] < open[i] THENCount = Count + 1ELSEBreakENDIFNEXTENDIFIF Count = QtyBars THENBUY PositionSize contract at MarketENDIFIF Onmarket THENSell at MarketENDIFGraph Count05/18/2018 at 2:06 PM #7077812345If close > open thenIf summation[4](close[1] < open[1]) = 4 thenBuy....EndifEndif05/18/2018 at 2:18 PM #70780So I re-wrote the code to do away with the FOR DO NEXT loop and the results are exactly the same. Trades are missed.
12345678910111213DEFPARAM cumulateOrders = FalseQtyBars = 4PositionSize = 1IF close[QtyBars] > open[QtyBars] and close < open and close[1] < open[1] and close[2] < open[2] and close[3] < open[3] THENBUY PositionSize contract at MarketENDIFIF Onmarket THENSell at MarketENDIFStrangely similar code in my indicator but displaced by one bar so as to run it as an analyse tool works fine.
123456IF close > Open + Spread and close[1] < open[1] and close[2] < open[2] and close[3] < open[3] and close[4] < open[4] and close[5] > open[5] THENDown4Total = Down4Total + (close - open) - SpreadENDIFIF close < open and close[1] < open[1] and close[2] < open[2] and close[3] < open[3] and close[4] < open[4] and close[5] > open[5] THENDown4Total = Down4Total + (close - open) - SpreadENDIF05/18/2018 at 2:23 PM #70781I think you have it wrong Robertogozzi. The green bar should be before the four red bars.
I’ll try this: (but I do not understand why the other two methods do not work as a strategy when they do as an indicator)
12345If close[4] > open[4] thenIf summation[4](close < open) = 4 thenBuy....EndifEndif05/18/2018 at 2:26 PM #7078205/18/2018 at 2:38 PM #70783Here is another example: This one was looking for five reds after a green but it opens a position when the last of the five is in fact a green.
The code used was this:
123456789101112131415DEFPARAM cumulateOrders = FalseQtyBars = 5PositionSize = 1IF close[QtyBars] > open[QtyBars] THENIF summation[QtyBars](close < open) = QtyBars THENBUY PositionSize contract at MarketENDIFENDIFIF Onmarket THENSell at MarketENDIF05/18/2018 at 3:38 PM #70787I tried it on Gbp/Nok, 1 minute, and it works fine!
05/18/2018 at 3:49 PM #7079005/18/2018 at 4:13 PM #70793Weekly timeframe? Try in other ones to see how it goes..
Yes but why does it not work in weekly? Is there something about the weekly closing data that is incorrect? If so it will make the new multi time frame feature pretty useless.
The data is correct if you wait a week before making the decision that you should have bought at the beginning of the week as my indicator proves!
I will check other time frames and report back…..
05/18/2018 at 4:47 PM #70798I just checked on daily data and all seems to be working correctly across a range of different same bar runs but then I tried it on a 6 (x) Days chart and something is very wrong there. There are trades opened that should not be opened. They are winners but that is not the point! The strategy was set to open a trade if a green bar is followed by four red bars. The graph at the bottom is my Candle Run indicator.
05/18/2018 at 5:05 PM #70802Only briefly interrupting my silence in case this might help: could it be the good old custom choice of “not displaying weekend data” in the platform local options? … resulting in probuilder indicators working as you expect with friday close being also weekly close, but backtests & pro-order strategies running on prt servers with weekend data regardless of your pc-localised-only custom choice (not run on your pc displaying therefore only a subset of data excluding weekend and sunday close, yet used)? Might be consistent with weekly and x days timeframes behaving differently depending if running a strategy or an indicator.
05/18/2018 at 5:49 PM #7080305/18/2018 at 10:03 PM #70810Something is definitely not as it should be. Here is an image from a strategy based on bars that represent 25 days on the DAX and strategy that does not use tick by tick data. PRT only opens and closes positions at the open of the new bar so how is this possible?
Maybe this needs moving to the PRT platform support for PRT to comment on?
05/21/2018 at 8:31 AM #7098805/23/2018 at 8:14 AM #71140 -
AuthorPosts
Find exclusive trading pro-tools on