# Smoothed RSI Conditional Order

#### Dousei987

##### New member
I’m trying to better understand custom orders and hopefully create one that responds to potential patterns and signals I think I’ve seen.

Mostly observed rsi and adx. Tried looking at both indicators on the same chart to see any potential overlap. Just wondering is there a way for the platform to do a trade order when both indicators reach a certain condition, or receive a signal or message saying condition met. Sometimes I think these patterns happen in the middle of the night or after market close.

Main thing is can I create a code specifically to combine indicator signals and get a message as soon as it is generated even if I’m away from my computer.

Solution
The Conditional Order using the below study would be:
Upsignal is true or DownSignal is true

Ruby:
``````input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
Input HMASmoothing = 4; ##Added an input line for smoothing value

def NetChgAvg = WildersAverage(price - price[1], length);
def TotChgAvg = WildersAverage(AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI_Raw = 50 * (ChgRatio + 1); ## changed the name to RSI_Raw
def SmoothRSI = HullMovingAvg (RSI_Raw, HMASmoothing); ## Added our smoothing

Plot downsignal = if SmoothRSI is greater than 70 and RSI()."RSI" is greater than 70...``````

#### Dousei987

##### New member
Can someone help me with creating a conditional order with these indicators. I have a general idea of how to code for when RSI shows over in market. But how do I create a signal for when RSI and smooth RSI both show over at the same time in the same market.

I use to enter only when RSI started showing over but sometimes I get a fast moving/short trend before a reverse starts. So i added an smooth RSI so that it can filter and help limit false entry signals. Basically RSI will show an over signal, and if Smooth RSI also generates a signal then it means trend is still going and you didn't rush immediately when signal is generated.

I'm using the NKD market just around when market opens and a couple hours have already passed, since my main focus is hopefully to test on the faster and greater volatility markets like the DOW or NASDAQ. Theory is meant to take advantage of roughly 30 min before to the 1st hour of makret open since it tends to be when volatility is at the highest and market moves may be most.

#### Dousei987

##### New member
For Smooth RSI i tried HMA Smoothing 3.

Here's the source code as it appears:
declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
Input HMASmoothing = 4; ##Added an input line for smoothing value

def NetChgAvg = WildersAverage(price - price[1], length);
def TotChgAvg = WildersAverage(AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI_Raw = 50 * (ChgRatio + 1); ## changed the name to RSI_Raw
plot OverSold = over_Sold;
plot OverBought = over_Bought;

Plot RSI = HullMovingAvg (RSI_Raw, HMASmoothing); ## Added our smoothing

RSI.DefineColor("OverBought", GetColor(5));
RSI.DefineColor("Normal", GetColor(7));
RSI.DefineColor("OverSold", GetColor(1));
RSI.AssignValueColor(if RSI > over_Bought then RSI.color("OverBought") else if RSI < over_Sold then RSI.color("OverSold") else RSI.color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));

#### MerryDay

Staff member
Staff
VIP
The Conditional Order using the below study would be:
Upsignal is true or DownSignal is true

Ruby:
``````input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
Input HMASmoothing = 4; ##Added an input line for smoothing value

def NetChgAvg = WildersAverage(price - price[1], length);
def TotChgAvg = WildersAverage(AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI_Raw = 50 * (ChgRatio + 1); ## changed the name to RSI_Raw
def SmoothRSI = HullMovingAvg (RSI_Raw, HMASmoothing); ## Added our smoothing

Plot downsignal = if SmoothRSI is greater than 70 and RSI()."RSI" is greater than 70 then high else double.NaN ;
downsignal.SetPaintingStrategy(PaintingStrategy.ARROW_down);
downsignal.SetLineWeight(1);
downsignal.SetDefaultColor(color.magenta) ;

Plot upsignal = if SmoothRSI is less than 30 and RSI()."RSI" is less than 30 then low else double.NaN ;
upsignal.SetPaintingStrategy(PaintingStrategy.ARROW_up);
upsignal.SetLineWeight(1);
upsignal.SetDefaultColor(color.blue) ;``````

#### Dousei987

##### New member
Yes thank you. This is a big help. It really gives me an idea and direction of how I may try to improve.