Comparing current price with open?


Category:
0
0

I have a newbie question. Is it possible to compare the current price (not a previous close but what it actually is at this exact time) to the open price for that particular bar? In otherwords, how much that candle has increased?

I wrote this code but not sure about the second line. Is PriceType.LAST the current price?

#in theory this should scan for candle that has grown 5% since it has opened
input percentIncrease = 1.05; #5% increase
input priceType = PriceType.LAST; #in theory, report current price???????
def currentPrice = close(priceType=priceType);
plot scan = (currentPrice * percentIncrease) > open;

 

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on April 29, 2020 11:30 am
102 views
0
Private answer

The solution is far easier than you can imagine. And this has already been asked and solved. Please be sure to search for your solution before posting a new question.

Here is link to the previous post. Please be sure to read the explanation so that you understand how to apply this correctly (hint: daily time frame).

https://www.hahn-tech.com/ans/percent-change-since-open-scan-tos/

 

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on April 29, 2020 1:29 pm
0
Thank you Pete. I actually looked that exact question before asking my own. And it was very close but felt I needed some details explained… I guess crux of my question would be this. Would close(priceType=PriceType.LAST) be the actual price right now that I could compare against the OPEN to see the length of a candle? If so, you mention that this is on the Day time frame. Can it be used on any time frame… such as the 1 min time frame? Thanks.
( at April 29, 2020 1:45 pm)
0
Within the coded, the close is always the most current price. There is no need to use any specific price type and in fact trying to use a price type may actually cause it to not work at all. Just depends on the instrument being scanned. Regarding the time frame, the code is merely comparing the open of the current candle to the close of that same candle. You can use this on any of the time frames available when building a custom scan.
( at April 29, 2020 3:35 pm)