How? Use 0.1 lots in OrderClose().
Phy,
Thanks for your reply. I guess I didnot explain or write adequately. I will try once more:
1. The EA opens .2 lots in either long or short based on some condition.
2. I need a small code (should I make a function?) which will just check for open positions (whether long or short)orders and see whether the position has made 50+
3. There will be ONLY one position open at a time(.2 either long or short).
4. If the position has made 50+, this small code should just close .1 lot and leave the other .1 running.
If you can point out to any sample/examples of code which incorporate this logic that will be great.
thanks again for your time/help
Thanks for your reply. I guess I didnot explain or write adequately. I will try once more:
1. The EA opens .2 lots in either long or short based on some condition.
2. I need a small code (should I make a function?) which will just check for open positions (whether long or short)orders and see whether the position has made 50+
3. There will be ONLY one position open at a time(.2 either long or short).
4. If the position has made 50+, this small code should just close .1 lot and leave the other .1 running.
If you can point out to any sample/examples of code which incorporate this logic that will be great.
thanks again for your time/help
for(int i = Orderstotal()-1; i >= 0; i--){ OrderSelect(i, SEL_BY_POSITION, MODE_TRADES); if(OrderLots() >=0.2){ if(OrderType() == OP_BUY){ if(Bid > OrderOpenPrice()+50*Point){ OrderClose(OrderTicket(), 0.1, Bid, slippage, aColor); } } if(OrderType() == OP_SELL){ if(Ask< OrderOpenPrice()-50*Point){ OrderClose(OrderTicket(), 0.1, Ask, slippage, aColor); } } } } }
Thanks a lot phy. I guess, I didnot mention that I am trying to use it with Magicno, does using magic no involves some extra coding to the above logic. Thanks again for ur time/reply.
Kent
Kent
is it really technically allowed to close part of lots? I did not know that. So i can open 3 lots and close 1 at time x and close rest at time y from same orderid?
Yes, but you get a new ticket number for the remnants of the original position
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
I am new here. Pretty good forum with generous help! I am writing/testing an EA where I would like to close partial lots.
Assume the trade (long) opened with .2 lots (mini) and after 50 pips I want to close the .1 lot and let the other .1 lot running till a reversal signal occurs in EA where the trade will close and start a new short for .2 lots.
Thanks for your time/replies.
Kent