How to fix value of a variable to a specific price?

 

Im using the following code to trigger a buy order. What Im doing is looking for an outside candle, where the low of the current candle dips below the low of the previous candle....and then the high of the current candle breaches the high of previous  candle. The following logic only works if its an outside candle. (i-e, current low is less than prev low, and current high is higher than prev high)  

[code]bool buy_condition_1 = Low[0] <= Low[1];

bool buy_condition_2 = Ask == High[1] ; 

 if( buy_condition_1 && buy_condition_2).................(buy at current ask) 

[/code]

What i want to do is that if the current low is less than prev low, then set the buy price at the high[1]...and hold that buy price until it is hit. In the above code, the  price is hit only if its an outside candle, and as soon as a new candle is formed, the value of High[1] shifts to the new candle as well. I want value of High[1] to remain fixed. 

 
What i want to do is that if the current low is less than prev low, then set the buy price at the high[1]...and hold that buy price until it is hit. In the above code, the  price is hit only if its an outside candle, and as soon as a new candle is formed, the value of High[1] shifts to the new candle as well. I want value of High[1] to remain fixed. 
The easiest thing you can do is placing a pending order with High[1] as one of the parameters.
It means you can delete your buy_condition_2 variable and instead have something like:
 
bool buy_condition_1 = Low[0] <= Low[1];
if( buy_condition_1 )OrderSend(Symbol(), OP_BUYSTOP,1,High[1],50,50);
Of course you should also check if OrderSend returned true, pass correct possition volume etc.
Hope it helps.
 
Adam Slucki:
The easiest thing you can do is placing a pending order with High[1] as one of the parameters.
It means you can delete your buy_condition_2 variable and instead have something like:
 Of course you should also check if OrderSend returned true, pass correct possition volume etc.
Hope it helps.

Thanks Adam...but that didnt seem to help.

I guess i can set the value by declaring it as a static double, but my next question would be, how would i reset its value, should i need to change it? Is there a way to reset the value of a static variable mid strategy, so as to assign in a new value?.

 
copy the static to a dynamic variable then you can change that.
Reason: