Use a specific price for sending a market order instead of pending order

 

Hi everybody

I want to placing an order(sell/buy) in specific exact price 

I know  these tips:

1. It is possible with pending orders but in my case i want to calculate order lot size in that specific price

2.  its impossible to modify lot size of pending orders

3. It is possible order could not placing in that specific exact price

So

I wrote this pieces of the code:

double firstbuyprice = NormalizeDouble(Ask + (Order_Distance*pips),Digits);
double firstsellprice = NormalizeDouble(Bid - (Order_Distance*pips),Digits); 

    if(firstbuyprice >= Ask && firstbuyprice <= NormalizeDouble(Ask+(1*pips),Digits))
    {
        OrderSend(....)
    }

It's okay to placing order with 1 pip teloranse.

Do you think my idea has any bugs? or any better idea for my case?

thanks a lot

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
yas: Do you think my idea has any bugs? or any better idea for my case?

On every new tick Bid/Ask will change. Thus firstXXXprice will also. Your condition will never be true.

You must remember them in a static or global variables once.

 
William Roeder #:

On every new tick Bid/Ask will change. Thus firstXXXprice will also. Your condition will never be true.

You must remember them in a static or global variables once.

Thanks dear William ,I got it

Now it work nice

Is exist other idea for my case?

 
yas #: Thanks dear William ,I got it Now it work nice Is exist other idea for my case?
Your question is unclear. If it "work nice", what other ideias do you want or need?
 
Fernando Carreiro #:
Your question is unclear. If it "work nice", what other ideias do you want or need?

Hi dear Fernando

You are right but sometimes some ideas maybe work better .