Error 130 - Requirements and Limitations in Making Trades its all OK (code + log with all variables)
Hi!
The first buy position does not open and throws the error 130.
This happens after a few orders.
The second order never gives problem (OP_SELLSTOP).
I put the code/log for better understanding.
Please add prints for Bid and Ask into your error reporting . . .
It seems to me that your trade does not comply with the requirements . . .
InitialPrice = Ask - INCREMENT * Point; // <------- note SellGoal = InitialPrice - 2 * INCREMENT * Point; BuyGoal = InitialPrice + 2 * INCREMENT * Point; ticket = OrderSend(Symbol(), OP_BUYSTOP, LOTS, InitialPrice + INCREMENT * Point, 2, // <---- note
so the opening price is InitialPrice + INCREMENT * Point or ( Ask - INCREMENT * Point ) + INCREMENT * Point resulting in a value of Ask
From here: Requirements and Limitations in Making Trades
Order Type |
Open Price |
Close Price |
Open Price of a Pending Order |
Transforming a Pending Order into aMarket Order |
---|---|---|---|---|
BuyStop | Above the current Ask price | Ask price reaches open price |
Please add prints for Bid and Ask into your error reporting . . .
It seems to me that your trade does not comply with the requirements . . .
so the opening price is InitialPrice + INCREMENT * Point or ( Ask - INCREMENT * Point ) + INCREMENT * Point resulting in a value of Ask
From here: Requirements and Limitations in Making Trades
You're right!
The problem was the initial price to open a buy position.
New code:
ticket = OrderSend(Symbol(), OP_BUYSTOP, LOTS, Ask, 2, SellGoal, BuyGoal, DoubleToStr(InitialPrice, MarketInfo(Symbol(), MODE_DIGITS)), MAGIC, 0); <<--- The problem line if (ticket > 0) { BuyGoalProfit = CheckProfits(OP_BUY, InitialPrice); Print("cpt(" + cpt + ") BuyGoalProfit(" + BuyGoalProfit + ")"); }else{ Print("Cannot trade, error: ",ErrorDescription(GetLastError())); PrintFormat("OP:"+(InitialPrice + INCREMENT * Point)+" SL:"+SellGoal+" TP:"+BuyGoal); Print("Bid-SL:"+(Bid-SellGoal)+" > Freeze Level:"+MarketInfo(Symbol(),MODE_FREEZELEVEL)); Print("Bid-SL:"+(Bid-SellGoal)+" >= Stop Level:"+MarketInfo(Symbol(),MODE_STOPLEVEL)); }
Thanks!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi!
The first buy position does not open and throws the error 130.
This happens after a few orders.
The second order never gives problem (OP_SELLSTOP).
I put the code/log for better understanding.
My code:
My log:
Watching to see the response and analysis!
Thanks!