Forex
Google

Go Back   Forex Trading > Discussion Areas > Documentation
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-01-2007, 02:39 PM
gigiyoffee gigiyoffee is offline
Member
 
Join Date: Sep 2006
Posts: 14
gigiyoffee is on a distinguished road
programming problem...!

hi,
does anyone knows, in an expert advisor, to program the "OrderSend()" function to open a trade on a symbol different from the one in which the ea is loaded?
thanks in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-10-2007, 11:27 PM
ryanklefas's Avatar
ryanklefas ryanklefas is offline
Senior Member
 
Join Date: Apr 2006
Location: USA
Posts: 440
ryanklefas is on a distinguished road
Quote:
Originally Posted by gigiyoffee
hi,
does anyone knows, in an expert advisor, to program the "OrderSend()" function to open a trade on a symbol different from the one in which the ea is loaded?
thanks in advance.

OrderSend(NULL, 0.... )


"NULL" specifies the pair for the order. Null means the current pair. You can put any string (that corresponds to a pair, such as GBPUSD) in there.
__________________
"Don't work harder, work smarter." -- my Java professor

Coder for Hire:
http://www.firecell-fx.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-20-2007, 03:30 PM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Quote:
Originally Posted by ryanklefas
OrderSend(NULL, 0.... )


"NULL" specifies the pair for the order. Null means the current pair. You can put any string (that corresponds to a pair, such as GBPUSD) in there.

I thought you also had to use the market info function, I know this works:

extern string paircharta="EURUSD";//whatever symbol you want

tradeticketa = OrderSend(paircharta,OP_BUY,lotsize,MarketInfo(pai rcharta,MODE_ASK),slippage,MarketInfo(paircharta,M ODE_ASK)-stoploss*MarketInfo(paircharta,MODE_POINT),MarketI nfo(paircharta,MODE_ASK)+takeprofit*MarketInfo(pai rcharta,MODE_POINT),"orderstart",magica,0,Blue);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-20-2007, 05:43 PM
ryanklefas's Avatar
ryanklefas ryanklefas is offline
Senior Member
 
Join Date: Apr 2006
Location: USA
Posts: 440
ryanklefas is on a distinguished road
Quote:
Originally Posted by wolfe
I thought you also had to use the market info function, I know this works:

extern string paircharta="EURUSD";//whatever symbol you want

tradeticketa = OrderSend(paircharta,OP_BUY,lotsize,MarketInfo(pai rcharta,MODE_ASK),slippage,MarketInfo(paircharta,M ODE_ASK)-stoploss*MarketInfo(paircharta,MODE_POINT),MarketI nfo(paircharta,MODE_ASK)+takeprofit*MarketInfo(pai rcharta,MODE_POINT),"orderstart",magica,0,Blue);
Well, that is the complicated way to do it.
__________________
"Don't work harder, work smarter." -- my Java professor

Coder for Hire:
http://www.firecell-fx.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-21-2007, 12:15 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Quote:
Originally Posted by ryanklefas
Well, that is the complicated way to do it.
Seems like there is always an easier way, I usually don't learn it until too late!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-21-2007, 03:23 AM
dermusic dermusic is offline
Junior Member
 
Join Date: Mar 2007
Posts: 27
dermusic is on a distinguished road
Try something like the code posted below:

Code:

extern double Lots1=0.2;
extern double Lots2=0.1;
extern int StopLoss =50;
extern int TakeProfit=100;

int Slippage= 3;
int MagicNumber =123;
bool MySignal=false;



string Symbol1,Symbol2;
double orderprice;


int start()
{



Symbol1="USDCHF", Symbol2="GBPUSD";  //remember to put an "m" in if 
                                     //using an Interbankfx mini account, like "GBPUSDm"

if (MySignal==true)
     {
      if(IsTradeAllowed()==true)
          {
          sl=StopLoss*MarketInfo(Symbol1,MODE_POINT):
          tp=TakeProfit*MarketInfo(Symbol1,MODE_POINT):
          orderprice=MarketInfo(Symbol1,MODE_ASK);
          OrderSend(Symbol1,OP_BUY,Lots1,orderprice,Slippage,orderprice-sl,orderprice+tp,"",MagicNumber,0,Blue); 
          }
          {
          sl=StopLoss*MarketInfo(Symbol2,MODE_POINT):
          tp=TakeProfit*MarketInfo(Symbo2,MODE_POINT):
          orderprice=MarketInfo(Symbol2,MODE_ASK);
          OrderSend(Symbol2,OP_BUY,Lots2,orderprice,Slippage,orderprice-sl,orderprice+tp,"",MagicNumber,0,Blue);
          }
          return(0);
     }



}

Last edited by dermusic : 05-21-2007 at 09:23 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-21-2007, 03:52 AM
wolfe's Avatar
wolfe wolfe is offline
Senior Member
 
Join Date: Jan 2006
Posts: 673
wolfe is on a distinguished road
Nice code dermusic, I like that!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Help In Programming Ea Goen Questions 0 05-04-2007 07:18 PM
Programming My First EA - - - ???? resalin Setup Questions 4 05-03-2007 03:06 PM
programming problem...! gigiyoffee Metatrader 4 2 05-01-2007 06:36 PM
programming Problem munait Metatrader 4 3 03-06-2006 09:45 AM


All times are GMT. The time now is 10:04 AM.