get open price for an already opened position

 

hi guys,

I'd like to use the following code as a static variable but it seems like changing at every new tick. I'd like to have the Opened position's price as a static number. any thoughts about this issuse? many thanks in advance!

while(Total==0) {



if (x==1) {

OrderSend(Symbol(), OP_BUY, Lots, Ask, 3, 0, Ask+range);
Ubarrier = Ask; //I define Ubarrier here, but it does not remain static
Dbarrier = Ask-range; // same here
x=2;
Total=1;


} else {

OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, 0, Bid-range);
Ubarrier = Bid+range;
Dbarrier = Bid;
x=1;
Total=1;
}

}

 

You can get OpenPrice and TP level by using OrderOpenPrice() and OrderTakeProfit() functions.

To get data saved in the variables you can define them outside start function (just before init() or after your extern parameters) .

Also pay attention to variables type. Maybe you defined them as int while they should be double.

 
hasayama:

You can get OpenPrice and TP level by using OrderOpenPrice() and OrderTakeProfit() functions.

To get data saved in the variables you can define them outside start function (just before init() or after your extern parameters) .

Also pay attention to variables type. Maybe you defined them as int while they should be double.


many thanks for your advise!