Error 130 on OP_BUYSTOP order

 

MT4 giving me an error 130. Here is the code:

 ticket_order = MarketOrderSend(Symbol(), OP_BUYSTOP, Lot(lot_size), ND(Ask+Distance*MyPoint), 10*int(MyPoint/Point()), ND(Bid-StopLoss*MyPoint+Distance*MyPoint),

It places a BuyStop oder but without Stop Loss and Take Profit (error 130).

What am I doing wrong?

 
Roman Filin:

MT4 giving me an error 130. Here is the code:

 ticket_order = MarketOrderSend(Symbol(), OP_BUYSTOP, Lot(lot_size), ND(Ask+Distance*MyPoint), 10*int(MyPoint/Point()), ND(Bid-StopLoss*MyPoint+Distance*MyPoint),

It places a BuyStop oder but without Stop Loss and Take Profit (error 130).

What am I doing wrong?

Nobody can help you, because nobody knows what your MarketOrderSend(), ND(), MyPoint and Distance are for.
 
Roman Filin:

MT4 giving me an error 130. Here is the code:

 ticket_order = MarketOrderSend(Symbol(), OP_BUYSTOP, Lot(lot_size), ND(Ask+Distance*MyPoint), 10*int(MyPoint/Point()), ND(Bid-StopLoss*MyPoint+Distance*MyPoint),

It places a BuyStop oder but without Stop Loss and Take Profit (error 130).

What am I doing wrong?

try the search function with "error 130" may you get a solution for the error
 
Roman Filin:

MT4 giving me an error 130. Here is the code:

 ticket_order = MarketOrderSend(Symbol(), OP_BUYSTOP, Lot(lot_size), ND(Ask+Distance*MyPoint), 10*int(MyPoint/Point()), ND(Bid-StopLoss*MyPoint+Distance*MyPoint),

It places a BuyStop oder but without Stop Loss and Take Profit (error 130).

What am I doing wrong?

if you have an ECN account you place order on maket price and YOU CAN`T set sl and tp.

You need to send order:

if(OrderSend(_Symbol,order_type,loty,price,5,NULL,NULL,NULL,0,0,arrow_color)<0)

and after MODIFY your order

have a nice day:)

 
  1. gierqs:

    if you have an ECN account you place order on maket price and YOU CAN`T set sl and tp.

    You need to send order:

    if(OrderSend(_Symbol,order_type,loty,price,5,NULL,NULL,NULL,0,0,arrow_color)<0)

    and after MODIFY your order

    When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. TP/SL on OrderSend has been fine for years.
              Build 500 2013.05.09 № 9
              Need help me mql4 guru add take profit to this EA - Take Profit - MQL4 and MetaTrader 4 - MQL4 programming forum

  3. NULL is not a valid price.
    • You can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, MarketInfo does not. OrderSend does not.
    • Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    • Zero is the same as PERIOD_CURRENT which means _Period. Don''t hard code numbers.
    • No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].

  4. MarketOrderSend(Symbol(), OP_BUYSTOP, Lot(lot_size), ND(Ask+Distance*MyPoint), 10*int(MyPoint/Point()), ND(Bid-StopLoss*MyPoint+Distance*MyPoint),
    You buy at the Ask and sell at the Bid.
    • Your buy order's TP/SL are triggered when the Bid reaches it. Not the Ask.
    • Your sell order's TP/SL will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 and MetaTrader 4 - MQL4 programming forum - Page 3
    • The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools -> Options {control-O} -> charts -> Show ask line.)

  5. Bid-StopLoss*MyPoint+Distance*MyPoint
    Don't know what Distance is but shouldn't you be subtracting?

  6. Check your return codes for errors, report them and you would know why. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.

Reason: