-
Why did you post your MT4 question in the
Root /
MT5 EA section
instead of the
MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Next time post in the correct place. The moderators will likely move this thread there soon. ticket=OrderSend(_Symbol,OP_BUY,buy_lots,Ask,slippage,buy_SL,buy_TP,order_comment,magic,0,clrNONE);
Check your return codes for errors, report them and you would know why.
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.- Use the debugger or print out your variables, including _LastError and find out why.
(buy_TP-Bid)/pip>stop_level)
Is stop_level in pips? Market Info returns points.double LostPerLot=LZ*1000*pip+Trade_Commission_Per_Lot; if(StopLoss_In_PIP>0) LostPerLot=LZ*StopLoss_In_PIP*pip+Trade_Commission_Per_Lot; double buy_lots=AccountFreeMargin()*Risk_In_Percent/100/LostPerLot;
Hard coding constants (1000) means your code breaks on other symbols. Free margin has nothing to do with risk. Risk depends on your initial stop loss, lot size, and the value of the pair.- You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
- Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.)
-
Do NOT use TickValue by itself - DeltaPerLot
and verify that MODE_TICKVALUE is returning a value in your deposit
currency, as promised by the documentation, or whether it is returning a value
in the instrument's base currency (EUR, in this case).
MODE_TICKVALUE is not reliable on non-fx instruments with many brokers. - You must normalize lots properly and check against min and max.
- You must also check FreeMargin to avoid stop out
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, here is my code why facing error 131 , Do some one help me... Chaiya