## Custom RSI

Hello,

I am new to quantconnect, I would like to know if its possible to run a custom rsi indicator on the 233 minute or 4hr time frame on the spy

the code for the custom rsi

declare lower;

# Inputs:
input p = close;
input gamma = .236;

# Variables:
def L0;
def L1;
def L2;
def L3;
def CU;
def CD;
plot RSI;
plot OB;
plot OS;
plot ArrowUp;
plot ArrowDn;

# Script
script Laguerre{
input a = close;
input gamma = .5;
def L0 = ((1 - gamma) * a) + (gamma * L0[1]);
def L1 = (-gamma * L0) + L0[1] + (gamma * L1[1]);
def L2 = (-gamma * L1) + L1[1] + (gamma * L2[1]);
def L3 = (-gamma * L2) + L2[1] + (gamma * L3[1]);
plot Laguerre = (L0 + (2 * L1) + L2) / 4;
}
L0 = (1 – gamma) * p + gamma * L0[1];
L1 = - gamma * L0 + L0[1] + gamma * L1[1];
L2 = - gamma * L1 + L1[1] + gamma * L2[1];
L3 = - gamma * L2 + L2[1] + gamma * L3[1];
CU =
If L0 >= L1 then L0 - L1
Else If L1 >= L2 then CU[1] + L1 - L2
Else If L2 >= L3 then CU[1] + L2 - L3
Else 0;
CD =
If L0 <= L1 then L1 - L0
Else If L1 <= L2 then CD[1] + L2 - L1
Else If L2 <= L3 then CD[1] + L3 - L2
Else 0;
RSI =
Laguerre(a = if CU + CD <> 0 then CU / (CU + CD) else 0, gamma = 0);
OB =
if isNaN(RSI) then Double.NaN else .8;
OS =
if isNaN(RSI) then Double.NaN else .2;
RSI.SetDefaultColor(Color.Cyan);
OB.SetDefaultColor(Color.Yellow);
OS.SetDefaultColor(Color.Yellow);
ArrowUp = if RSI crosses above OS then OS else Double.Nan;
ArrowUp.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
ArrowUP.SetLineWeight(3);
ArrowUp.SetDefaultColor(Color.Green);
ArrowDn = if RSI crosses below OB then OB else Double.NaN;
ArrowDn.SetPaintingStrategy(PaintingStrategy.Arrow_Down);
ArrowDn.SetLineWeight(3);
ArrowDn.SetDefaultColor(Color.Red);

Thanks

Best Regards

Roger

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.

You can run an indicator on any time frame. If your indicator only requires the closing value, you can use the following to make an indicator on any bar size: ```var close = Identity("SPY", TimeSpan.FromMinutes(barSizeInMinutes)); var rsi = new RelativeStrengthIndex(14).Of(close);```If you require the full trade bar you can use consolidators:```var consolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(barSizeInMinutes)); SubscriptionManager.AddConsolidator("SPY", consolidator); consolidator.DataConsolidated += OnCustomBarSize; // later in file public void OnCustomBarSize(TradeBar customBarSizeTradeBar) { // do special logic on time frame } ```
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.

Hey Michael,

Thank you so much for the response, my apologies on the delay, I've been quite busy with work. I was wondering if you could suggest a good read on applying/declaring the inputs/conditions on quantconnect. For example, I have quite a few indicator codes that I would like to test, like the LRSI, but I am missing the functions/inputs. What do you suggest would be the best way to get a better understanding of these functions/declarations so I can run the backtests.

Best regards

Roger
0

The best way may be to look at the built-in indicators here. I would first take a peek at the simpler indicators, such as the ExponentialMovingAverage and SimpleMovingAverage. This should give a feel for the data flow. The indicators are computed 'online' - this means that we don't send array data into the indicator, but rather a single, new data point each time new data is available. For example, the SimpleMovingAverage implementation keeps track of data points it has seen by using the RollingWindow type. Each indicator must override the ComputeNextValue function, this is the function that will produce a new value for the indicator. Indicators can also override the IsReady property.

Have a look at the attached links and ping me back here with any and all questions!
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.