View Single Post
pending orders
  #2 (permalink)  
Old 11-15-2007, 03:15 PM
pgtips pgtips is offline
Freshman
 
Join Date: Mar 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
pgtips is on a distinguished road
Default pending orders

Hi Guru's

Could someone possibly help me with this bit of code:

I've defined as user input
extern double high_price = 2.0500;
and opp for low
extern double low_price = 2.0400;

using this I can calculate the distance from the current price that i want to place pending orders.

For some reason when I do the calculations for distanceh or distancel (see below) it goes wrong, it won't place an order BUT if I tell it the distance as external double distance = 15; it is ok.

Code:

int start()
{
int ticket,distanceh,distancel;
string hcomment = "place pending";
distanceh = (high_price - Bid); //works out distance from current price for pending buystop
distancel = (Ask - low_price); // vice versa for sell stop

ticket=OpenPendingOrder(OP_SELLSTOP,lots,distancel ,5,stoploss,takeprofit,hcomment);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES )) Print("Pending " + GetOrderType(OrderType()) + " order opened : ",OrderOpenPrice());
}
else Print("Error opening Pending " + GetOrderType(OrderType()) + " order : ",GetLastError());

ticket=OpenPendingOrder(OP_BUYSTOP,lots,distanceh, 5,stoploss,takeprofit,hcomment);
if(ticket>0)
{



any help very appreciated. It doesn't seem to like the output from the calculation so not going any further. I'm also wondering if the price format has anything to do with it, i.e number of decimal places possibly

Many thanks
KevM
Reply With Quote

Registered members have access to special online forex currency trading tools, software, mt4 expert advisors and indicators. Register now

Main Menu

Economic Forecast