thanks...i see. not quite what i had in mind and i'm afraid i was unclear originally.
I'd like an line indicator to show on an intra-day chart the average daily range for past X (like 7) trading days. It would be even nicer to have it weighted, similar to weighted moving average.
Does this make sense?
ps - I suck at programming...makes my temples ache and gives me a white hot poker in back of my neck. So, i appreciate all the help.
Brad,
Appreciate the effort.
Here's what i'd like. E.g., on ES H3=2 (6:30-13:00pst).
2-25 23.75 is it's day's range today
2-24 14.25
2-23 22.50
2-22 13.75
2-21 12.00
_________
= 86.25 / 5days = 17.25 for average last 5 days
I'd like a line indicator which would display 17.25 for entire day tomorrow on my intraday chart, then after tomorrow's range is complete, the indicator would change to it's new average.
Thanks.
As far as I know, this is not entirely possible at this time. There is a solution, but I have to re-write the code...
The immediate solution is to load this indicator onto a Daily chart and change the User-Input to 5. This will give you the range from the daily chart and allow you to use this on your intraday chart..
/*
* Set the properties of the default bar. These will be the
* properties of any bar for which style, color, thickness is
* not specificed.
*/
setDefaultBarStyle(PS_SOLID, 0); // Open
setDefaultBarStyle(PS_SOLID, 1); // High
setDefaultBarStyle(PS_SOLID, 2); // Low
setDefaultBarStyle(PS_SOLID, 3); // Close
setDefaultBarFgColor(Color.red, 0); // Open
setDefaultBarFgColor(Color.black, 1); // High
setDefaultBarFgColor(Color.black, 2); // Low
setDefaultBarFgColor(Color.blue, 3); // Close
setDefaultBarThickness(2, 0); // Open
setDefaultBarThickness(4, 1); // High
setDefaultBarThickness(4, 2); // Low
setDefaultBarThickness(2, 3); // Close
setPlotType(PLOTTYPE_FLATLINES, 0); // Open
setPlotType(PLOTTYPE_FLATLINES, 1); // High
setPlotType(PLOTTYPE_FLATLINES, 2); // Low
setPlotType(PLOTTYPE_FLATLINES, 3); // Close
}
var vSymbol = null;
var vInterval = null;
var vLastRawTime = null;
var vLastO = null;
var vLastH = null;
var vLastL = null;
var vLastC = null;
/*
* This is a neat formula because it is working on multiple intervals
* sBarItem will be "Open", "High", "Close", or "Low"
*
*/
function main(bShowOpen, bShowHigh, bShowLow, bShowClose) {
if(bShowOpen == null)
bShowOpen = true;
if(bShowHigh == null)
bShowHigh = true;
if(bShowLow == null)
bShowLow = true;
if(bShowClose == null)
bShowClose = true;
/*
* No need to show the OHL or C on a daily chart.
* only interested in seeing OHLorC on intraday.
*/
if(vInterval == "D" || vInterval == "W" || vInterval == "M")
return;
/*
* What time is the current bar?
*/
vBarTime = getValue("time");
if(vBarTime != null) {
/*
* vTime is currently the time for the current intraday bar.
* Ask for the time of the previous trading day for "Symbol,D"
* Note: See that we are asking for a different time frame
* than the default by passing a symbol,interval
*/
vAbsTime = getPreviousTradingDay(vBarTime, vSymbol);
if(vAbsTime == null)
return;
/*
* Get index to first bar of day. In this case the daily bar.
*/
vIndex = getFirstBarIndexOfDay(vAbsTime, vSymbol);
if(vIndex != null) {
vO = getValueAbsolute("Open", vIndex, vSymbol);
vH = getValueAbsolute("High", vIndex, vSymbol);
vL = getValueAbsolute("Low", vIndex, vSymbol);
vC = getValueAbsolute("Close", vIndex, vSymbol);
vLastRawTime = vRawTime;
vLastO = vO;
vLastH = vH;
vLastL = vL;
vLastC = vC;
return new Array(vO, vH, vL, vC);
}
}
return null;
The attached efs will plot both the range of the prior day and a user defined average of the ranges (default is 5 days).
Note that the EFS requires getPrevDaysOHLC.efs in the OHLC subfolder of Formulas. If you do not have it you can find a copy here
Alex
Comment