Hi guys,
I’ve found a very interesting “bug”. For some reason it seems that PRT sometimes ignores a very important condition and goes for it anyway. In my code I have this:
IF NOT LongOnMarket AND LongCondition AND belowred = 1 THEN
Notice the “belowred = 1”. That’s my on/off trigger for buy, if it’s 0 then no go. Once i’m in the market it goes to zero and waits for a specific condition to switch back on. That works like a charm.
However, PRT ignores it and takes a trade I don’t want! Look at the attached image. That IF statement is the only place in the code where a buy order is issued… Anyone else have this kind of hick-ups? Errors like this is very costly and if this is a true PRT error it is very serious.
Hello, the other trades I see on your chart were also launched on a 0 condition. It’s difficult to help you more with no code at all 😀
Arn’t those just a result of lag? Here is the full code (a bit messy though):
//Conditions för long re-entry
ONCE belowred = 1
IF belowred = 0 AND low< MAH10 AND NOT LongOnMarket THEN
belowred = 1
ENDIF
// Conditions to enter long positions
MAL8 = Average[8](low)
MAH10 = Average[10](high)
William = WilliamsAccumDistr(close)
WilliamMA = Average[57](William)
LongCondition = low[1] > MAH10 AND open > MAH10 AND MAH10>MAL8 AND William>WilliamMA
IF NOT LongOnMarket AND LongCondition AND belowred = 1 THEN
BUY 100 CONTRACTS AT MARKET
profittake = high+((high-low)*2)
belowred = 0
ENDIF
graph belowred
// Conditions to exit long positions
If LongOnMarket AND open>profittake THEN
SELL AT MARKET
ENDIF
//SL om hamnar under blå (MAL8)
If LongOnMarket AND close<MAL8 THEN
SELL AT MARKET
ENDIF
Can you tell me what instrument and timeframe please?
Please test again with this instruction in the first line :
defparam preloadbars = 0
Im running daily on any stock. Preloadbars didn’t work, see attached result.
For me everything is working well. Your GRAPH instruction draw your “belowred” variable that is reset to 0 each time you take a trade on line 21. That’s why you may think that PRT take the trade in “inverted” mode despite of this variable value.
Hi Nicolas,
Yeah I got it now, belowred goes on, trade is made and it goes off all in the same bar – thus it is “invisible” at that entry. Great, many thanks for your help!
Hi,
I’m still having a bit of trouble figuring this one out (this time it’s a reverse problem). Obvious entry is missed completely or severely delayed. Kindly look at the attached image, there should be an entry at X:
LongCondition = low[1] > MAH10 AND open > MAH10 AND MAH10>MAL8 AND William>WilliamMA
- Bar before above red line? Check.
- Open above red line? Check.
- Red line above blue line? Check.
- William above Williams MA? Check.
- belowred = 1? Check.
Yet no entry at all…
Now let’s have a look at Y:
Same conditions as above, all check. Yet the entry is at 5th bar!
Is it possible that “AT MARKET” sometimes fail or is greatly delayed? Or am I missing something here?