Ask for help: How to get the opening and closing prices of a k-line

Author: The dead came, Created: 2017-01-21 17:08:57, Updated:

Calling for help

I would like to ask you a question. I'm a user who has just started learning how to write strategies, and I have some basic questions. There may be ready-made answers on the forum, but I haven't found them yet. If there are, I hope you can send a link, thank you very much.

The question is this: How can you get the price of the Open and Close tiles for the K-line that just finished and the K-line that preceded it?

Explain this: For example, if we take the 1 minute K line, and assume that it is now between 13:30:01 and 13:30:59, that is how we get the K line at 13:29:00-13:30:00; and the price of the Open and Close ticks at 13:28:00-13:29:00 for this K line.

When entering 13:31:00, the whole is pushed back by one minute, i.e. 13:30:00-13:31:00 and 13:29:00-13:30:00 for the two K-lines Open and Close.

I feel like I'm reaching out a little bit. But I really haven't figured out how to do it.

Thank you very much.


More

The Little Dream- ### The code What's up? Import time def main (: PerTime is 0. while True: LogStatus (("Now is the time:", _D(time.time))) records = exchange.GetRecords if ((not records or len ((records) < 3): Continue Other: If ((perTime!= records[-1]["Time"]): Log (((((((((((((((((((((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) Log (("degrees the first BAR Time:", _D ((records[-1]["Time"] / 1000), "open:", records[-1]["Open"], "close:", records[-1]["Close"])) Log (("degrees the second BAR Time:", _D ((records[-2]["Time"] / 1000), "open:", records[-2]["Open"], "close:", records[-2]["Close"]) PerTime = records[-1]["Time"] Sleep ((1000); What is it? This is a list of all the different ways Dn-filebox.qbox.me/0526171cd87660b623631c0e1230d728c54189df.png is credited in the database.

The dead cameEnn, the change should be correct afterwards. I don't seem to have a problem with the contrast graph when reviewing it. Also, the output should be the most timely when the new BAR is generated.

The Little DreamOh yeah, it's me who wrote the problem, I output LOG when the new BAR is generated, which is indeed the same thing as OPEN and CLOSE.

The dead came https://dn-filebox.qbox.me/f26922644ef757f579ac683a5032c42d57ee2bcc.png

The dead cameThe sensation log should be generated at the [-1] moment, so the code should be changed to: Log (("degrees the first BAR Time:", _D ((records[-2]["Time"] / 1000), "open:", records[-2]["Open"], "close:", records[-2]["Close"]) Log (("degrees the second BAR Time:", _D ((records[-3]["Time"] / 1000), "open:", records[-3]["Open"], "close:", records[-3]["Close"]))

The dead cameSuddenly I found that the close data of the inverse of the first BAR was a bit problematic, its open and close are always the same, I compared it later and found that close was wrong, but the code I didn't see was wrong.