Hi @fxshrat

I am trying to do find one standard deviation of last say "X day" range and add it to the current days open(subtract) price to get the expected range for the day..

```
// Code if using shorter interval than EOD (e.g. 1-min, 5-min, ...., Hourly, ...)
_SECTION_BEGIN("Expected_Intra_Move");
dtDayStartComp = TimeFrameCompress( DateTime(), inDaily, compressOpen );
dtDayStartExp = TimeFrameExpand( dtDayStartComp, inDaily, expandFirst );
dtDayEndComp = TimeFrameCompress( DateTime(), inDaily, compressLast );
dtDayEndExp = TimeFrameExpand( dtDayEndComp, inDaily, expandFirst );
DayCond = DateTime() >= dtDayStartExp AND DateTime() < dtDayEndExp;
SetBarsRequired(sbrAll);
Todays_Open = TimeFrameGetPrice( "O", inDaily, 0 );
//TimeFrameSet(inDaily);
tmfrm = inDaily;
TimeFrameSet( tmfrm );
Range = ATR(14);
VolatalityDays = StDev(ln(Range/Ref(Range,-1)), 30)*100*sqrt(252);
printf( "\n Range = %.2f \n", Range );
printf( "\n VolatalityDays = %.2f \n", VolatalityDays );
TimeFrameRestore();
VolatalityDays = TimeFrameExpand( VolatalityDays, tmfrm, expandLast);
Upper_Range=Todays_Open+(VolatalityDays);
Plot( IIf( DayCond, Upper_Range, Null ), "Upper Range", colorGreen, styleDashed, Null, Null, 0 );
Lower_Range=Todays_Open-(VolatalityDays);
Plot( IIf( DayCond, Lower_Range, Null ), "Lower Range", colorRed, styleDashed, Null, Null, 0 );
```

But the value it is not working as expected.. at some places, the value of standard deviation is negative..

Can you please suggest where I am going wrong?

Thanks in advance.

Regards,

Sumit