Posts: 1
Please rate this topic Current rating: 0 Votes: 0
RSS
Ozzmann
Banned
Offline
  • From: Netherlands
  • Registered: 05-20-18
  • Posts: 5
  • Gender: male
  • Age: 51
  • Email
  • Thanks: 1

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
MyEA - Copy.zip 918 b, 30 downloads since 2018-05-31 

Thanked for the post: jozmik

Online Users & Stats
  • Total number of registered users: 58,211
  • Registered users today: 6
  • Newest registered user: SUMITO
  • Total number of topics: 11,579
  • Total number of posts: 37,784

Online users: 5,800 guests, 402 Members:

, 125034805, 38335223, 40333369, 4221497133xyz, 4xlord, achim22285, Achmad, activo6, Ada.vivian, Adamblacky, adasas, admin, afadhil2007, aforest, Ahmad AA, Ahmed Algantiry, ahmedzaaloo, ajbitz31573, Alanlan, alapia, Alberto776, aleksandr, Aleš Johnson, Alexander Lamount Knowles, Alexandrea Deleon, Alexx, americgroup, Anderson Thome Amaral, andrespinilla, Andrezigonk, arafat.haitham, Ari, asad.uosindh, Ashcash, AvhaHenry, Azzam_k, badrul93, Bagre, bajpai, Bandara Sanath, Bảo Khương, Bazith, belluspixel, BENEX, benw, Benya, betuboxem, bigbizbid, blasterblade, Blessing Thapelo, bob1968, Bobbshteer, bobbythom, Bratanon, brodakwame, Burhanuddin Al-asrory, business.nwar, bxxlb001, c j, Cacius, charlenep1, Chen Suyuan, Chicks, Chrisroz, Christian Oneness, Clint, cluemaster2000, cmaq, Cosmicus, cosminb, dailocphat, Damian Virenque, damvanlong, danior, dbruno, Deajisafe, Dforex7, dhampton109, dhiru, djeyabalan, dlg2012, Donaldson, doredemo, doukang2, dsggs, Dube, dunarel, Dwight Griffin, EA Tester Team Manager, Edwin Meza, eeyang5, Ehiz O Oluwatoyin, emaltbrown, Emanuele Vazzoler, eme2000, Emil Botto, Emmaline78, Emmanuel Eric Leung, Eric Eisenstein, ericandroid, etrader, exstromar, Ezra Calloway, Faisal Hassan, faizal656, finanza1993, Francis50, Francolegend, frankhez200, fredericrigaud, Fredom, fxdayprofit, Gabriel Rodrigues, Gat76, GEANMAGE, GeorgGiortz, Giancarlo Cavaliere, Glen Knowles, golap, golfzeed, gonza42668a5, GoodSmith, goranm100, Greener30, GSaf Safaa, Haldi64, hanyabdellatif100, Harish Jacelon, Hasan Akca, hasanrockefeller, helaoshi8899, helchadai, HEMILCO, heoconstore, Heriberto Arias, Histvan, Horus, hr.domi, hs4tge, hussain66, Hussein Mohamed, Huxx Zen, imadaitelarabi, Imam1984, invertirmejor, Isaac Eberhart, ismail, ivesent, jack7878, jacklcs, james4real, janavas, jarbett, jasoncrom, Jattila688, Jay171, jeanmps, Jignesh Dholaria, jimi, JJFlush, jkp4174, Joe711, Joel Corrand, JoeSDF, john2531, johncrichton001, Johnnyblaze9, Jojogtr, joskerone, jpkilo, Julyvongsikhay, Jun, Kaboy, kamal123, Kamen Carrot, karimquevedo, Kaushal Shah, Kerapetse, kevpen, Khajoane, Khaled Bah, kisha00, klicmkts, KnifeS2, KolimNt, kpmurugan7, Kubilay Örnek, laert, landgrafivail, lee, Lehn78, lenyora, lifeupchoi, Lwazi, maennicr, maitruc, mak58, makpo, malljohn65, man30885, manvic, Marcus111, Mars Jan, mars7, Marshallofm, Martin 1, Maruping, masrouri2, maxheadroom, maxxyryo, MAYOR74, MElliott, Meso Potamia, mhammedturkman, mholland15178, Mickyvo, mike1809, Minsoo Seok, MlleEsther, Mogbolu Simeon, moneyjolt, moonwalker, Moosle Cooper, Mosheig, MotherFather, Mpho Percival Tilodi, msawan80, mseye, Msina, Msuthur, msyslo, muddy200, Muhammed Shahhoud, MulaudziNP, naimradio, Nano S, Nathan147, neagoelaur, nealmirashi, Nelio Boma, Nicky Mila Rafita, Nicolai, NikAfnan, noeltg, nowcom81, nrpatil1975, nuashall, obzajd, OKmyDAY, Olamilekan Famous Williams, omtei, Oska, Oumarou Badini, Palungsein Spypon, pang3ran, Pankaj Rajoria, paolocroci69, Paresh P Kedar, pasobell, Patcharapon Jaithong, Paul103, pefre, penta, peteaw72, Philkoui, playboy333, Pokseh74, Portablejzs, pram85401, professorepitacio, prs10ce, ptitdiim, puguhnw, putilinao, qingbin wang, Qubik, quintana, R1CH4RD, Radim Bulawa, Radz5000, Rama, ranasumair10, rarranz, Rayjalene3, razmy, redstar1, Reitumetse Lobere, REKING86, Rengarajan, Rethabile, RobertoSAORI, robsam, Rooks, rostaus, rradha999, Rrsingh, ruanlloyd, ryante, Ryhnz, sabastine, Sadaquat Sartaz, sagocendol, saivishnu, salim07, SAMI308, Samsron Jeong, Sean Kennedy, Seerane Emmanuel, segaj, sergeik, Sergio Sepulveda, Serpiente, Setjhaba94, sev, SGR, shamsuriyadi, Sharky, shela, shivaprasad, Shoun, shulav512447, sidtune, sigitsolo, Simons Svirskis, sit01, somin, Sonny TK, speedking, sri4you, sss343344, steeldrum, SUMITO, Sun Hxiao, sunnytsang, Surya Narayan Pradhani, suwar, Sxcret Price Pros, Sydney2000, ta srenevasan, teamcity, tech1979, tech4lifeid, Thabo94, thelordheaven1, ThreeLions, toklapin, Tolkien, tonymakgopa, totals, Trader_Z, tradingralf, Tristan@900, Troygiggs, Tshego, tskabilan, tuiwin8, TWA2020, Tyler, umiteteman, Vaidas170, Valtha, Vamsi2681, VanGils75, vasanth07, venus, vhagwie, Victor Antonio Garcia Espino, vikhustler, Vitaro, Vittayajiratanont Pinijram, vodafone2066, Vuyisile Bango, walidshahbudin, way, widadi, Wiljou, win520923, xiangjn99, xIReaperS, Xman, xpressrobot, xterminator, Y.BTrading, Yahya Yakeen, yaojintong, yiwanfuweng, yjforex, yoadrian978, Yolanda Taylor, Zeeshaan Zedd Shaik, zeevlas43, Zendhy_fitra, Zhero, Zoltan0013, Zone6Mars, zorbafx69, Zweli, zzzpoin, ειρηνη λουκουμακη, דרור וסרמן, ธนกร ลิ่มศิลา

NOTE: Only open-source Forex robots allowed to upload. Hacked or illegal versions of copyrighted Forex robots are highly prohibited on MT4talk.com. If you upload any illegal version of any copyrighted Forex robot, your forum account will be banned. No exceptions.

MT4talk is a User Generated Content website. All content uploaded to MT4talk by our users (MT4talk forum members) is User Generated Content. Please note that MT4talk doesn't sell Forex robots and does not provide support for the uploaded Forex robots. MT4talk only sells PRO membership. PRO membership is unlimited download access in every forum topic and forum posts.


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 site may contain links to affiliate websites, and we receive an affiliate commission for any sign up that trade by you on the affiliate website using such links. Our affiliate partner includes the following: FXopen, FBS, LQDFX, MyForexVPS.

Copyright MT4talk.com Forum Rules - Privacy Policy.