-
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
No free help (2017)Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum (2018)We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
No free help (2017) -
The following might get you started.
When dealing with time, a lot of people use strings; they can not be optimized. Using (int) seconds or (double) hours, or (int) hours and minutes can be.
See also Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
date/time (2017)
Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
Find bar of the same time one day ago - MQL4 programming forum (2017)
i have had many attempts ,at least 20 attempts,i just didnt want others to have complicated ideas while thinking ,maybe sb has an easy way to solve.
here is the main attempt:
int H1730=63000;
int H2330=84600;
int h=Hour();
int m=Minute();
int SecsPassedFromDay=(h*60*60)+(m*60);//ثانیه های گذشته از از دوازده شب
if( Seconds()==0 && SecsPassedFromDay>H1730
&& SecsPassedFromDay<H2330 )//ساعت بعد هفده و سی و قبل بیستو سه و سی و ثانیه صفر هر دقیقه
{
int shiftOPNYinMins=(SecsPassedFromDay+(30*60))/60;//قیمت یازده و نیم شب یعنی باز شدن آمریکا
double ONYP=iOpen(NULL,PERIOD_M1,shiftOPNYinMins);//قیمت یازده و نیم شب در یورویواسیعنی باز شدن
Print("ShiftopnyinMins = ",shiftOPNYinMins);
Print("ONYP = ",ONYP);
Print("Time0 =",Time[0]);
Print("secpasedfromday =",SecsPassedFromDay," > ",H1730," & secpasedfromday= " ,SecsPassedFromDay," <",H2330);
}
-
Please edit your (last) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor -
int h=Hour(); int m=Minute(); int SecsPassedFromDay=(h*60*60)+(m*60);//ثانیه های گذشته از از دوازده شب
Simplifiedint SecsPassedFromDay=time();
date/time (2017)
Find bar of the same time one day ago - MQL4 programming forum (2017) -
if( Seconds()==0 && … int shiftOPNYinMins=(SecsPassedFromDay+(30*60))/60;//قیمت یازده و نیم شب یعنی باز شدن آمریکا
These assume every bar every exists — they don't. What if there are no ticks during a specific candle period? Especially the first second of a new bar. There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
"Free-of-Holes" Charts - MQL4 Articles (2006)
No candle if open = close ? - MQL4 programming forum (2010) -
int H2330=84600; datetime bod=date(); int tod=time(); if(tod < H2330) bod=yesterday(); int shiftM1=iBarShift(_Symbol, PERIOD_M1, bod+H2330); return iOpen(_Symbol, PERIOD_M1, shiftM1);
thank you for your precious time,
my expert is writing, i am looking for ANOTHER solution.
just last question,
my meta4 does not have these two as predefined
datetime bod=date(); int tod=time();
date()
and
time()
how can i get them
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
PLZ help
MQL4
I am writing an expert to buy & sell in direction of open of 22:31 open price of yesterday ,
this is what i want to write:
if time passes 22:30 ,pick 22:31 candle open price & use it as a constant up to tomorrow 22:30,
Can anyone help?