Awesome Oscillator On Top adding William R
Awesome Oscillator On Top adding William R
19 Jul 2020, 14:50
HI Team
I am writing Indicator for combination of AO + William R
Is anything wrong on my Code?
If commented my william R code it will display AO
However, If i have both results only showing William R Indicator results.
Can someone help me here whats went wrong on my code.
[Parameter(DefaultValue = 5)]
public int periodFast { get; set; }
[Parameter(DefaultValue = 34)]
public int periodSlow { get; set; }
[Parameter("WRPeriods", DefaultValue = 25)]
public int WRPeriod { get; set; }
[Output("Main", LineColor = "CornflowerBlue", Thickness = 2)]
public IndicatorDataSeries WResult { get; set; }
[Output("previousAO")]
public double previousAO { get; set; }
[Output("currentAO")]
public double currentAO { get; set; }
[Output("Awesome OscillatorGreen", IsHistogram = true, LineColor = "Green")]
public IndicatorDataSeries AwesomeGreen { get; set; }
[Output("Awesome OscillatorRed", IsHistogram = true, LineColor = "Red")]
public IndicatorDataSeries AwesomeRed { get; set; }
private SimpleMovingAverage smaSlow;
private SimpleMovingAverage smaFast;
private IndicatorDataSeries medianprice;
protected override void Initialize()
{
// Initialize and create nested indicators
medianprice = CreateDataSeries();
smaSlow = Indicators.SimpleMovingAverage(medianprice, periodSlow);
smaFast = Indicators.SimpleMovingAverage(medianprice, periodFast);
}
public override void Calculate(int index)
{
//William R start
double max = Bars.HighPrices.Maximum(WRPeriod);
double min = Bars.LowPrices.Minimum(WRPeriod);
double close = Bars.ClosePrices[index];
WResult[index] = 100 - (100 * (close - max) / (max - min) * -1);
//William R End
//AO Calculate value at specified index
medianprice[index] = (Bars.HighPrices[index] + Bars.LowPrices[index]) / 2;
previousAO = smaFast.Result[index - 1] - smaSlow.Result[index - 1];
currentAO = smaFast.Result[index] - smaSlow.Result[index];
if (previousAO >= currentAO)
{
AwesomeRed[index] = smaFast.Result[index] - smaSlow.Result[index];
}
else
{
AwesomeGreen[index] = smaFast.Result[index] - smaSlow.Result[index];
}
}
Replies
RamboForex
20 Jul 2020, 11:03
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi malleswaramma.ram,
The problem is the scale
Best Regards,
Panagiotis
Hi Panagiotis
Yes i was thinking may be scale issue
can we override scale OFF for Willams R so that we can see the both Indicators on the screen?
Please suggest the solution.
@RamboForex
PanagiotisCharalampous
20 Jul 2020, 11:09
Hi malleswaramma.ram,
No that is not possible. The only solution would be to somehow change the values of your Williams R so that they fall within the range of the Awesome oscillator.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
20 Jul 2020, 09:27
Hi malleswaramma.ram,
The problem is the scale
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous