Last Bullish and Bearish candle
Created at 13 Nov 2013, 11:27
Last Bullish and Bearish candle
13 Nov 2013, 11:27
Hello!
Can anyone help me, how to define the actual last bullish and last bearish candle? Even if the latest candle change of direction.
Thanks in advance!
Replies
fzlogic
13 Nov 2013, 14:56
RE:
fzlogic said:
for (int i = index; i > index - Period; i--) if (MarketSeries.Open[i] < MarketSeries.Close[i]) { ChartObjects.DrawText("LL", "LastLong", index, MarketSeries.High[i], VerticalAlignment.Top, HorizontalAlignment.Center, Colors.LimeGreen); break; } }
That one was only for last long.
double lastLong = 0; double lastShort = 0; for (int i = index; i > index - Period; i--) { if (MarketSeries.Open[i] < MarketSeries.Close[i]) { lastLong = MarketSeries.High[i]; ChartObjects.DrawText("LL", "LastLong", i, lastLong, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.LimeGreen); } else if (MarketSeries.Open[i] > MarketSeries.Close[i]) { lastShort = MarketSeries.Low[i]; ChartObjects.DrawText("LS", "LastShort", i, lastShort, VerticalAlignment.Bottom, HorizontalAlignment.Center, Colors.Red); } if (lastLong > 0 && lastShort > 0) break; }
@fzlogic
fzlogic
13 Nov 2013, 14:59
Sorry, that one was also wrong.
This one is correct:
double lastLong = 0; double lastShort = 0; for (int i = index; i > index - Period; i--) { if (lastLong == 0 && MarketSeries.Open[i] < MarketSeries.Close[i]) { lastLong = MarketSeries.High[i]; ChartObjects.DrawText("LL", "LastLong", i, lastLong, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.LimeGreen); } else if (lastShort == 0 && MarketSeries.Open[i] > MarketSeries.Close[i]) { lastShort = MarketSeries.Low[i]; ChartObjects.DrawText("LS", "LastShort", i, lastShort, VerticalAlignment.Bottom, HorizontalAlignment.Center, Colors.Red); } if (lastLong > 0 && lastShort > 0) break; }
@fzlogic
rkokerti
13 Nov 2013, 13:24
Like code below... But it is not too smart / elegant, and it is investigate only 3 candle backward.
I would like to ivnestigate more (min 20) candles. So some FOR/DO/WHILE cycle would be better.
Please help!
@rkokerti