How Code Price of EMA at Specific Time ?
Page 1 of 732 12 LastLast
Results 1 to 10 of 311

Thread: How Code Price of EMA at Specific Time ?

  1. #1
    Dearforexsoutheast.asiareader... anybody can write Price of EMA at particular time into EA. .

    This detail of my question :

    1. Time frame 1 hour.
    2. EMA 25, Price Close HL2.
    3. Fixed Time for EMA let say at 02.00 server.

    The best way to code it. . .remember its not price of bar chart... however Price EMA lineup at the point ( 02.00 ) only.

    Anybody know mql coding, please help... Thanks.

  2. #2
    Quote Originally Posted by ;
    How to code it. . .remember its not price of bar chart... however Price EMA line at the time ( 02.00 ) only.

    Anyone know mql coding, please help... Thanks.
    IBarShift() will provide you the bar offset (how many bars back at the designated interval) that is closest to some time (period given as POSIX timestamp, see the reference documentation for date and time functions).

    Use this number returned with iBarShift() since the shift parameter in your call to iMA().

  3. #3
    7bit... do you have sample code for it... Please upload..here.

  4. #4
    Perhaps reader can help me, write code concerning my query within 1st post. . ?

    Thanks...

  5. #5
    How about

    if (Hour()==2) emaprice=iOpen(Symbol(),PERIOD_H1,0);

  6. #6
    Quote Originally Posted by ;
    ... do you have sample code for it... Please upload..here.
    No.

    You're asking the wrong questions. If you are familiar with programming you should be able to translate the theories into code yourself.

    If you would like to instantly get the EMA worth of the previous time it was two o'clock then you have several options, based on what you wish to do.

    Each of the functions starting with a lower instance I have a shift as last parameter so the number of bars back in the current pub on the specified timeframe.

    Times for the time works are always given as POSIX timestamps, they're seconds since a predetermined date in the remote past, and that means you can just add and subtract multiples of 60 or even 3600 to move forwards and backward in increments of minutes or hours to make new timestamps.

    You could use iTime(Symbol(), PERIOD_H1, 0) then use TimeHour() to get the specific timestamp and hour of day of the current H1 pub, then use that (and TimeMinute()) to construct a new timestamp for the specific moment as it was two o'clock or just use the gap to the current hour of day directly as an offset (shift parameter) for the H1 bars.

    If you have found your H1 pub for two o'clock by simply chosing an offset on the H1 chart it is possible to utilize iTime() on this pub to get it's accurate timestamp and iBarShift() to translate that into an offset for other timeframes.

    In the cases you need to perform additional checks to rule out special cases on sunday nights following weekends.

    Another choice is simply let it run and wait until it's exactly 2 o'clock by assessing the current period on each tick and behave (save the current EMA worth someplace) only when Hour() returns 2 for the very first time (store the last returned value of Hour() someplace to behave only when it actually changed).

    If all the above is way over your head and you don't have any idea how to express such things in code then you should first find programming simple hello world progr in simpler to use languages and find out formulating algorithms and expressing them in code. You would not be helped by giving you only a few lines of code that you understand.

    Either you can quickly start fishing if I tell you in which the water is or you have to learn the skill of fishing first. Just asking the others for broiled fish everytime you are hungry won't assist you.

  7. #7
    Quote Originally Posted by ;
    No.

    You're asking the wrong questions. If you are familiar with programming you should be able to interpret the theories.

    If you want to instantly get the EMA value of the previous time it was 2 o'clock then you've got multiple alternatives, depending on what you want to do.

    Each of the functions beginning with a lower case I have a shift as last parameter which means the number of bars back from the current pub on the designated timeframe.

    Times for your time functions are always given as POSIX timestamps, they...
    Anyway thanks for your answer. . I'm only beginning to find out mql couple of month coding.

    I found a simple EA that order with price breakout out of fx forum. After I do research and backtest it. . I see if using EMA at specific time for filter / - range pips..result better.

    Most EA code forum. . Mostly use indior then employed to current price or open bar chart for take decision. . .so its completely different with what I need...

  8. #8
    Quote Originally Posted by ;
    How about

    if (Hour()==2) emaprice=iOpen(Symbol(),PERIOD_H1,0);
    Its price of available pub period 1 hour. . .at 2 o'clock.

    What I need is price of EMA lineup at two o'clock. Price can be above, below or maybe near of bar. .

  9. #9
    Quote Originally Posted by ;
    Its price of open pub span 1 hour. . .at 2 o'clock.

    What I want is price of EMA lineup at 2 o'clock. Price can be above, maybe near or below of pub. .
    Then only use iMA() with appropriate parameters for period and type instead if iOpen() to get the value of this MA instead of the pub open price.

  10. #10
    Quote Originally Posted by ;
    Actually I'm only starting to find out mql coding past couple of month.
    You need to learn coding (not mql-coding) first. By communiing I mean all the general theories of how to approach problems, how to compose down the solutions in a way that a computer can understand, how to debug whats going wrong, how to look at the code and measure it as a computer could perform.

    More or less any other language is much better suited than mql for this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.