automatic order closing - page 2

 
Alain Verleyen:

What is "x" ?

I think it should be Sx ? (not sure now how in the heck works with x either... but it works ... engineering paradox ... )

Note: without RefreshRates is not working at all... cross my heart ... 


Appreciated for all your help !

 
Seng Joo Thio:

Curiously, I wrote these few lines in the hope of finding out whether OrderClosePrice() "refreshes" the price it returns... 

I run this EA, then randomly open any buy or sell order... and I realized that they get closed regardless... no error at all... which seemed to imply that OrderClose() function ignores the close price supplied... you guys know why?


Update: (1) Right, different behavior for different broker, and (2) Found a broker that does not ignore the close price, and it is apparent that OrderClosePrice() DOES return the latest price - no need to call RefreshRates().

so that code doesn't require RefreshRates ? how come ? in the code i provided is not working without it... what is the actual difference ?

appreciated Seng !

 
CB:

so that code doesn't require RefreshRates ? how come ? in the code i provided is not working without it... what is the actual difference ?

Getting mysterious... LOL

Here's a small portion of the log from my test yesterday (notice that the price value (last column) does change, despite not calling RefreshRates() and not exiting from the infinite loop (which should be sufficient proof that OrderSelect()+OrderClosePrice() will return updated prices)):

0       09:11:06.963    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:07.972    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:08.982    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:09.991    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:11.000    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:12.010    TestOrderClosePrice GBPUSD,H1: 129, 2.42798
0       09:11:13.019    TestOrderClosePrice GBPUSD,H1: 129, 2.42798
0       09:11:14.028    TestOrderClosePrice GBPUSD,H1: 129, 2.42798
0       09:11:15.038    TestOrderClosePrice GBPUSD,H1: 129, 2.42798
0       09:11:16.047    TestOrderClosePrice GBPUSD,H1: 129, 2.42798
0       09:11:17.056    TestOrderClosePrice GBPUSD,H1: 129, 2.42798
0       09:11:18.065    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:19.074    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:20.084    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:21.093    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:22.102    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:23.111    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:24.121    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:25.132    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:26.141    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:27.150    TestOrderClosePrice GBPUSD,H1: 129, 2.42796
0       09:11:28.159    TestOrderClosePrice GBPUSD,H1: 129, 2.42794
0       09:11:29.168    TestOrderClosePrice GBPUSD,H1: 129, 2.42794
0       09:11:30.177    TestOrderClosePrice GBPUSD,H1: 129, 2.42798
0       09:11:31.186    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:32.195    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:33.204    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:34.214    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:35.223    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:36.232    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:37.241    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:38.250    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:39.259    TestOrderClosePrice GBPUSD,H1: 129, 2.42802
0       09:11:40.268    TestOrderClosePrice GBPUSD,H1: 129, 2.42794

But I suppose there is no harm calling RefreshRates() too, especially if it works for you...

 
Seng Joo Thio:

Getting mysterious... LOL

Here's a small portion of the log from my test yesterday (notice that the price value (last column) does change, despite not calling RefreshRates() and not exiting from the infinite loop (which should be sufficient proof that OrderSelect()+OrderClosePrice() will return updated prices)):

But I suppose there is no harm calling RefreshRates() too, especially if it works for you...

thank you Sir !

Reason: