// Script generates chart for differences between day open price (midnight for fx market) and every bar according to defined bar period.
// author: NightWalker @ Zorro Trader Forum
// version: 20121202.
function run()
{
BarPeriod = 60; //time frame set to 1 hour
StartDate = 2012; //testing just for 2012 year
NumDays = 30; // and only 30 days
TimeFrame = 24; //switchitng time frame - price series below reference to daily frame (24 * BarPeriod))
var daily_atr = ATR(1);
TimeFrame = 1; //switching timeframe to 1 hour and printf debugging info
printf("\n close = %f, daily-open = %f, atr = %f", priceClose(0), priceOpen(hour(0)), daily_atr);
var pricediff = (priceClose(0) - priceOpen(hour(0)))/daily_atr*PIP; //calculate difference in price
// hour(0) means current price, so priceOpen(hour(0)) points to daily open (for fx markets - midnight))
if ( hour(0) == 0) // ploting big red bar separating days instead of first hour bar
plot("new day", daily_atr, BARS, RED);
else
plot("price differences", pricediff, BARS, BLUE); //plot price difference for current bar
PlotHeight1 = 300;
set(PLOTNOW);
}