- No idea what a "sth" is.
- Why did you post your MT4 question in the Root / MT5 General
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. - Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
-
double TickValue = MarketInfo(Symbol(),MODE_TICKVALUE); if(Point == 0.001 || Point == 0.00001) TickValue *= 10;
PIP, Point, or Tick are all different in general.
What is a TICK? - MQL4 programming forumNever risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.Risk depends on your initial stop loss, lot size, and the value of the pair. It does not depend on margin and leverage. No SL means you have infinite risk.
- 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.
- AccountBalance * 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.
MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum 2017.10.10
Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum 2018.02.11
Lot value calculation off by a factor of 100 - MQL5 programming forum 2019.07.19 - You must normalize lots properly and check against min and max.
- You must also check FreeMargin to avoid stop out
Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.
-
double BuyStopLoss = argOpenPrice - (argStopLoss * PipPoint(argSymbol));
You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.- Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
- Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To
trigger at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 - 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.)
-
for(int Counter = 0; Counter <= OrdersTotal()-1; Counter++){ OrderSelect(Counter,SELECT_BY_POS);
In the presence of multiple orders (one EA multiple charts, multiple EAs, manual trading,) while you are waiting for the current operation (closing, deleting, modifying) to complete, any number of other operations on other orders could have concurrently happened and changed the position indexing:- For non-FIFO
(non-US brokers), (or the EA only opens one order per symbol,) you can
simply count down, in a position loop, and you won't miss orders. Get in the habit of always counting down.
Loops and Closing or Deleting Orders - MQL4 programming forum
For In First Out (FIFO rules-US brokers,) and you (potentially) process multiple orders per symbol, you must find the earliest order, close it, and on a successful operation, reprocess all positions.
CloseOrders by FIFO Rules - Strategy Tester - MQL4 programming forum - Page 2 #16
MetaTrader 5 platform beta build 2155: MQL5 scope, global Strategy Tester and built-in Virtual Hosting updates - Best Expert Advisors - General - MQL5 programming forum #1 № 11 ACCOUNT_FIFO_CLOSE - and check OrderSelect in case earlier positions were deleted.
What are Function return values ? How do I use them ? - MQL4 programming forum
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles - and if you (potentially) process multiple orders, must call RefreshRates() after server calls if you want to use, on the next order / server call, the Predefined Variables (Bid/Ask) or (be direction independent and use) OrderClosePrice().
- For non-FIFO
(non-US brokers), (or the EA only opens one order per symbol,) you can
simply count down, in a position loop, and you won't miss orders. Get in the habit of always counting down.
- Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal
(MT4) or PositionsTotal (MT5), directly and/or no Magic number filtering on your OrderSelect /
Position select loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
PositionClose is not working - MQL5 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
Hello dear trader community
I have coded sth.It does not give order. I am about to lose my mind. Anyone can help me solve this problem out? I really appreciate that.
Write in English!
sth.It is not a word
Hello dear trader community,
I have coded sth.It does not give order. I am about to lose my mind. Anyone can help me solve this problem out? I really appreciate that.
Thanks in advance for your help and time.
Best Regards
Hello,
what is this?
-1 mean count in the future.
Shift = 0. Current bar.
Shift = 1. One bar back.
To get correct variable current and previous iMA, need second iMA have 1 or more Shift greater value.
In your code current and previous iMA have same shift value (-1 wrong).
double MA = iMA(Symbol(), PERIOD_H1, 10, -1,MODE_EMA,PRICE_CLOSE,-1); double MApre = iMA(Symbol(), PERIOD_H1, 10, -1,MODE_EMA,PRICE_CLOSE,-1);
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello dear trader community,
I have coded sth.It does not give order. I am about to lose my mind. Anyone can help me solve this problem out? I really appreciate that.
Thanks in advance for your help and time.
Best Regards