TraderTect: The EA I created is a beast based on MA cross and never loses if I dont use SL.
but it is only opening short trades...
- No SL means you have infinite risk.
In code (MT4): Risk depends on your initial stop loss, lot size, and the value of the pair. It does not depend on margin and leverage.
- 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
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.
-
; if(OrdersTotal()==0); { if(iStochastic(NULL, PERIOD_CURRENT, 5, 3, 3, MODE_SMA, 0, MODE_MAIN,0) < iStochastic(NULL, PERIOD_CURRENT, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL,0) && iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_EMA, PRICE_CLOSE, 0) < iMA(NULL, PERIOD_CURRENT, 30, 0, MODE_EMA, PRICE_CLOSE, 0)) OrderSend (_Symbol,OP_SELL,0.01,Bid,0,Stoploss,Bid-500*_Point,NULL,0,0,Red); else return; }
Why are you ignoring the compiler's warnings? " empty controlled statement found testscr.mq4 5 26" Your first if does nothing, therefor if the conditions are correct, you will open one order per tick. -
Using OrdersTotal (or OrdersHistoryTotal)
directly and/or no Magic number filtering on your
OrderSelect 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
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles - Run your code through the styler so you can see the logic flow.
- When you find a problem, stop using the tester, Use the debugger or print out your variables, including _LastError and prices and find out why.

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
The EA I created is a beast based on MA cross and never loses if I dont use SL. but the issue I am getting in the strategy tester is that it is only opening short trades...
it also open many positions at once like 100, and when they hit tp, it looks to sell straight away.
as well as getting it to open buy orders, can you also help me figure out how to restrict the amount of trades triggered?
I will attach the script here