If I have a 1 minute chart with Parabolic SAR (or any other), can I reset the indicator at the begging of each session ?
I'm asking this because if I only use Regular Trading Hours and there is a gap (which is usual), the indicator values are meaningless. I would prefer to reset it and force the indicator to calculate starting from nothing.
Any way of reseting a indicator each session (intraday)
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Any way of reseting a indicator each session (intraday)
Hello Automeq,
In order to differentiate between the sessions you can use SessionLastBar - Returns a logical value indicating whether the current bar is the last bar of the session; returns a value of True if the current bar is the last bar of the session, and a value of False if the current bar is not the last bar of the session.
In order to differentiate between the sessions you can use SessionLastBar - Returns a logical value indicating whether the current bar is the last bar of the session; returns a value of True if the current bar is the last bar of the session, and a value of False if the current bar is not the last bar of the session.
Re: Any way of reseting a indicator each session (intraday)
Thanks Henry but I don't see how this can be used to reset the indicator.
If I have a chart of 1 minute and a simple moving average of 14 periods, Multicharts waits 14 bars to compute the moving average.
I would like this to happen every day which means that if a new day starts now, the moving average 14 period will have to wait 14 minutes to be calculated for the first time today. What happens in the previous day (or session) should be 'forgotten'.
I'm not sure if this is possible.
If I have a chart of 1 minute and a simple moving average of 14 periods, Multicharts waits 14 bars to compute the moving average.
I would like this to happen every day which means that if a new day starts now, the moving average 14 period will have to wait 14 minutes to be calculated for the first time today. What happens in the previous day (or session) should be 'forgotten'.
I'm not sure if this is possible.
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Any way of reseting a indicator each session (intraday)
Hello Automeq,I would like this to happen every day which means that if a new day starts now, the moving average 14 period will have to wait 14 minutes to be calculated for the first time today. What happens in the previous day (or session) should be 'forgotten'.
Please find the adjusted code below:
Code: Select all
inputs: Price( Close ), Length( 14 ), Displace( 0 ) ;
variables: var0( 0 ), var1(0), PriceModif(0), Counter(0);
value1 = 0;
For Counter=0 To Length Begin
if date<>date[Counter] then begin value1=Counter; break; end;
End;
var0 = Average( c, Length ) ; //requires simple function instead of series
if value1>0 and value1<Length then var0 = 0;
condition1 = Displace >= 0 or CurrentBar > AbsValue( Displace ) ;
if condition1 then
begin
Plot1[Displace]( var0, "Avg" ) ;
if Displace <= 0 then
begin
condition1 = Price crosses over var0 ;
if condition1 then
Alert( "Price crossing over average" )
else
begin
condition1 = Price crosses under var0 ;
if condition1 then
Alert( "Price crossing under average" ) ;
end ;
end;
end ;
Code: Select all
if value1>0 and value1<Length then var0=Average( c, value1) ;