190
forexmmm

Hi,

I have a question regarding the programming into an indicator of the spread of the candlestick. Specifically the high and low of that bar.

What I want is a way for the indicator to be able to detect what is a wide spread bar vs average spread bar vs low spread bar.

The problem of calculating the average spread is that during a volatile period the average spread is high and in non volatile period the average spread is lower. So a bar which could be termed as a wide spread bar in non volatile times could become a average or even narrow spread bar in volatile times.

Any suggestions that can be applied to programming of an indicator?

Thanks,

- forexmmm

6099

forexmmm:

Hi,

I have a question regarding the programming into an indicator of the spread of the candlestick. Specifically the high and low of that bar.

What I want is a way for the indicator to be able to detect what is a wide spread bar vs average spread bar vs low spread bar.

The problem of calculating the average spread is that during a volatile period the average spread is high and in non volatile period the average spread is lower. So a bar which could be termed as a wide spread bar in non volatile times could become a average or even narrow spread bar in volatile times.

Any suggestions that can be applied to programming of an indicator?

Thanks,

- forexmmm

Use standard deviations rather than means or averages

Use quartiles

Use a volatility filter

Use a long look back

Many ways to do it and the logic you finally use is what will be the heart of your indicator/EA.

There's no shortcut to trial and error.  How you finally solve the problem will become part of your "coder personality"  :-)

Oh, I suggest a google on terms such as financial statistics, averages, means, quartiles, standard deviations etc.

Have fun! :)

190
forexmmm
Stuart Browne:

Use standard deviations rather than means or averages

Use quartiles

Use a volatility filter

Use a long look back

Many ways to do it and the logic you finally use is what will be the heart of your indicator/EA.

There's no shortcut to trial and error.  How you finally solve the problem will become part of your "coder personality"  :-)

Oh, I suggest a google on terms such as financial statistics, averages, means, quartiles, standard deviations etc.

Have fun! :)

Thanks for the advice. Will definitely look into that.
6099

forexmmm:
Thanks for the advice. Will definitely look into that.
Welcome :)
6099

As discussed on PM, here's some very quick and dirty code for a basic weighted volatility filter:

```      double LogNormalReturnForecast=MathLog(Close[1]/Close[2]);
double LogNormalReturnActual=MathLog(Close[0]/Close[1]);
double VolatilityPlot=(LogNormalReturnForecast*0.35)+(LogNormalReturnActual*0.65);
```

Compare the results with long term volatility (which is usually around 1).

Further research can be found by searching for such things as GARCH and Log Normal Returns. Hope it helps!