LeonParticipant
Junior
Hey guys,
I was coding a Range Break Out which you scan find at attachments (insert PRT code funktion was not warking properly for me).
Im wondering why it takes actions to late, exaplme also at attachments.
Entry should have been around 10.550, but it entered later – around 10.534 points at 09:05 o clock. This happened some more times – I just took this one for example. Is it maybe the time limitation in the code?
Does anybody got suggestions why this is happening? Is it a codingproblem in my Range Break Out?
BR
Leon
Without reviewing your code, I would say that it’s due to the fact that ProBacktest only read and execute code one time per bar. Please post your code and you’ll get a definitive answer to this problem 🙂
LeonParticipant
Junior
Hello Nicolas,
oh i thought it is in the attachments. Seems like its not. The code is running on demo, the uploaded trade is done with a demo account “live” to test its reliablility till 10.3 is implemented for Ig and i con do it with a reliable backtest 😉
Here is the code:
ONCE daycount = Days - 1
trailingv = 20
sharestotrade = 1
IF CurrentHour=8 THEN
IF daycount < Days THEN
higvalue = High
lowvalue = Low
totrade = 1
daycount = Days
ENDIF
IF High>higvalue THEN
higvalue = High
ENDIF
IF Low<lowvalue THEN
lowvalue = Low
ENDIF
ELSIF NOT ONMARKET AND CurrentTime<=153000 AND totrade THEN
IF close>=higvalue THEN
BUY sharestotrade SHARE AT MARKET
totrade=0
SET STOP pTRAILING trailingv
ELSIF close<=lowvalue THEN
SELLSHORT sharestotrade SHARE AT MARKET
totrade=0
SET STOP pTRAILING trailingv
ENDIF
ELSIF CurrentTime>=175500 AND longonmarket THEN
SELL AT MARKET
ELSIF CurrentTime>=175500 AND shortonmarket THEN
EXITSHORT AT MARKET
ENDIF
Please use the good button to insert code next time, you don’t have an idea of how much posts I edit everyday.. Feel like a robot sometimes! 🙂
At lines 19 and 23 you are testing if the current close is above or below your trigger prices, but sometimes it’s too late, because the code is read at the close of the candle and price had already often gone away from them.
To avoid this, you should place STOP pending orders at levels you want your trade to be triggered. You’ll find a lot of examples on forums and in the Library I guess.
LeonParticipant
Junior
Hello Nicolas,
thanks for the advice – i will try that!
LeonParticipant
Junior
Hello Nicolas,
as you told me i tried to find a work arround to get the right entrie but after a lot of code test i cant get rid of the problem that the code i entering to late.
Can you give me some advice which code is working or which post is dealing with this? I looked trough the forum but wasn’t able to identify something that seemd like a solution.
Thanks in advance!
BR
Leon