I need help, I would like to shut the order at closing of the same pub of open position.
There's a way to do this?
Thanks.
Lubo
I need help, I would like to shut the order at closing of the same pub of open position.
There's a way to do this?
Thanks.
Lubo
Try do so on open bar that is next, for example, you opened place when new candle if progresses, or has lit, and you want to close at close of THE exact same bar or onto receptive of new one. Use this portion of code (the factors, their initalize and reset worth you may resolve, I expect. That is really for 1hr charts, the daily has the similar logic
if (pos_open==authentic Hour() == OpenHour 1)
OrderClose(ticket,...,...,...,.... Blah blah)
The bool var pos_open you will manage by OrderSelect and OrderCloseTime ==0, as true, else false
The var OpenHour you initialize at the IF figure where you start the place
(Instance:
if(pos_open==false ...) //your entry rules
OrderSend(NULL, OP_BUY, Lots, Ask, 0, Bid-SLNULLStage, Bid PT*Stage);
OpenHour=Hour();
It's clear and understandable?
P.S. for Daily, or alternative TF you can use the similar logic, replace just Hour() Minute() or dawn() - as new candle lights
Thank you to this code, and I think it's much better gt;= instead ==
I've tried this.
If(TimeCurrent() gt;= Time[0] (Stage() * 60 - 1)) ....Close Trade
However, I still become orderclose mistake 138....requote, '' I do not understand why. .
Any ideas?
Lubo.
Gt;= possibly better than ==, however the order you close only once, so that is irrelevant, what you wrote it... you will acquire orderclose error when you realize close by elseway (SL, PT hit, for example), or even the EA is looking near position with wrong ticket amount. Try re-check the orderSelect passing, and attempt recompile without it, simply try attempt/error. I now work on another PC, where I've not some functionable EA, out of.
I had here only right OrderSelect, You Might edit it for your needs
if(OrderSelect(position1,SELECT_BY_TICKET)==true)
OrderSelect(position1, SELECT_BY_TICKET);
if(OrderCloseTime() ==0)
total1=1;
else
total1=0;
else total1=0; //nikdy pozice 1 nebyla
if(OrderSelect(position2,SELECT_BY_TICKET)==true)
OrderSelect(position2,SELECT_BY_TICKET);
if(OrderCloseTime() ==0)
total2=1;
else
total2=0;
else total2=0;
EDIT: the re-quote you attempt slove from the slippage debate
I think is rilevant coz if the second pub is missed the position isn't closed...Originally Posted by ;
Yes, I agree, this I relevanton M1 or similar charts, on greater TF (for instance 1hr) you've usualy more than 500 tick, so the EA calls the start() work more than 500 times. We were disunderstood about TF which you just play But, you're right, the operator more than or equivalent is more protected wiritingOriginally Posted by ;
Were you solve the issue with closing place??
Another (maybe stupid) idea: I'd once upon a time a issue with similar signs as yours (OrderSend Error : (I think) 128) - I tried all what's possible - nothing, errors still occurs. I was get mad (very, very upset) the code, what and where it remained I erased and entrie EA re-wrote. The code appears identically, but in older was problem or a hidden error. To current days I do not know where, but by this (extreme) process I solved.
If you don't see some manner, attempt return on beginning you manner and procced step-by-step
Sorry, my English is horrible, but I expect you can understood it. (And I must do anything with it )