Help - about variables

 
Hi, I have a basic problem with variables. I have a variable named "x". The value of this variable (for example depending on the price of the eur-usd parity) is constantly changing. My goal is trading when certain conditions are met. The "price" variable that I will trade will be the value of my "x" variable at the moment exactly those conditions are met. And during the trading the value of "price" variable should be remain constant. After my first trade is finished, I will have to have the necessary conditions again for the second trading. When the necessary conditions are met, the "price" that I will enter into the second trading will also be the value of my "x" variable at the time that those conditions are met. This will continue like this. How can I create the "x" variable and the "price" variable so that the program can continue in this order.
 
double x;     //Your variable
if ((x == your_price) && (//insert condition to detect no current position))
{
      //insert your trading code
}
 
mfx123:
Ty for response. I couldn't explain my issue exactly. My "x" variable is already determined. My "x" variable is highest price of last 5 candle, therefore it always changes with time. My aim is my "price" variable should take value of "x" at the time when all necessery conditions are met. Then my trade starts. After my trade finish I want to do same thing constantly. For example, for my second trade, value of my "price" variable should not be same with value of "price" in the first trade. It should be value of "x" variable when all conditions are met again. Note: during the each trade, value of "price" variable should remain constant.
 
Check if there is a position before you change the variable
 
amando:
Check if there is a position before you change the variable

I didnt understand. I will try to explain my problem in other way.

"x" is changing with time.

"price" should take value of x when all conditions are met.

Example:

x is always changes and my program start first trade when x = 1.205. And my "price" is equal to 1.205.

Trade 1:

x = always changes

price = 1.205 and during the trade its value must be same

Trade 2:

x = always changes

price = 1.228 (assume conditions for second trade were met at that value) and during the trade "price" value must be same as before.

 
You already have the answer in #1.
 
mfx123:
double x;     //Your variable
if ((x == your_price) && (//insert condition to detect no current position))

Doubles are rarely equal. Understand the links in:
          The == operand. - MQL4 programming forum #2 2013.06.07