You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hmm so this would be good?
Actually i changed Time[1] to Time[0] because Time[1] was skipping 1 more bar, so Time[0] is actually representing the Open[0].If anyone knows anything better/smoother than this please tell!
Hmm so this would be good?
Actually i changed Time[1] to Time[0] because Time[1] was skipping 1 more bar, so Time[0] is actually representing the Open[0].If anyone knows anything better/smoother than this please tell!
RefreshRates(); OrderClose( OrderTicket(), OrderLots(),OrderClosePrice() ,Slippage,CLR_NONE);
and check also if orderclose succeed
and check also if orderclose succeed
Well if not succeded then when the start() function repeats itself it will test again that if() before the orderclose() and since the conditions will still be true to proceed, it wil try to close it again.I cant try to close it 2 times in the same loop of the start(),must wait another tick no?
Hmm so this would be good?
Actually i changed Time[1] to Time[0] because Time[1] was skipping 1 more bar, so Time[0] is actually representing the Open[0].If anyone knows anything better/smoother than this please tell!
If you want to close as close to the close of the bar then you have to determine if the current tick is the first tick of the new bar . . . . then you also have to make sure you close works because you will only get one chance par bar.
Well if not succeded then when the start() function repeats itself it will test again that if() before the orderclose() and since the conditions will still be true to proceed, it wil try to close it again.I cant try to close it 2 times in the same loop of the start(),must wait another tick no?
you started that it has to close last tick of bar
we tried you to understand not possible to know when last tick bar is coming
now it doesn't matter if closing fails we try again, again,again on following ticks
did you also miss other changes i did suggest
what sense does it make refreshrates after orderclose ??
and do you know why slippage instead of TAKEPROFITPIPS
it depends on the errorreturn you can try to close it 2 times in same loop
if tradecontext too busy and you have more trades inside the loop to close the n great possibillity they fail also
No, this will always close regardless of the tick being the tick of the next bar or not, for any bar following the bar when the trade was opened and any time during that bar Time[0] will always be greater than OrderOpenTime().
If you want to close as close to the close of the bar then you have to determine if the current tick is the first tick of the new bar . . . . then you also have to make sure you close works because you will only get one chance par bar.
Isnt the start() repeat itself after each tick? Am I wrong?
Anyway imagine like this:
OrderOpenTime() = 12:12:01 (12 H 12 MIN 1 SEC)
The order gets opened,the Orderclose() function packet is after my OrderSend() one in the main code so, right after opening the order my OrderClose() packet will test that the conditions did met to close the order or not.Let's say it did now its time to close the order:
Time[0] is the open price of this bar, so by common logic it must be smaller than the time the order was open, because the order cant be opened before the same bar opened.It's: 12:12:00
So by all means :
Will return true value so the orderclose will be triggered.If it cant close it, for any reason, like slippage or so, no problem, the start() repeats itself
And by the next repeat the Time[0] will 100% be bigger than the open time of the order,because its logical, so if the first close fails the other OrderClose() will happen every time afterwards when the start() will repeat itself, and since i think that start() repeats itself by every tick, then i dont think there is a better way to close the order quicker, i hope i explained it clearly :)
you started that it has to close last tick of bar
we tried you to understand not possible to know when last tick bar is coming
now it doesn't matter if closing fails we try again, again,again on following ticks
did you also miss other changes i did suggest
what sense does it make refreshrates after orderclose ??
and do you know why slippage instead of TAKEPROFITPIPS
it depends on the errorreturn you can try to close it 2 times in same loop
if tradecontext too busy and you have more trades inside the loop to close the n great possibillity they fail also
Isnt the start() repeat itself after each tick? Am I wrong?
Yes, start() is called for each tick unless it is still executing . . .
Anyway imagine like this:
OrderOpenTime() = 12:12:01 (12 H 12 MIN 1 SEC)
The order gets opened,the Orderclose() function packet is after my OrderSend() one in the main code so, right after opening the order my OrderClose() packet will test that the conditions did met to close the order or not.Let's say it did now its time to close the order:
Time[0] is the open price of this bar, so by common logic it must be smaller than the time the order was open, because the order cant be opened before the same bar opened.It's: 12:12:00
So by all means :
Will return true value so the orderclose will be triggered.If it cant close it, for any reason, like slippage or so, no problem, the start() repeats itself
And by the next repeat the Time[0] will 100% be bigger than the open time of the order,because its logical, so if the first close fails the other OrderClose() will happen every time afterwards when the start() will repeat itself, and since i think that start() repeats itself by every tick, then i dont think there is a better way to close the order quicker, i hope i explained it clearly :)
It is quite rare for the close price of a bar not to be repeated on the susequent bar, not neccessarily its open price ...