Code: Select all
input: First_Period(14) Above_level(70);
variables: Barssince(0);
Barssince = 0;
While RSI(Close, First_Period) < Above_level
begin
Barssince = Barssince + 1;
end;
Plot1(Barssince, "barssince");
Code: Select all
input: First_Period(14) Above_level(70);
variables: Barssince(0);
Barssince = 0;
While RSI(Close, First_Period) < Above_level
begin
Barssince = Barssince + 1;
end;
Plot1(Barssince, "barssince");
you can try this:In Metastock, there is a syntax called Barssince. This syntax is able to find out how many bars since a condition takes place. For example, bars since MACD crosses above its moving average. In Multicharts, I like to write something similar. I like to know if it is possible to write an indicator that counts the number of bars since RSI falls below 80. How to do it? I tried the code below but Multicharts hangs after I insert the indicator
Code: Select all
input: First_Period(14) Above_level(70);
variables: Barssince(0);
Barssince = 0;
While RSI(Close, First_Period) < Above_level
begin
Barssince = Barssince + 1;
end;
Plot1(Barssince, "barssince");
Code: Select all
...
myRSI = RSI(Close, First_Period);
if myRSI cross above Above_Level then
Barssince = 0;
Barssince = Barssince +1;
Plot1(Barssince, "barssince");