I'm creating a function to try and return the PriceRank of the current symbol. By using the IV Rank calculation, I want want to calculate the Price Rank.
I've used it, but some how, I'm getting higher current Closing prices than the Highest within the last 52 weeks.
Can someone tell me what I'm doing wrong?
Here is my code:
Screenshot attached of the Journal showing an example. My thought is that there is no way the closing price can be higher than the 52wk high. At most it can be equal.
Here is another example of the Lowest actually being higher than the Highest.
What am I doing wrong?
You are specifying a timeframe (PERIOD_W1) on your iHighest / iLowest calls, but then you use High[] and Low[] which reference the current timeframe.
So unless your current timeframe is PERIOD_W1, you will get the wrong result.
Try using iHigh() and iLow() instead.
use iHigh for the weekly timeframe.
You are getting values for the index on the current chart time-frame.
You are mixing apples and oranges. | valLowest= iLowest(NULL, PERIOD_W1, MODE_LOW, 52, 0); Print("High: ", High[valHighest], " Low: ", Low[valLowest], " |
I see what you guys are saying. So, I'm using the INDEX from the W1 timeframe and lets say that the iHighest returns a shift of 8 weeks ago. My High[valHighest] is going to return the High value from 8 days ago (on the D1 timeframe).
So, I need to extract the datetime from the shift that iHighest is returning and then figure out what the equivalent shift is for D1?
Am I on the right track?
If so, thank you!
jthornton: So, I need to extract the datetime from the shift that iHighest is returning and then figure out what the equivalent shift is for D1? Am I on the right track?
|
Close. It depends on what you are trying to do. In your case, you have a highest week. You could use iBarShift( weekStart ) and get the starting day of that week. But that won't get you the high. Which day of the week? You have the shift, just get the price of that bar iHigh. If you wanted the bar on a lower TF, you'd start with the starting bar iBarShift(weekStart). Then the last bar iBarShift( weekStart + PeriodSeconds(PERIOD_W1) - 1) And then find which bar in that range. |
Close. It depends on what you are trying to do. In your case, you have a highest week. You could use iBarShift( weekStart ) and get the starting day of that week. But that won't get you the high. Which day of the week? You have the shift, just get the price of that bar iHigh. If you wanted the bar on a lower TF, you'd start with the starting bar iBarShift(weekStart). Then the last bar iBarShift( weekStart + PeriodSeconds(PERIOD_W1) - 1) And then find which bar in that range. |
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm creating a function to try and return the PriceRank of the current symbol. By using the IV Rank calculation, I want want to calculate the Price Rank.
I've used it, but some how, I'm getting higher current Closing prices than the Highest within the last 52 weeks.
Can someone tell me what I'm doing wrong?
Here is my code:
Screenshot attached of the Journal showing an example. My thought is that there is no way the closing price can be higher than the 52wk high. At most it can be equal.