I am trying to solve a coding problem it seems easy but I get it wrong in the backtest.
I want to take as reference everyday’s price at 090000h. Let’s call it levelZERO. I would write:
So, that day, if I want to refer to the price at 09:00h I would mention levelZERO in the code. It seems that it has to be reset everyday, seems the lecture I got in the backtest does not make any sense. Everyday levelZERO should be different, but it seems that it refers to a price from a different day.
I have tried:
It does not show a lot of imagination but it is simple.
I believe it still doesn’t work, since I don’t get the lecture I want in the backtest.
I would appreciate if anyone can confirm with me if the above is right, or any other (and more simple way) to “lock” the price at 09:00 everyday.
Your first code example should work. Anytime you think your code is wrong or something dis-functioning, try to debug it with GRAPH or build a simple indicator from it and apply it on your chart.
090000 is a time that must be read by the code, if you launch the code on daily basis, then it is possible that it will not be updated, since the code is read one time at Close and at that moment, time could not be 09h00m00s.
Thanks. That is what I did. I built a simple indicator representing levelZRO and it works. I am discovering GRAPH applications to debug/confirm and to graphically see the results of same lines of codes.
Warning: Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced clients who have sufficient financial means to bear such risk. The articles, codes and content on this website only contain general information. They are not personal or investment advice nor a solicitation to buy or sell any financial instrument. Each investor must make their own judgement about the appropriateness of trading a financial instrument to their own financial, fiscal and legal situation.