I have some problem of 4107 -- invalid price

 

here is my code:

    // A7

               //

               ticket=OrderSend(_Symbol,OP_SELL,sell_lots,Bid,slippage,sell_SL,sell_TP,order_comment,magic,0);

               if(ticket>0)

                 {

                  signal_HA[iTF_HA_SL]=0;

                  HA_last_trade_bartime[iTF_HA]=iTime(_Symbol,TF_HA,0);

                 }

               if(ticket<0)

                 {

                  string locate="@_"+__FUNCTION__+IntegerToString(__LINE__);

                  Print(locate,"-",GetLastError());

                  print_trading_error(OP_SELL,Bid,sell_lots,sell_SL,sell_TP);

                 }

And here is the results.

error

My problem is, this is place to Bid. When sell we place to Bid?   But result price(=Bid)==13.92 and Bid is 13.92.  This order should be execute but return is ERROR 4107.

Do some one help me what is a wrong in my code.

Chaiya

 
Read the error message and fix your code.
 
Alain Verleyen:
Read the error message and fix your code.

The error message say ERROR 4107-invarid price but my debug printing show the correct price. I am not see the wrong. Or this may to be use NormalizePrice(Bid)?

chaiya

 
Chaiya Srisawat:

The error message say ERROR 4107-invarid price but my debug printing show the correct price. I am not see the wrong. Or this may to be use NormalizePrice(Bid)?

chaiya

I hope you've already gotten it. But for case you haven't: There isn't a problem with the OpenPrice but with your TP.
 
Chaiya Srisawat:

The error message say ERROR 4107-invarid price but my debug printing show the correct price. I am not see the wrong. Or this may to be use NormalizePrice(Bid)?

chaiya

Your log says "invalid takeprofit for OrderSend function".

As noted by Petr, a invalid price doesn't necessarily mean "Open price".

 
Alain Verleyen:

Your log says "invalid takeprofit for OrderSend function".

As noted by Petr, a invalid price doesn't necessarily mean "Open price".

I revise code as follows, and error still there!  chaiya

sell_price=Bid; 

sell_TP=NormalizePrice(sell_TP);

sell_SL=NormalizePrice(sell_SL);

sell_price=NormalizePrice(sell_price);

ticket=OrderSend(_Symbol,OP_SELL,sell_lots,sell_price,slippage,sell_SL,sell_TP,order_comment,magic,0);

 
Chaiya Srisawat:

I revise code as follows, and error still there!  chaiya

sell_price=Bid; 

sell_TP=NormalizePrice(sell_TP);

sell_SL=NormalizePrice(sell_SL);

sell_price=NormalizePrice(sell_price);

ticket=OrderSend(_Symbol,OP_SELL,sell_lots,sell_price,slippage,sell_SL,sell_TP,order_comment,magic,0);

Your problem is in your TP. Look at your log in your firs post. You try to set NEGATIVE TP:

ORDER_TYPE_SELL, Price=14.270,..., TP=-15.730 => Invalid takeprofit

You should set TP to e.g. 12.270

 
Petr Nosek:

Your problem is in your TP. Look at your log in your firs post. You try to set NEGATIVE TP:

ORDER_TYPE_SELL, Price=14.270,..., TP=-15.730 => Invalid takeprofit

You should set TP to e.g. 12.270

YES, THANK YOU TO THE POINT..

CHAIYA

Reason: