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
Hi Everyone
Sorry, but I spoke too soon. While adding RefreshRates() seem to make a difference, I am still having the same issue. It sometimes open both pending orders, sometimes only one of the two, and sometimes neither. I am still getting error 130 when it doesn't open an order, or both, but no errors when both actually get opened. I also noticed that on those pairs where my inputs are below MODE_STOPLEVEL, it never opens an order and I always have error 130, even though the program adjusts my inputs as requested. I am printing the values and they are adjusted as expected. So I'm trying to figure out why my OrderSend doesn't realy work.
On a pair such as EURUSD where the stoplevel is 5, it usually send both orders, but not always. However on a pair such as EURAUD where the stoplevel is 10, it never sends an order
I have also tried it like this, but it makes no difference:
And even if I do this it makes no difference:
Thanks for all the help Everyone. I finally got it to work. The only way I could get it to work consistently was by changing it to this:
I also figured out that the Pipmove level before the pending order gets activated must also be higher than stoplevel. So everything seems to work now.. Thanks
Thanks for all the help Everyone. I finally got it to work. The only way I could get it to work consistently was by changing it to this:
I also figured out that the Pipmove level before the pending order gets activated must also be higher than stoplevel. So everything seems to work now.. Thanks
The simple answer is not to try to open pending orders so close to the current price. 5 Points is usually half a pip
Thank you for the reply. My calculation is actually in pips, so the pending orders are at least 50 points (5 pips away from the current price), however, it does seem to work if I move it at least 1 pip further away from the stoplevel, which is 50 points on the EURUSD. It apears as if it now opens both trades except for the first one after I drag it onto the chart. But I'm okay with this for now. My code now looks like this:
I ran into a separate but similar problem. Once one of the pending orders get triggered, one of two things could happen. It either triggers the TrailingStop at which point the other pending order gets deleted. or if that trade goes against me it should open a hedge in the opposite direction. Depending on how I write the code, it will either open more than one hedge or no hedge at all. I've tried everething including the following two:
Or:
Should I use a separate for loop for this? Thank you
Hi Everyone
It's been weeks of trying and I still have not made any progress. Everything works now, except that under certain conditions the EA opens more than one hedge trade on the original trade. The SL on the original trade is 11 pips and the SL on the Hedge trade is 9 pips. Sometimes the hedge trade get stopped out at 9 pips while the original trade is still open. It will then open a second hedge trade and even a 3rd and 4th while the original trade is still open. I simply want to limit the amount of hedge trades to one and if it gets stopped out, just wait and see what happens with the original trade.
This is the type of results I get:
576 2015.01.15 11:39 buy stop 29 0.48 1.16786 1.16616 0.00000 0.00 4834.24
577 2015.01.15 11:39 sell stop 30 0.48 1.16642 1.16812 0.00000 0.00 4834.24
578 2015.01.15 11:39 sell 30 0.48 1.16642 1.16812 0.00000 0.00 4834.24
579 2015.01.15 11:39 delete 29 0.48 1.16786 1.16616 0.00000 0.00 4834.24
580 2015.01.15 11:42 buy 31 1.44 1.16743 1.16653 0.00000 0.00 4834.24
581 2015.01.15 11:42 s/l 31 1.44 1.16653 1.16653 0.00000 -129.60 4704.64
582 2015.01.15 11:44 buy 32 1.44 1.16742 1.16652 0.00000 0.00 4704.64
583 2015.01.15 11:44 s/l 30 0.48 1.16812 1.16812 0.00000 -81.60 4623.04
584 2015.01.15 11:48 modify 32 1.44 1.16742 1.16893 0.00000 0.00 4623.04
The buystop and sellstop orders (29 and 30) are opened as they should. The price then drops and the sell order (30) gets filled while the buystop (29) gets deleted. The price then goes up again and the hedge(martingale) order (31) gets triggered (3*lotsize). The price then drops again and the hedge (31) gets stopped out, but because 30 is still open it triggers another hedge (32), etc. How can I prevent order 32 from getting triggered? Thank you
Hi Everyone. Its been more than a month now that I've tried to resolve this and I'm beginning to think that it is programatically impossible to code. So if someone will please confirm this, I can put it to rest and move on. Is it not possible to set a deep level for the number of hedge(martingale) orders as explained in the post above? Thank you.
The best I have so far is:
There are different ways that this can be achieved.
When the hedge is opened, create a Global Variable of the client terminal.
Give it a name that includes the ticket number of the main trade.
Give it a value that acts as a flag that a hedge trade has been opened for that ticket number, or a hedge count if necessary.
Check the GV before opening a hedge.
The hedge and main trade have different lot sizes.
Before opening a hedge, check open orders and history to see if an opposite order has been opened with the relevant lot size with an OrderOpenTime() later than than the main trade's open time.
There are different ways that this can be achieved.
When the hedge is opened, create a Global Variable of the client terminal.
Give it a name that includes the ticket number of the main trade.
Give it a value that acts as a flag that a hedge trade has been opened for that ticket number, or a hedge count if necessary.
Check the GV before opening a hedge.
The hedge and main trade have different lot sizes.
Before opening a hedge, check open orders and history to see if an opposite order has been opened with the relevant lot size with an OrderOpenTime() later than than the main trade's open time.
So I tried to to achieve this through a Global Variable, but since adding this code, it is not opening a hedge trade at all. I think that the issue is that the EA is doing a GlobalVariableCheck, but since none has been created yet, it won't continue. It does, however, select and Print the correct ticket no. Perhaps I'm doing it wrong. Here is the relevant code: