Any way of reseting a indicator each session (intraday)

Questions about MultiCharts and user contributed studies.
Automeq
Posts: 108
Joined: 16 Apr 2014
Has thanked: 15 times
Been thanked: 1 time

Any way of reseting a indicator each session (intraday)

Postby Automeq » 12 Oct 2015

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.

User avatar
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)

Postby Henry MultiСharts » 15 Oct 2015

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.

Automeq
Posts: 108
Joined: 16 Apr 2014
Has thanked: 15 times
Been thanked: 1 time

Re: Any way of reseting a indicator each session (intraday)

Postby Automeq » 16 Oct 2015

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.

User avatar
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)

Postby Henry MultiСharts » 21 Oct 2015

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'.
Hello Automeq,

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 ;
If you want to calculate the average on bars inside Length period after daily reset - change the corresponding line above to the following:

Code: Select all

if value1>0 and value1<Length then var0=Average( c, value1) ;


Return to “MultiCharts”