Download MetaTrader 5

Storing entry price until Bias Change?

To add comments, please log in or register
Dominic Gilbert
Dominic Gilbert 2014.09.19 15:17 

How can I store the entry price for my OrderSend functions up until the bias changes?

Entry for long:  H1_Buy_Touch = "H1 Buy Touch"; (global variable)

Entry for short:  H1_Sell_Touch = "H1 Sell Touch"; (global variable)

These biases can change on every hour as it is checked on ever new bar. Thing is, when the OrderEntry(1) is called, the entry price will be near enough different every time as the calulcations are done in that void straight away. 

I want to remember the FIRST time it's called and the corresponding price. OrderEntry pushes out Pending buy and sell stops. They can be cancelled every hour if the stops, targets and lots require adjusting. If thats the case, on every tick it then start here again (below) and if the bias is applicable, it'll push out 4 sets of new pending orders with everything new INCLUDING a new entry price. I don't want the entry price to change though... I want to use the same entry price up until either the orders are entered into the market, or the bias changes to "None"

//| Expert tick function                                             |
void OnTick()

   if( OpenOrdersThisPair(Symbol()) == 0 && H1_Sell_Touch == "H1 Sell Touch")
       OrderEntry(1); // <<< Sell function (x4 OrderSend)

To add comments, please log in or register