orderStopLoss() = 1

 

Hi,

I have a problem in coding Trailing Stop Loss.

if (OrderSelect(u,SELECT_BY_POS,MODE_TRADES))

{

double stoploss = OrderStopLoss();

int ticket = OrderTicket();

double priceopen = OrderOpenPrice();

double takeprofit = OrderTakeProfit();

int typ = OrderType();

Alert ("stoploss:",stoploss," ticket:", ticket," priceopen:", priceopen," takeprofit:",takeprofit);

(...)

After execution of these lines EA displays an alert which shows 1.

Alert: stoploss:1 ticket:3 priceopen:1.3319 takeprofit:1.3337

While stoploss is clearly not at 1.0000. At first I thought that perhaps I declared stoploss as intiger but no, it was alright. Does anyone of my more experienced fellow programers know what might be the problem?

I will really appreciate any help.


 

ticket:3

it seems to me that u don't have the right ticket selected

 
Well, ticket:3 is fine. Program allows multiple orders to be placed. The weird thing is that ticket, openprice and takeprofit are there, found with ease but stoploss does not function.
 

Alert: stoploss:1 ticket:3 priceopen:1.3319 takeprofit:1.3337

While stoploss is clearly not at 1.0000.

stoploss IS clearly 1.0000??????

look at the journal when it opened

Look at the code that opened it, print out the values used.

and next time

 

Yes it is clearly 1. I did the following alert and it shows 1!

if (OrderSelect(u,SELECT_BY_POS,MODE_TRADES))
{
double stoploss = OrderStopLoss();
int ticket = OrderTicket();
double priceopen = OrderOpenPrice();
double takeprofit = OrderTakeProfit();
int typ = OrderType();
Alert ("stoploss:",OrderStopLoss()," ticket:", ticket," priceopen:", priceopen," takeprofit:",takeprofit);
(...)

The order is selected correctly because there is ticket, open price, and take profit of that particular order printed correctly. However even when I changed stoploss to be printed not as a variable to which OrderStopLoss() is assigned but as OrderStopLoss itself, it still does show 1!

How can this be?

 

I note that you are setting typ to OrderType() but not displaying it. Never mind; this ticket should be a BUY as TP > PriceOpen.

A BUY @ 1.3319 could have a SL of 1.0000, which would show as 1

Unless it's not a BUY.

Now, please explain why SL couldn't possibly be 1

 
macgyver:

Yes it is clearly 1. I did the following alert and it shows 1!

How can this be?

Because it IS 1.0000

Look at the orderSend code, look at the journal. Your OrderSelect/Alert is irrelevant.

Reason: