- how to know last static value(not current just one before)
- how to avoid big ups and downs in current bar?
- I want to improve my ea.not with indicator upgrade but with some tricks.
Set a datetime LastBuyTime when the Buy happens, check if an hours has elapsed since LastBuyTime before you place the next Buy, when you place the next Buy reset LastBuyTime = CurrentTime()
Thank you.Could you write as a code,pls.I think its easier for you.
Thank you.Could you write as a code,pls.I think its easier for you.
I dont know how to identify LastbuyTime.I tried (datetime orderopentime) and print it but it gives unrelated digits.
if(TimeCurrent()>Last_Trade_Time + TimeHour()*4){...Its OK now to place a new order;}
something like here.
All you need to do is set it when you place a Buy trade . . . LastBuyTime = CurrentTime();
datetimes are counted in seconds since 1 Jan 1970 : https://docs.mql4.com/dateandtime
TimeHour() gives an int for a given datetime : https://docs.mql4.com/dateandtime/TimeHour
Instead of TimeHour use PERIOD_H1 : https://docs.mql4.com/constants/timeframes and multiply it by 4 ( for 4 hours ) and then by 60 ( convert to seconds )
I dont know how to identify LastbuyTime.
static datetime lastTradeOpen; : if( decision ){ int ticket = OrderSend(... if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else lastTradeOpen = TimeCurrent(); }
static datetime lastTradeOpen; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- Crepeat=Repeat; //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { . . . if(TimeCurrent()>lastTradeOpen + PERIOD_H1){double xxx=0;} if(xxx==0 ){orderparameter} . . . if(ticket<=0) { Write("Error Occured : "+ErrorDescription(GetLastError())); } else { lastTradeOpen = TimeCurrent(); """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" it didnt work.
It didn't work . . really ?
if(TimeCurrent()>lastTradeOpen + PERIOD_H1){double xxx=0;}
PRIOD_H1 = 60 . . . . so your code says, if the current time > last trade open + 60 seconds . . .
RaptorUK:
Instead of TimeHour use PERIOD_H1 : https://docs.mql4.com/constants/timeframes and multiply it by 4 ( for 4 hours ) and then by 60 ( convert to seconds )
It didn't work . . really ?
PRIOD_H1 = 60 . . . . so your code says, if the current time > last trade open + 60 seconds . . .
RaptorUK:
Instead of TimeHour use PERIOD_H1 : https://docs.mql4.com/constants/timeframes and multiply it by 4 ( for 4 hours ) and then by 60 ( convert to seconds )
PRIOD_H1 = 60 . . . . so your code says, if the current time > last trade open + 60 seconds . . .
Am I going to multiply it by 60 to make an hour?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use