First Candle of the Day, Locate and Identify???
-
Can anyone help me understand how I can locate and identify if the 1st candle of the day, regardless of the Timeframe, is Bullish or Bearish?
-
https://fxdreema.com/shared/E8yo27G2c this is a project test.
-
That depends on the timeframe. The first on the daily timeframe is the only one available on chart, whereas on 1M there will be many more. What TF is the EA supposed to be working on?
-
@l-andorrà
How does it depend on the timeframe? In my view it doesn't depend on the TimeFrame, because I'm talking about locating the (First) candle that happens in the Timeframe, it doesn't matter if it's in m1, or h1, or h4, I would like to plot an arrow under the first candle that opens and keep the arrow there, and I wanted to identify what the ID of that candle is.
Next I would just identify if that candle is a (bullish) or (bearish) candle.
But I managed to do it in a different way, I'm validating it to see if it's right in the real market. -
There are two useful functions to locate candles: iTime and iBarShift.
This should work
https://fxdreema.com/shared/PLxU6Cwed -
@roar thanks... I got it but otherwise, follow the link.
https://fxdreema.com/shared/E8yo27G2c -
Explaining...
First I have to know what time the market starts, so I used (once a day).
Then I draw an arrow to identify that particular candle at the time the (market opens) on that particular asset.
And finally, I created a condition to identify whether the closing of the current candle is greater than the opening of the current candle, if so it is a green candle, if not it is a red candle. -
Correct Project is here... https://fxdreema.com/shared/MgHR863pe
-
Congrats for the second version of the structure. It is more efficient than the previous one. And BTW, the 'pass' block on top can be removed. It is redundant.
-
@roar Your code is identifying whether it is a bullish or bearish bar on the D1 timeframe.
What I needed is to identify if it's a bullish or bearish bar on the timeframe I'm using at the moment, it doesn't matter if it's m1, h1 or monthly.
He has to be able to look at the first bar and see, if it's green it's bullish if it's red it's bearish, and for that he needs to wait for this first bar to be closed to confirm. -
@OntradingX I tried to use current timeframe, but there was an error with the quick example I made.
Here's corrected code:
int openid_current_tf = iBarShift(NULL, 0, iTime(NULL, PERIOD_D1, 0)); if(iClose(NULL, 0, openid_current_tf) > iOpen(NULL, 0, openid_current_tf)) Comment("Today started with a BULL candle"); else Comment("Today started with a BEAR candle");
-
@roar
I believe it is still not right according to what I wanted to say.
Notice my project, I am using a block of (once per day) and putting 1 hour ahead of the market start.
Then, as soon as this block is triggered, I identify which candle is (previous) so I put a condition?:- If the closing price of the candle was > than the opening price then it is a candlestick (green|bullish), otherwise it is a candlestick (red|bearish).
Then I just plot arrows to guide which direction is the (first candle that happened at the market opening).
Your code from what I understand and tested it at certain times is confusing what is a candle (green | bullish) and what is a candle (red | bearish). Also place an arrow to observe this.
- If the closing price of the candle was > than the opening price then it is a candlestick (green|bullish), otherwise it is a candlestick (red|bearish).
-
@OntradingX
The first bar could be identified as :iBarShift(NULL, 0, 0) = iBarShit(NULL, PERIOD_D1, 0)
That means the starting time of the current bar in the current chart should be the same as that in a daily chart.
Then you could use whatever chart technique to highlight it.
-
@roar Just curious. Could I use this custom code to confirm if a trade was open in any candle different from the current one, ie on candle ID 1 or bigger?
-
@OntradingX I dont know what to tell you man, I tested it and it sure seems to work.
This code doesnt rely on some specific execution time, you can run it at any point of the day, and it always tells the correct candle.
-
@l-andorrà yes, you can use the time value of trade open or trade close inside the ibarshift function
