Read the book or the Documentation (links at the top!).
Look for the examples of opening orders.
Study the sample EAs in the Expert folder how they set their prices for OrderSend(..)
Search for other examples...
You are mixing apples and oranges. Ask/Bid are the current chart pair but you are opening a USDCHF pair. Fails if the current chart is not USDCHF | double price=Ask; : // int ticket=OrderSend("USDCHF",OP_BUY,1,price, ... int ticket=OrderSend(NULL, OP_BUY,1,price, |
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 try to open order with OrderSend function. But it makes error code 136
Code that i use
void OnStart()
{
//---/--- get minimum stop level
double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
Print("Minimum Stop Level=",minstoplevel," points");
double price=Ask;
//--- calculated SL and TP prices must be normalized
double stoploss=NormalizeDouble(Bid-10*Point,Digits);
double takeprofit=NormalizeDouble(Bid+10*Point,Digits);
Print("price ", price);
Print("stoploss ", stoploss);
Print("takeprof ", takeprofit);
Print("Ask ",Ask);
Print("Bid ", Bid);
//--- place market order to buy 1 lot
int ticket=OrderSend("USDCHF",OP_BUY,1,price,1000,stoploss,takeprofit,"My order",16384,0,clrGreen);
Print("ticket ", ticket);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
}
else
Print("OrderSend placed successfully");
}
Any assistance will be appriciated