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