EMA on Close

 
I'm writing an EA based on EMA crossover. I want it to calculate EMA only on today's close, so if "buy" or "sell" signal occured, it trades by tomorrow's open. Please help. Thank you.
 
See values of an indicator on first tick of new bar.
 
Thank you, but sorry, I don't understand what you mean. I'm not programmer, and just learning MQL4 for the last few months. See how? Thanks.
 

Rosh: See values of an indicator on first tick of new bar.

Transliteration: When the first tick of the new day comes, make your decision based on the last bar of the old day.

"I want it to calculate EMA only on today's close"

To be precise, there is no "close" for today, only the current price

"so if "buy" or "sell" signal occured, it trades by tomorrow's open"

Tomorrow isn't here yet.

What you should be saying, and programming is this:

"I want to calculate EMA on yesterday's close, so if "buy" or "sell" signal occurred, it trades by today's open. Please help"

Ok, here is the rest of the help

int dayNumber;
 
int init(){
   dayNumber = TimeDayOfYear(Time[0]);
}
 
int start(){
   
   if(dayNumber != TimeDayOfYear(Time[0])){
      dayNumber = TimeDayOfYear(Time[0]);
      // first tick of new day is detected
      // do your calculation and make your decision based on indicator value calculated for yesterday's close
 
phy:

Rosh: See values of an indicator on first tick of new bar.

Transliteration: When the first tick of the new day comes, make your decision based on the last bar of the old day.

"I want it to calculate EMA only on today's close"

To be precise, there is no "close" for today, only the current price

"so if "buy" or "sell" signal occured, it trades by tomorrow's open"

Tomorrow isn't here yet.

What you should be saying, and programming is this:

"I want to calculate EMA on yesterday's close, so if "buy" or "sell" signal occurred, it trades by today's open. Please help"

Ok, here is the rest of the help

int dayNumber;
 
int init(){
   dayNumber = TimeDayOfYear(Time[0]);
}
 
int start(){
   
   if(dayNumber != TimeDayOfYear(Time[0])){
      dayNumber = TimeDayOfYear(Time[0]);
      // first tick of new day is detected
      // do your calculation and make your decision based on indicator value calculated for yesterday's close
Thanks, Phy.

I tried, it doesn't work. But it's okay, I have other solution in mind instead of EA trade on the open of the next bar. Will you please check it out.

Thanks again.