Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
We can't see your broken code.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
We can't see your broken code.
<Deleted>
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
We can't see your broken code.
it seems than I failed to sent the detail code, now I try to sent once more (sorry, this is my first time post in the forum)
<Deleted>
You've been told twice to post your code correctly
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
Including the high-lighted link from William
Please use the code button (Alt+S) when pasting code.
it seems than I failed to sent the detail code, now I try to sent once more (sorry, this is my first time post in the forum)
***
may be can try this:
//extern datetime Day1 = D'2022.06.01 00:05'; datetime barD1; bool tradeNow = false; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { // declare variable for debuging check /* datetime static _static_daytime=0; datetime _Time = Time[0]; if(IsTesting()) { if(CheckEntry(Day1) && (_static_daytime!=Time[0])) { if(OrderSend(NULL,OP_BUY,0.1,Ask,30,0,0,NULL)) {} _static_daytime=Time[0]; } } */ if(barD1!=iTime(NULL,PERIOD_D1,0)){ barD1=iTime(NULL,PERIOD_D1,0); //if(OrderSend(NULL,OP_BUY,0.1,Ask,30,0,0,NULL)) {} tradeNow = true; } //--- if(tradeNow){ //--- tambahkan Trigger utk entry signal if(OrderSend(NULL,OP_BUY,0.1,Ask,30,0,0,NULL)) {} tradeNow = false; } }
if(OrderSend(NULL,OP_BUY,0.1,Ask,30,0,0,NULL)) {}
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum (2020)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear All
I have some problem in getting the Datetime of the lastbar, when I want to memorize the static variable as in iNewBar function, in running backtest it runs ok, so we can avoid over trade, and just only one entry, but when I check using debugging, I found that the date save in static variable is not the current running of the history bar's datetime, but the date of the last bar which appear in the current chart,
for example, the trade begin at 2022-05-01 00:00, and the local time now is 2022-06-10 08:00, so when the first bar time I save in the static variable, in the run of backtest, it's run well that the last bar is 2022-05-01, but when I check using debugging, I see that the static variable not record the 2022-05-01 00:00, instead : 2022-06-10 08:00, so I have using time[[], itime(NULL,0,0), still cannot to get the exact runngin backtest history last bar datetime, instead always the last time of the real time chart, so How to get the really last datetime of the history running last datetime ?
many thank if can solve this problem
thanks, bob