Command CROSSES OVER bug, normal behavior or wrong coding?
Forums › ProRealTime English forum › ProOrder support › Command CROSSES OVER bug, normal behavior or wrong coding?
- This topic has 9 replies, 4 voices, and was last updated 7 years ago by Nikita.
-
-
02/01/2017 at 8:17 PM #23473
Dear all,
I’ve set a condition like this:
c1 = xClose CROSSES OVER indicator1
where XClose is the closure of an Heking Ashi and indicator1 it’s a Moving Average.
I’ve noticed it openes position even if HA opens above MA then HA-low crosses under the MA and finally the HA-Close come back and closes over MA.
So it looks like the CROSSES OVER command is true in these two cases:
- Open is below MA and close is above MA.
- Open and close are both above MA but low crosses under MA.
Do you think it’s normal behavior, a bug or a mistake in coding of the condition?
Thank you all!
02/01/2017 at 10:46 PM #2349802/02/2017 at 1:56 PM #23591Dear Derek,
thanks for you answer, could you please help me to find that options you said?
I had a look in charts option and time zone and trading hours but I couldn’t find it.
I would like to add that I compared that chart with investing.com one.
It’s a candle at 10.15 of 01/02/2017 and it looks like on both charts (prorealtime and investing.com) as a Doji, but in prorealtime the low crosses under the MA instead it does not crosses under the MA in investing.com chart.
Thank you again
02/02/2017 at 2:24 PM #23612Looks like normal behaviour to me, as long as the xclose of previous candle was below your indicator1, and the xclose at completion of current candle is above your indicator1, the “xclose crosses over indicator1” statement is true, regardless of what the low did.
Yes it can be untrue while current candle is not complete yet and xclose has gone below indicator1 again, but as far as logic at completion of candle is concerned, xclose went above at end of candle, so it did cross over, doesn’t matter where the low is, no problem there.
Only if you had coded “low crosses over indicator1” would the cross over remain untrue at end of candle.
PS: I think Derek’s problem was rather due to different results between probuilder and probacktest/proorder because of taking into account cfd weekend data (apologies if I mistakenly mix it up with another topic). Doesn’t seem to be related here considering you don’t mention comparative results of probuilder and proorder.
02/02/2017 at 4:32 PM #2363402/02/2017 at 4:44 PM #2363602/02/2017 at 4:49 PM #23639Ok, you didn’t mention in first post that xClose was already above MA in previous candle (opening above at current candle is not necessarily equal to having closed above at previous candle because of possible gap between two candles). In that case, it’s likely there’s a bug somewhere in the code that might affect the value of either xClose or indicator1 and/or c1.
If this is a backtest the best way to debug is to use the GRAPH function (works from PRT v10.2 but not older versions I think) by adding those lines at end of backtest:
GRAPH c1 as “c1”
GRAPH xClose as “xClose”
GRAPH indicator1 as “indicator1 ”
and verify they behave as expected.
If not, the instances when they don’t behave as expected would provide clues to search for the bug(s)
02/02/2017 at 4:50 PM #2364002/02/2017 at 5:23 PM #2364302/02/2017 at 7:26 PM #23674Thank you all for the answers!
@Noobywan: you are right I didn’t specify it because I thought CROSSES OVER meant that the current candle open below the MA and close above it. I did know I should consider the previous xclose to be below MA and current xclose to be above MA. Thank you a lot to clarify.I think to have that condition I have to use something like this:
1c1 = xOpen < indicator1 and xClose > indicator1About that position I mentioned you were right I think, I had a better look to the charts and the bar before the doji was a bearish HA and close was few decimal of pips below the MA which were rounded like this:
MA: 1,0792
Xclose: 1,0791
Instead investing.com reports them as both at 1.0792 and a loss postion would have not been opened.
@Nicolas, here is the HA, I will post them to be sure:12345678910xClose = (open+high+low+close)/4IF BarIndex=0 THENxOpen = openxHigh = highxLow = lowELSExOpen = (xOpen[1] + xClose[1])/2xHigh = Max(Max(high, xOpen), xClose)xLow = Min(Min(low, xOpen), xClose)ENDIFand this too (even if I’m using the first and the results do not changes):
1234567891011IF BarIndex = 0 THENXClose = TotalPriceXOpen = (Open + Close) / 2xHigh = highxLow = lowELSEXClose = TotalPriceXOpen = (XOpen[1] + Xclose[1]) / 2xHigh = Max(Max(high, xOpen), xClose)xLow = Min(Min(low, xOpen), xClose)ENDIFThank you all again for your support and sorry for the bad reading value, anyway I’ve learned how the CROSSES OVER and UNDER behave.
Now I will have to study a way to avoid this situation.
Thank you!:)
-
AuthorPosts