Replies

CobainsCat
29 Jul 2013, 12:53

RE:
atrader said:

Hi,

To identify the previous bar below the 20 ema you can compare the price (open, close, high, low whichever you want)  to the ema. 

e.g. if ( MarketSeries.High[index-1] < ema.Result[index-1] ) 

where ema is: private ExponentialMovingAverage ema; 

initialized in the Initialize() method:

e.g. ema = Indicators.ExponentialMovingAverage(MarketSeries.Close, 20);

To see if it is a bear bar you compare the open to close

e.g. if ( MarketSeries.Open[index-1] > MarketSeries.Close[index-1]

You can do the same for as far back as you want with a loop

for (int i = index - Period; i < index; i++)
            {
                var lastBarBelowEma = MarketSeries.High[i - 1] < ema.Result[i - 1];
                var lastBarBear = MarketSeries.Open[i - 1] > MarketSeries.Close[i - 1];
                var priceActionWithinLastBar = MarketSeries.High[i] < MarketSeries.High[i - 1] &&
                                               MarketSeries.Low[i] > MarketSeries.Low[i - 1];

                if (lastBarBelowEma && lastBarBear && priceActionWithinLastBar)
                {
                    double yValue = MarketSeries.High[i] + Symbol.PipSize*2;

                    ChartObjects.DrawText("objectName", "Yes", i, yValue, VerticalAlignment.Center,
                                          HorizontalAlignment.Center, Colors.Red);
                }

            }

You can do something the equivalent with bars above ema.

Hope it helps.

Hi ATrader, 

Thank you very much for the kind response. I will give this a go.

Glenn


@CobainsCat

CobainsCat
16 Jun 2013, 12:49

RE:
cAlgo_Fanatic said:

The cAlgo.API.dll may be referenced within your Vistual Studio solution. It is located in the same folder as the cAlgo.exe file.

See also: /forum/cbot-support/211

Thanks! :)


@CobainsCat

CobainsCat
11 Jun 2013, 11:59

Anyone?

 


@CobainsCat