Hour(), Minutes(), & Seconds() are integer based.
You should use datetime based, against TimeCurrent().
Thanks for the reply,
How would something like that work then?
I mean my logic was that I can write: if at time of starthour the price is above the close of (starthour-1) then OrderSend.
How would the datetime based variables fit in here?
Thanks!
Thanks for the reply,
How would something like that work then?
I mean my logic was that I can write: if at time of starthour the price is above the close of (starthour-1) then OrderSend.
How would the datetime based variables fit in here?
Thanks!
I changed it into the following:
It gives me the high of te candle at 9.00
What do you think?
if(Ask > iHigh(NULL,0,iBarShift(NULL,0,(TimeCurrent()-(TimeCurrent()-(60*60*(Hour()-9))))))) TicketnumberB = OrderSend(Symbol(), OP_BUY, Lots, Ask, 5, BStoplossPrice, BTakeProfitPrice,NULL); if(Bid < iLow(NULL,0,iBarShift(NULL,0,(TimeCurrent()-(TimeCurrent()-(60*60*(Hour()-9))))))) TicketnumberS = OrderSend(Symbol(), OP_SELL, Lots, Bid, 5, SStoplossPrice, STakeProfitPrice,NULL);
I changed it into the following:
It gives me the high of te candle at 9.00
What do you think?
Something like this
datetime HourMin(int pHour = 0, int pMinute = 0) { MqlDateTime timeStruct; TimeToStruct(TimeCurrent(),timeStruct); timeStruct.hour = pHour; timeStruct.min = pMinute; datetime useTime = StructToTime(timeStruct); return useTime; }
then call it on void OnTick()
void OnTick() { if(TimeCurrent()==HourMin(9,0)) { // your order function } }
just pseudocode, but you should figure it out.
if( TimeCurrent() >= StringToTime("09:00") ) ... // or #define HR0900 32400 // 9*3600 if( TimeCurrent() >= date()+HR0900 ) ...
Do not double post
I have deleted your other post

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All,
Im rather new here and I want to create a simple system where I look at the high and low of the first 1 hour candle at a start time (in this case 9.00).
If after this first 1 hour the rate goes above the high, than sell. If it goes below the low than sell.
What I did so far is the following:
Also Im trying to find a code that closes my trade at the end of each day (at 23.59) no matter what. It seems simple but I tried many things but couldnt find anything.
Thanks for the help!
JB