Declare Lower;
input MALength = 200;
input length = 14;
input crossingType = {default above, below};
input threshold = 30;
input averageType = AverageType.WILDERS;
Def Con1 = Close > Average(Close,MALength);
def Con2 = crosses(RSI(length=length, averageType=averageType).RSI, threshold, crossingType == CrossingType.above);
Plot Signal = if Con1 and Con2 then 1 else 0;
Declare Lower;
input MALength = 200;
input length = 14;
input crossingType = {default above, below};
input threshold = 30;
input averageType = AverageType.WILDERS;
Def Con1 = Close > Average(Close,MALength);
def Con2 = crosses(RSI(length=length, averageType=averageType).RSI, threshold, crossingType == CrossingType.above);
Plot Signal = if Con1 and Con2 then 1 else 0;
hey thanks for the reply. I think i may be missing something. But when i copy and paste the code, nothing shows up on my chart. the strategy does however appear accurately on the 'Edit study and strategies' page. How do i load so i can see the results (arrows and/or labels) on the chart? thanks againCode:Declare Lower; input MALength = 200; input length = 14; input crossingType = {default above, below}; input threshold = 30; input averageType = AverageType.WILDERS; Def Con1 = Close > Average(Close,MALength); def Con2 = crosses(RSI(length=length, averageType=averageType).RSI, threshold, crossingType == CrossingType.above); Plot Signal = if Con1 and Con2 then 1 else 0;
The script will plot a 1 whenever the 2 conditions apply. It will plot a 0 for all of the other bars. I feel like a genie, you have 2 more wishes, be CAREFUL of what you wish for!hey thanks for the reply. I think i may be missing something. But when i copy and paste the code, nothing shows up on my chart. the strategy does however appear accurately on the 'Edit study and strategies' page. How do i load so i can see the results (arrows and/or labels) on the chart? thanks again
https://usethinkscript.com/threads/jt_multitrend.6998/page-2#posts "Posts #25 & #26" show how different EMA's and Butterworth Filters work with band restrictions for long and short conditionsCan I make a request? I would like 1 indicator that is composed of 2 RSI indicators which I would like to be ale to change the values and colors of. Default values would be 25 and 100 for the RSI lengths. Colors make no matter for default as long as they are changeable. I also need an EMA with changeable moving average types such as simple, EMA, HULL and changeable length with a default of 25 EMA. I would like to have signals when the 25 RSI crosses above and below the 100 RSI. The other rule is longs only above the 25 EMA and shorts vice versa.
Is this possible to put all into 1 indicator? I would like to be able to scan for the RSI crossover signals if that matters how you go about coding this. Thanks in advance for any help.
Did you come up with this?@henry1224 Thank you for the tips. I will see what I can figure out from here. Thanks.
declare lower;
input length1 = 25;
input length2 = 100;
input EMALength = 25;
Input price = Close;
input Dotsize = 3;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, price - price[1], length1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(price - price[1]), length1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, price - price[1], length2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(price - price[1]), length2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
Def EXPA = ExpAverage(Close,EMALength);
Def Con1 = If RSIA >= RSIB then 1 else 0;
Def Con2 = if Close>= EXPA then 1 else 0;
plot A1_Dot = if IsNaN(Close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A1_Dot.SetLineWeight(DotSize);
A1_Dot.AssignValueColor(if Con1 == 1 and Con2 ==1 then Color.Cyan else if Con1 ==0 and Con2 ==0 then Color.Magenta else Color.Yellow);
You can also plot this as an upper indicator, Coloring the EMA to reflect the change in RSIDid you come up with this?
Code:declare lower; input length1 = 25; input length2 = 100; input EMALength = 25; Input price = Close; input Dotsize = 3; input averageType = AverageType.WILDERS; def NetChgAvgA = MovingAverage(averageType, price - price[1], length1); def TotChgAvgA = MovingAverage(averageType, AbsValue(price - price[1]), length1); def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0; def RSIA = 50 * (ChgRatioA + 1); def NetChgAvgB = MovingAverage(averageType, price - price[1], length2); def TotChgAvgB = MovingAverage(averageType, AbsValue(price - price[1]), length2); def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0; def RSIB = 50 * (ChgRatioB + 1); Def EXPA = ExpAverage(Close,EMALength); Def Con1 = If RSIA >= RSIB then 1 else 0; Def Con2 = if Close>= EXPA then 1 else 0; plot A1_Dot = if IsNaN(Close) then Double.NaN else 1; A1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES); A1_Dot.SetLineWeight(DotSize); A1_Dot.AssignValueColor(if Con1 == 1 and Con2 ==1 then Color.Cyan else if Con1 ==0 and Con2 ==0 then Color.Magenta else Color.Yellow);
declare Upper;
input length1 = 25;
input length2 = 100;
input EMALength = 25;
Input Price = Close;
Input arrows = no;
Input Dotsize = 3;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, price - price[1], length1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(price - price[1]), length1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
def RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, price - price[1], length2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(price - price[1]), length2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
def RSIB = 50 * (ChgRatioB + 1);
Plot EXPA = ExpAverage(Close,EMALength);
Def Con1 = If RSIA >= RSIB then 1 else 0;
Def Con2 = if Close>= EXPA then 1 else 0;
EXPA.AssignValueColor(if Con1 == 1 and Con2 ==1 then Color.Cyan else if Con1 ==0 and Con2 ==0 then Color.Magenta else Color.Yellow);
plot ArrowDown = if arrows and (Con1 ==0 and Con2 ==0 and Con1[1] ==1 and Con2[1] ==0) or (arrows and Con1 ==0 and Con2 ==0 and Con1[1] == 0 and Con2[1] == 1) then High else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Magenta);
ArrowDown.setLineWeight(dotsize);
plot ArrowUp = if arrows and (Con1 ==1 and Con2 ==1 and Con1[1] ==1 and Con2[1] ==0) or (arrows and Con1 ==1 and Con2 ==1 and Con1[1] == 0 and Con2[1] == 1) then Low else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);
Here is the code for 2 RSINot sure what the difference is, but your signals don't match at all to when I place 2 instances of RSI and use 25 and 100 for their lengths- signals are the crossovers of the 2 RSI overlayed on top of each other when they are signals on the right side of the 25 EMA
declare lower;
input length1 = 25;
input length2 = 100;
input EMALength = 25;
Input price = Close;
input Dotsize = 3;
input arrows = no;
input averageType = AverageType.WILDERS;
def NetChgAvgA = MovingAverage(averageType, price - price[1], length1);
def TotChgAvgA = MovingAverage(averageType, AbsValue(price - price[1]), length1);
def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0;
Plot RSIA = 50 * (ChgRatioA + 1);
def NetChgAvgB = MovingAverage(averageType, price - price[1], length2);
def TotChgAvgB = MovingAverage(averageType, AbsValue(price - price[1]), length2);
def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0;
Plot RSIB = 50 * (ChgRatioB + 1);
RSIA.SetDefaultColor(Color.Cyan);
RSIB.SetDefaultColor(Color.Magenta);
AddCloud(RSIA,RSIB,Color.Cyan,Color.Magenta);
plot ArrowDown = if arrows and RSIA crosses below RSIB then RSIB else double.nan;
ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down);
ArrowDown.setDefaultColor(color.Magenta);
ArrowDown.setLineWeight(dotsize);
plot ArrowUp = if arrows and RSIA crosses Above RSIB then RSIB else double.nan;
ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up);
ArrowUp.setDefaultColor(color.Cyan);
ArrowUp.setLineWeight(dotsize);
The rsi's are on the same scale and match upHere is the code for 2 RSI
Code:declare lower; input length1 = 25; input length2 = 100; input EMALength = 25; Input price = Close; input Dotsize = 3; input arrows = no; input averageType = AverageType.WILDERS; def NetChgAvgA = MovingAverage(averageType, price - price[1], length1); def TotChgAvgA = MovingAverage(averageType, AbsValue(price - price[1]), length1); def ChgRatioA = if TotChgAvgA != 0 then NetChgAvgA / TotChgAvgA else 0; Plot RSIA = 50 * (ChgRatioA + 1); def NetChgAvgB = MovingAverage(averageType, price - price[1], length2); def TotChgAvgB = MovingAverage(averageType, AbsValue(price - price[1]), length2); def ChgRatioB = if TotChgAvgB != 0 then NetChgAvgB / TotChgAvgB else 0; Plot RSIB = 50 * (ChgRatioB + 1); RSIA.SetDefaultColor(Color.Cyan); RSIB.SetDefaultColor(Color.Magenta); AddCloud(RSIA,RSIB,Color.Cyan,Color.Magenta); plot ArrowDown = if arrows and RSIA crosses below RSIB then RSIB else double.nan; ArrowDown.setpaintingStrategy(paintingStrategy.Arrow_Down); ArrowDown.setDefaultColor(color.Magenta); ArrowDown.setLineWeight(dotsize); plot ArrowUp = if arrows and RSIA crosses Above RSIB then RSIB else double.nan; ArrowUp.setpaintingStrategy(paintingStrategy.Arrow_Up); ArrowUp.setDefaultColor(color.Cyan); ArrowUp.setLineWeight(dotsize);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
C | Scan for stocks above 200 daily SMA but also include IPOs | Questions | 1 | |
A | price cross 150ma -- moving to 200 ma | Questions | 3 | |
S | Scan for stocks Trading Within 0.xx$ of 200 SMA | Questions | 0 | |
P | Scanner: 50 SMA above 200 SMA over the last 30 bars | Questions | 2 | |
S | flat sma 200 scan | Questions | 2 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.