Wanted to know if anyone could create an indicator that creates a buy/sell tag on the upper chart. Conditions are:
Buy: 5 exp move avg greater than 13 exp move avg and RSI is above 50.
Sell 5 exp move avg less than 13 exp move avg and RSI is below 50
Any help would be greatly appreciated!
Wanted to see if we could add a condition to this script. As the script is now, the buy and sell signal appear when the move averages cross but I would like to add a condition for those buy and sell signals to occur only when RSI is above or below 50. Any help would be greatly appreciated!
Buy signal: Buy signal occurs when the faster move average crosses above the slower move average ( just as it is now) and RSI is above 50. Once those two conditions are met, the buy signal will generate.
Sell signal: Sell signal occurs when the faster move average crosses below the slower move average ( just as it is now) and RSI is below 50. Once those two conditions are met, the sell signal will generate.
Here is the code:
Wanted to see if anyone knew how to how to add a condition to the move average cross indicator. Would like to add RSI as a condition so when the move averages cross and produce a signal, RSI is taken into consideration as well to produce those signals. Thank you in advance for any assistance!
New Buy Condition: Fast move average crosses above slow move average and RSI is above 50, the buy signal is produced. As of right now the signal is produced when the move averages crosses.
New Sell Condition: Fast move average crosses below slow move average and RSI is below 50, the sell signal is produced. As of right now the signal is produced when the move averages crosses.
Here is the thinkscript I am using:
Buy: 5 exp move avg greater than 13 exp move avg and RSI is above 50.
Sell 5 exp move avg less than 13 exp move avg and RSI is below 50
Any help would be greatly appreciated!
Wanted to see if we could add a condition to this script. As the script is now, the buy and sell signal appear when the move averages cross but I would like to add a condition for those buy and sell signals to occur only when RSI is above or below 50. Any help would be greatly appreciated!
Buy signal: Buy signal occurs when the faster move average crosses above the slower move average ( just as it is now) and RSI is above 50. Once those two conditions are met, the buy signal will generate.
Sell signal: Sell signal occurs when the faster move average crosses below the slower move average ( just as it is now) and RSI is below 50. Once those two conditions are met, the sell signal will generate.
Here is the code:
Ruby:
#hint: <b>Find Moving Average Xover</b>\nFinds when a fast moving average crosses over or under a slow.\n The fast average going above the slow average (bullish crossover) is a signal to buy, while the opposite situation (bearish crossover) is a signal to sell.
input price = close;#hint price: The price used to calculate the crossover. <b>(Default is CLOSE)</b>
input fastLength = 9;#hint fastLength: The number of bars used to calculate the fast moving average. <b>(Default is 3)</b>
input slowLength = 21;#hint slowLength: The number of bars used to calculate the slow moving average. <b>(Default is 8)</b>
input slowAvgType = {default exponential, simple, Weighted, Wilders, Hull};#hint slowAvgType: Type of the fast moving average to be used for calculation. <b>(Default is Expontential)</b>
input fastAvgType = {default exponential, simple, Weighted, Wilders, Hull};#hint fastAvgType: Type of the fast moving average to be used for calculation. <b>(Default is Exponential)</b>
Input DoArrows = no;#hint DoArrows:Yes shows arrows to define crosses
Input DoPlots = yes;#hint DoPlots: Yes shows MA plots to define crosses. Default is 'YES'
Input DoAlerts = No;#hint DoAlerts:No turns off alerts
Assert( fastLength < slowLength, "fastLength ["+fastLength+"] must be less than slowLength["+slowLength+"]");
def fastAvg;
switch (slowAvgType) {
case Simple:
fastAvg = Average(price, fastLength);
case Exponential:
fastAvg = ExpAverage(price, fastLength);
case Weighted:
fastAvg = wma(price, fastLength);
case Wilders:
fastAvg = WildersAverage(price, fastLength);
case Hull:
fastAvg = HullMovingAvg(price, fastLength);
}
def slowAvg;
switch (fastAvgType) {
case Simple:
slowAvg = Average(price, slowLength);
case Exponential:
slowAvg = ExpAverage(price, slowLength);
case Weighted:
slowAvg = wma(price, slowLength);
case Wilders:
slowAvg = WildersAverage(price, slowLength);
case Hull:
slowAvg = HullMovingAvg(price, slowLength);
}
plot signalXup = If DoArrows Then crosses(fastAvg, slowAvg, CrossingDirection.above) else Double.nan;
signalXup.SetDefaultColor(Color.pink);
signalXup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signalXup.SetLineWeight(3);
plot signalXdn = If DoArrows Then crosses(fastAvg, slowAvg, CrossingDirection.below) else Double.nan;
signalXdn.SetDefaultColor(Color.cyAN);
signalXdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signalXdn.SetLineWeight(3);
Alert(signalXup && DoAlerts, "UP...Fast MA Cross Above Slow MA", Alert.BAR, Sound.Ring );
Alert(signalXdn && DoAlerts, "Down...Fast Ma Cross Below Slow MA", Alert.BAR, Sound.Bell );
Plot fast_Avg = If DoPlots then Fastavg else double.nan;
fast_Avg.SetDefaultColor(Color.red);
fast_Avg.SetPaintingStrategy(PaintingStrategy.line);
fast_Avg.SetLineWeight(2);
Plot Slo_Avg = If DoPlots then Slowavg else double.nan;
Slo_Avg.SetDefaultColor(Color.cyan);
Slo_Avg.SetPaintingStrategy(PaintingStrategy.line);
Slo_Avg.SetLineWeight(2);
AddCloud(fastAvg, slowAvg, color.green, color.RED);
#AddLabel(1, "Fast MA(" + fastLength + ")",color.pink);
#AddLabel(1, "Slow MA(" + slowLength + ")",color.cyan);
#end
Wanted to see if anyone knew how to how to add a condition to the move average cross indicator. Would like to add RSI as a condition so when the move averages cross and produce a signal, RSI is taken into consideration as well to produce those signals. Thank you in advance for any assistance!
New Buy Condition: Fast move average crosses above slow move average and RSI is above 50, the buy signal is produced. As of right now the signal is produced when the move averages crosses.
New Sell Condition: Fast move average crosses below slow move average and RSI is below 50, the sell signal is produced. As of right now the signal is produced when the move averages crosses.
Here is the thinkscript I am using:
Ruby:
#hint: <b>Find Moving Average Xover</b>\nFinds when a fast moving average crosses over or under a slow.\n The fast average going above the slow average (bullish crossover) is a signal to buy, while the opposite situation (bearish crossover) is a signal to sell.
input price = close;#hint price: The price used to calculate the crossover. <b>(Default is CLOSE)</b>
input fastLength = 9;#hint fastLength: The number of bars used to calculate the fast moving average. <b>(Default is 3)</b>
input slowLength = 21;#hint slowLength: The number of bars used to calculate the slow moving average. <b>(Default is 8)</b>
input slowAvgType = {default exponential, simple, Weighted, Wilders, Hull};#hint slowAvgType: Type of the fast moving average to be used for calculation. <b>(Default is Expontential)</b>
input fastAvgType = {default exponential, simple, Weighted, Wilders, Hull};#hint fastAvgType: Type of the fast moving average to be used for calculation. <b>(Default is Exponential)</b>
Input DoArrows = no;#hint DoArrows:Yes shows arrows to define crosses
Input DoPlots = yes;#hint DoPlots: Yes shows MA plots to define crosses. Default is 'YES'
Input DoAlerts = No;#hint DoAlerts:No turns off alerts
Assert( fastLength < slowLength, "fastLength ["+fastLength+"] must be less than slowLength["+slowLength+"]");
def fastAvg;
switch (slowAvgType) {
case Simple:
fastAvg = Average(price, fastLength);
case Exponential:
fastAvg = ExpAverage(price, fastLength);
case Weighted:
fastAvg = wma(price, fastLength);
case Wilders:
fastAvg = WildersAverage(price, fastLength);
case Hull:
fastAvg = HullMovingAvg(price, fastLength);
}
def slowAvg;
switch (fastAvgType) {
case Simple:
slowAvg = Average(price, slowLength);
case Exponential:
slowAvg = ExpAverage(price, slowLength);
case Weighted:
slowAvg = wma(price, slowLength);
case Wilders:
slowAvg = WildersAverage(price, slowLength);
case Hull:
slowAvg = HullMovingAvg(price, slowLength);
}
plot signalXup = If DoArrows Then crosses(fastAvg, slowAvg, CrossingDirection.above) else Double.nan;
signalXup.SetDefaultColor(Color.pink);
signalXup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signalXup.SetLineWeight(3);
plot signalXdn = If DoArrows Then crosses(fastAvg, slowAvg, CrossingDirection.below) else Double.nan;
signalXdn.SetDefaultColor(Color.cyAN);
signalXdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signalXdn.SetLineWeight(3);
Alert(signalXup && DoAlerts, "UP...Fast MA Cross Above Slow MA", Alert.BAR, Sound.Ring );
Alert(signalXdn && DoAlerts, "Down...Fast Ma Cross Below Slow MA", Alert.BAR, Sound.Bell );
Plot fast_Avg = If DoPlots then Fastavg else double.nan;
fast_Avg.SetDefaultColor(Color.red);
fast_Avg.SetPaintingStrategy(PaintingStrategy.line);
fast_Avg.SetLineWeight(2);
Plot Slo_Avg = If DoPlots then Slowavg else double.nan;
Slo_Avg.SetDefaultColor(Color.cyan);
Slo_Avg.SetPaintingStrategy(PaintingStrategy.line);
Slo_Avg.SetLineWeight(2);
AddCloud(fastAvg, slowAvg, color.green, color.RED);
#AddLabel(1, "Fast MA(" + fastLength + ")",color.pink);
#AddLabel(1, "Slow MA(" + slowLength + ")",color.cyan);
#end
Last edited by a moderator: