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
In order to make a certain set of triggers open trades in both directions (yes, it makes no sense opening trades in both directions with only one set of triggers, I know), do you need to use magic numbers (if magic numbers are required, where should I go to read about them?)? I have modified a sample EA that was on this site to read like this. How would I make this open trades in both directions simultaneously?
// check for long position (BUY) possibility
if(MacdCurrent>0 && MacdPrevious<0)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-SL*Point,Ask+TakeProfit*Point,"macd sample",16384,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
// check for short position (SELL) possibility
if(MacdCurrent>0 && MacdPrevious<0)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+SL*Point,Bid-TakeProfit*Point,"macd sample",16384,0,Red);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
return(0);
}