dzony: overall profit would reach 10 pips... that EA close only one trade which was taken from the chart on which EA was activated
- Are you converting overallprofit from pips to ticks (profit1/2.)?
- Your close() uses predefined variables They are only for the current pair.
if(OrderType()==OP_BUY) pricee=Bid; if(OrderType()==OP_SELL) pricee=Ask;
- MODE_TRADES is ignored when selecting by ticket.
void close(int ticket){ if(OrderSelect(ticket,SELECT_BY_TICKET)){ OrderClose(ticket,OrderLots(),OrderClosePrice(),20); } }
- If you restart the terminal (power failure, etc) you've lost the values of position1/2. Do you recover?
- What are Function return values ? How do I use them ? - MQL4 forum
pricee=MarketInfo("YourSymbol", MODE_BID);
if(OrderType()==OP_SELL)
pricee=MarketInfo("YourSymbol", MODE_ASK);
or even better
OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 20);
qjol:
pricee=MarketInfo("YourSymbol", MODE_BID);
if(OrderType()==OP_SELL)
pricee=MarketInfo("YourSymbol", MODE_ASK); or even better ... | Problem is it's not "YourSymbol" but multiple symbols from multiple orders. pricee=MarketInfo(OrderSymbol(), MODE_BID);
if(OrderType()==OP_SELL)
pricee=MarketInfo(OrderSymbol(), MODE_ASK); Unnecessary with OrderClosePrice() |
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,
i am trying to write a simple EA, which will close two specified trades when net profit from them both reach specified value. For example i bought EURCAD and sold USDCAD and i want EA to close them both when overall profit would reach 10 pips. I have written that code below but there is a problem. That EA close only one trade which was taken from the chart on which EA was activated. I will appriopriate any clues. (I'm really noob, this is my first EA ever)