Log in or register to download unlimited Forex robots!
MT5 MQL5 Trading EA
Hello,
Bases on the SimpleCancelOrder EA of mql5tutorial.com I created my own trading EA only suitable in MT5.
If the EA has in total less than 15 positions open it will open new sell stop and buy stop orders. With TP and SL. All values are configurable at the Inputs tab. The EA also cancels the pending order if market prices has gone the other direction. It comments on the chart several variables. It has a dynamic lot sizing bases on the equity. It makes with the current setting on my roboforex demo account about 600 euro profit using 2000 and 1:500 leverage.
#include<Trade\Trade.mqh>
CTrade trade;
input int BuyTP = 252;
input int BuySL = 1019;
input int SellTP = 1193;
input int SellSL = 883;
input int Offset = 299;
void OnTick()
{
double Balance = AccountInfoDouble(ACCOUNT_BALANCE);
double Equity = AccountInfoDouble(ACCOUNT_EQUITY);
double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
double PositionSize = NormalizeDouble((Equity/100000),2);
if (PositionSize < 0.01) PositionSize = 0.01;
// if we have no open position and no order
if (PositionsTotal()<=15 && OrdersTotal()<=15)
{
Comment ("\n ### PositionsTotal: ",PositionsTotal(), "\n OrdersTotal: ",OrdersTotal());
// buy stop, 10 microlots, 100 points above Ask, no SL,
// 300 points TP, no expiration, no date, no comment
trade.BuyStop(PositionSize,Ask+Offset*_Point,_Symbol,Ask-BuySL*_Point,Ask+BuyTP*_Point,ORDER_TIME_GTC,NULL);
// sell stop, 10 microlots, 100 points below Bid, no SL,
// 300 points TP, no expiration, no date, no comment
trade.SellStop(PositionSize,Bid-Offset*_Point,_Symbol,Bid+SellSL*_Point,Bid-SellTP*_Point,ORDER_TIME_GTC,NULL);
}
Comment ("Position Size: ",PositionSize,"\n PosTotal: ",PositionsTotal(), "\n OrdersTotal: ",OrdersTotal(),"\n Spread: ",(Ask-Bid)*_Point);
// if we have at least 1 position
if (Balance!=Equity) CancelOrder();
}
void CancelOrder()
{
// check all orders
for(int i=OrdersTotal()-1; i>=0; i--) // count all currency pair positions
{
// get the ticket number
ulong OrderTicket = OrderGetTicket(i);
// Delete the pending orders
trade.OrderDelete(OrderTicket);
} // End for loop
} // End BreakEven Stop function
- Total number of registered users: 77,580
- Registered users today: 5
- Newest registered user: mkrdOvems
- Total number of topics: 11,777
- Total number of posts: 38,456
Online users: 2,302 guests, 91 Members:
admin, Alex Pierre Torras, Alrowad Gate, Asbu, azfxtrade, Biren, Bitson Mahoney, Brasky4eva, brunox, BUNDER, circusdjay, Cleidivan Ramos, Coiner, cowboy25, CTThisani, curleyjoel, Daniel Higgins, david.weissbraun, Davo6789, ddeliberato, diversanta, dmb trading, Donovan Sissing, edwinses, ela, Ema144, emmie789, Emmy, ez251158, fastlane2021, flairandflowers, Fraser, gohang, goleon8, Gun Gun Gunawan, harrydapel, hgmt4, hhh45, IamSolomonChika, Investor, Jilles Maes, josidd, Justin Schmitgen, Kanaimba Ua Lucky, khunudom, Kingbill2, kjrajchennai, KYM, Lamboz-Cashpot Worldwide, limevanilla, lob68, m217irr, Marvin Tacdoy Bao-et, Massimo Casiglia, Mauricio Adriano de Castro, Mendocino, Mike419, Miroslav Hányš, mkrdOvems, Mokgobi, moneyjolt, mt4talk001, naushad1976, neagoelaur, nilocrasta, oberasbacher, Oupas25, pigboy, povvke, Purgeaudio, Raiikou Idrissi, Raja Rabbani Janjua, Rosecharity40, sasastephe, Sibu, Simone Cik Cicala, skinvestor1978, Sniperxss, sonel, spark2023, SUKMILKY1959, Thakurb, tskabilan, Unclemo95, vrkvinayagam, xv16, Xxsticsxx, Zo, Zoltan0013, zorbafx69, 西伯利亚风
The content on the MT4talk website is created by its users (MT4talk forum members). MT4talk does not sell Forex robots and does not offer support for them. MT4talk only offer PRO membership which allows for unlimited downloads of content from any forum topic or post. The updates for Forex robots may be limited or not happen at all, depending on who created the robot.
We are testing Forex robots in real-life conditions! We use a demo account to test some of the robots and the results are still accurate. We are not financial advisors and cannot advise you to invest your money. Our aim is to find good market analysis solutions using different strategies that can benefit our community.
CFTC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS, IN GENERAL, ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.
Disclaimer - No representation is being made that any Forex account will or is likely to achieve profits or losses similar to those shown on backtests in this forum. In fact, there are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical trading does not involve financial risk, and no hypothetical trading record can completely account for the impact of financial risk in actual trading. All information on this forum is for educational purposes only and is not intended to provide financial advice. Any statements posted by forum members or the MT4talk EA Tester Team about profits or income expressed or implied, do not represent a guarantee. Your actual trading may result in losses as no trading system is guaranteed. You accept full responsibilities for your actions, trades, profit or loss, and agree to hold the MT4talk team and forum members of this information harmless in any and all ways.
Affiliates Disclaimer - The website may have links to partner websites, and if you sign up and trade through these links, we will receive a commission. Our affiliate partners are FXOpen, FBS, LQDFX, and MyForexVPS.
Copyright MT4talk.com Forum Rules - Privacy Policy.