### Question

• Good Morning Group;

Consolidating the following The 3 indicator are:

RSI, CCI, MACD

```using System;
using System.Drawing;

namespace PowerLanguage.Indicator
{
public class RSI : IndicatorObject
{
private Function.RSI m_rsi1;

private VariableSeries<Double> m_myrsi;

private IPlotObject Plot1;

private IPlotObject Plot2;

private IPlotObject Plot3;

public RSI(object ctx) :
base(ctx){
overbcolor = Color.Red;
overscolor = Color.Cyan;
overbought = 70;
oversold = 30;
length = 4;
}

[Input]
public int length { get; set; }

[Input]
public double oversold { get; set; }

[Input]
public double overbought { get; set; }

[Input]
public Color overscolor { get; set; }

[Input]
public Color overbcolor { get; set; }

protected override void Create(){
m_rsi1 = new Function.RSI(this);
m_myrsi = new VariableSeries<Double>(this);
Plot1 =
Color.Empty, 0, 0, true));

Plot2 =
Color.Empty, 0, 0, true));
Plot3 =
Color.Empty, 0, 0, true));
}

protected override void StartCalc(){
m_rsi1.price = Bars.Close;
m_rsi1.length = length;
}

protected override void CalcBar(){
m_myrsi.Value = m_rsi1[0];
Plot1.Set(0, m_myrsi.Value);
Plot2.Set(0, overbought);
Plot3.Set(0, oversold);
if (PublicFunctions.DoubleGreater(m_myrsi.Value, overbought)){
Plot1.Colors[0] = overbcolor;
}
else{
if (PublicFunctions.DoubleLess(m_myrsi.Value, oversold)){
Plot1.Colors[0] = overscolor;
}
}
if (this.CrossesOver(m_myrsi, oversold)){
}
else{
if (this.CrossesUnder(m_myrsi, overbought)){
}
}
}
}
}

using System;
using System.Drawing;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
public class CCI_Average : IndicatorObject
{
private VariableSeries<Double> m_ccivalue;

private VariableSeries<Double> m_cciavg;

private IPlotObject Plot1;

private IPlotObject Plot2;

private IPlotObject Plot3;

private IPlotObject Plot4;

public CCI_Average(object ctx) :
base(ctx){
overbought = 100;
oversold = (-1*100);
cciavglength = 9;
ccilength = 15;
}

[Input]
public int ccilength { get; set; }

[Input]
public int cciavglength { get; set; }

[Input]
public double oversold { get; set; }

[Input]
public double overbought { get; set; }

protected override void Create(){
m_ccivalue = new VariableSeries<Double>(this);
m_cciavg = new VariableSeries<Double>(this);
Plot1 =
Color.Empty, 0, 0, true));
Plot2 =
Color.Empty, 0, 0, true));
Plot3 =
Color.Empty, 0, 0, true));
Plot4 =
Color.Empty, 0, 0, true));
}

protected override void CalcBar(){
m_ccivalue.Value = Bars.CCI(ccilength);
m_cciavg.Value = m_ccivalue.Average(cciavglength);
Plot1.Set(0, m_ccivalue.Value);
Plot2.Set(0, m_cciavg.Value);
Plot3.Set(0, overbought);
Plot4.Set(0, oversold);
if (this.CrossesOver(m_cciavg, oversold)){
}
else{
if (this.CrossesUnder(m_cciavg, overbought)){
}
}
}
}

using System;
using System.Drawing;

namespace PowerLanguage.Indicator
{
public class HUT_MACD: IndicatorObject
{
private Function.MACD m_macd1;

private Function.XAverage m_xaverage1;

private VariableSeries<Double> m_mymacd;

private VariableSeries<Double> m_macddiff;

private IPlotObject Plot1;

private IPlotObject Plot2;

private IPlotObject Plot3;

private IPlotObject Plot4;

public HUT_MACD(object ctx) :
base(ctx){
macdlength = 9;
slowlength = 15;
fastlength = 5;
}

[Input]
public int fastlength { get; set; }

[Input]
public int slowlength { get; set; }

[Input]
public int macdlength { get; set; }

protected override void Create(){
m_macd1 = new Function.MACD(this);
m_xaverage1 = new Function.XAverage(this);
m_mymacd = new VariableSeries<Double>(this);
m_macddiff = new VariableSeries<Double>(this);
Plot1 =
Color.Empty, 0, 0, true));
Plot2 =
Color.Empty, 0, 0, true));
Plot3 =
Color.Blue, Color.Empty, 0, 0,
true));
Plot4 =
Color.Empty, 0, 0, true));
}

protected override void StartCalc(){
m_macd1.Price = Bars.Close;
m_macd1.FastLength = fastlength;
m_macd1.SlowLength = slowlength;
m_xaverage1.Price = m_mymacd;
m_xaverage1.Length = macdlength;
m_mymacd.DefaultValue = 0;
m_macddiff.DefaultValue = 0;
}

protected override void CalcBar(){
m_mymacd.Value = m_macd1[0];
var m_macdavg = m_xaverage1[0];
m_macddiff.Value = m_mymacd.Value - m_macdavg;
Plot1.Set(0, m_mymacd.Value);
Plot2.Set(0, m_macdavg);
Plot3.Set(0, m_macddiff.Value);
Plot4.Set(0, 0);
if (this.CrossesOver(m_macddiff, 0)){
}
else{
if (this.CrossesUnder(m_macddiff, 0)){
}
}
}
}
}```

Then

I would like the Long Entry alert to:

If RSI Crosses over and
RSI Value > 70

and

If CCI Crosses over and
CCI Value > 100

and

IF MACD Crosses over and
MACDDiff > 0

"Long Entry"

Roger H Hicks

Roger H Hicks

Friday, December 22, 2017 10:47 AM

• Hi HICKSUNLIMITED,

>>In the code, there are (3) different indicator, would I consolidate them into one indicator and then add the dd the conditions

No, you don't need consolidate them into one. we could use c# Operator to achieve it, such as &&, ||, etc.

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-and-operator

Best regards,

Zhanglong

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Thursday, January 4, 2018 3:03 AM

### All replies

• Hi HICKSUNLIMITED,

According to your description, it seems that you want to alert message via a lot of condition from three class, if so, you could create three instance from three class and assign value to the instance. Then you could check if it is meeting the conditions. like this:

```RSI rsi = new RSI();
//assign related value to the instance
CCI_Average cci = new CCI_Average();
//assign related value to the instance
HUT_MACD macd = new HUT_MACD();
//assign related value to the instance
if (rsi.length > 70 && cci.ccilength > 100 && macd.macdlength > 0 && more condition)
{
MessageBox.Show("Long Entry");
}```

Best regards,

Zhanglong Wu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Monday, December 25, 2017 3:03 AM
• Thanks How would  I Consolidated the indicators

Roger H Hicks

Friday, December 29, 2017 5:56 PM
• Hi HICKSUNLIMITED,

>>Thanks How would  I Consolidated the indicators

You could write all condition in if statement.

If I misunderstand your issue, could you please describe it in detailed. it will be beneficial to resolve the issue.

Best regards,

Zhanglong Wu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Monday, January 1, 2018 5:27 AM
• In the code, there are (3) different indicator, would I consolidate them into one indicator and then add the dd the conditions

Roger H Hicks

Wednesday, January 3, 2018 6:39 PM
• Hi HICKSUNLIMITED,

>>In the code, there are (3) different indicator, would I consolidate them into one indicator and then add the dd the conditions

No, you don't need consolidate them into one. we could use c# Operator to achieve it, such as &&, ||, etc.

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-and-operator

Best regards,

Zhanglong

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Thursday, January 4, 2018 3:03 AM