You didn't post a topic yet. Let us show you how to make your first topic and upload your favorite forex robot. Guide me

Skip to forum content


Pages 1

You must login or register to post a reply

RSS

Posts: 3
Please rate this topic
Current rating: 0
Votes: 0

Embed topic to your site
(edited by raselpro 04-28-15 19:21:24)

AC+AO ea v1 (+source code)

Topic: AC+AO ea v1 (+source code)

//+------------------------------------------------------------------+
//| This MQL is generated by Expert Advisor Builder                  |
//|                [url]http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/[/url] |
//|                                                                  |
//|  In no event will author be liable for any damages whatsoever.   |
//|                      Use at your own risk.                       |
//|  Changes by Barry Vincent                                        |
//|  8/14/08 AC+AO v1 Fix error in code and the stops and take profit|                                                                |
//|          optimized for the eurusd                                |                                         |
//|                                                                  |
//+------------------- DO NOT REMOVE THIS HEADER --------------------+

#define SIGNAL_NONE 0
#define SIGNAL_BUY   1
#define SIGNAL_SELL  2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

#property copyright "Expert Advisor Builder"
#property link      "[url]http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/[/url]"

extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 1.0;
extern int Slippage = 3;
extern bool UseStopLoss = True;
extern int StopLoss = 25;
extern bool UseTakeProfit = True;
extern int TakeProfit = 118;
extern bool UseTrailingStop = True;
extern int TrailingStop = 55;

int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
   BarCount = Bars;

   if (EachTickMode) Current = 0; else Current = 1;

   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() {
   return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
   int Order = SIGNAL_NONE;
   int Total, Ticket;
   double StopLossLevel, TakeProfitLevel;



   if (EachTickMode && Bars != BarCount) TickCheck = False;
   Total = OrdersTotal();
   Order = SIGNAL_NONE;

   //+------------------------------------------------------------------+
   //| Variable Begin                                                   |
   //+------------------------------------------------------------------+


double Buy1_1 = iAC(NULL, 0, Current + 0);
double Buy1_2 = iAC(NULL, 0, Current + 1);
double Buy2_1 = iAC(NULL, 0, Current + 1);
double Buy2_2 = iAC(NULL, 0, Current + 2);
double Buy3_1 = iAO(NULL, 0, Current + 0);
double Buy3_2 = iAO(NULL, 0, Current + 1);

double Sell1_1 = iAC(NULL, 0, Current + 0);
double Sell1_2 = iAC(NULL, 0, Current + 1);
double Sell2_1 = iAC(NULL, 0, Current + 1);
double Sell2_2 = iAC(NULL, 0, Current + 2);
double Sell3_1 = iAO(NULL, 0, Current + 0);
double Sell3_2 = iAO(NULL, 0, Current + 1);

double CloseBuy1_1 = iAC(NULL, 0, Current + 0);
double CloseBuy1_2 = iAC(NULL, 0, Current + 1);
double CloseBuy2_1 = iAC(NULL, 0, Current + 1);
double CloseBuy2_2 = iAC(NULL, 0, Current + 2);

double CloseSell1_1 = iAC(NULL, 0, Current + 0);
double CloseSell1_2 = iAC(NULL, 0, Current + 1);
double CloseSell2_1 = iAC(NULL, 0, Current + 1);
double CloseSell2_2 = iAC(NULL, 0, Current + 2);

   
   //+------------------------------------------------------------------+
   //| Variable End                                                     |
   //+------------------------------------------------------------------+

   //Check position
   bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
            //Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Buy)                                           |
            //+------------------------------------------------------------------+

                     if (CloseBuy1_1 < CloseBuy1_2 && CloseBuy2_1 > CloseBuy2_2) Order = SIGNAL_CLOSEBUY;


            //+------------------------------------------------------------------+
            //| Signal End(Exit Buy)                                             |
            //+------------------------------------------------------------------+

            if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
               if (!EachTickMode) BarCount = Bars;
               IsTrade = False;
               continue;
            }
            //Trailing stop
            if(UseTrailingStop && TrailingStop > 0) {                 
               if(Bid - OrderOpenPrice() > Point * TrailingStop) {
                  if(OrderStopLoss() < Bid - Point * TrailingStop) {
                     OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
                  }
               }
            }
         } else {
            //Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Sell)                                          |
            //+------------------------------------------------------------------+

                     if (CloseSell1_1 > CloseSell1_2 && CloseSell2_1 < CloseSell2_2) Order = SIGNAL_CLOSESELL;


            //+------------------------------------------------------------------+
            //| Signal End(Exit Sell)                                            |
            //+------------------------------------------------------------------+

            if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
               if (!EachTickMode) BarCount = Bars;
               IsTrade = False;
               continue;
            }
            //Trailing stop
            if(UseTrailingStop && TrailingStop > 0) {                 
               if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
                  if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
                     OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
                  }
               }
            }
         }
      }
   }

   //+------------------------------------------------------------------+
   //| Signal Begin(Entry)                                              |
   //+------------------------------------------------------------------+

   if (Buy1_1 > Buy1_2 && Buy2_1 < Buy2_2 && Buy3_1 > Buy3_2) Order = SIGNAL_BUY;

   if (Sell1_1 < Sell1_2 && Sell2_1 > Sell2_2 && Sell3_1 < Sell3_2) Order = SIGNAL_SELL;


   //+------------------------------------------------------------------+
   //| Signal End                                                       |
   //+------------------------------------------------------------------+

   //Buy
   if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
      if(!IsTrade) {
         //Check free margin
         if (AccountFreeMargin() < (1000 * Lots)) {
            Print("We have no money. Free Margin = ", AccountFreeMargin());
            return(0);
         }

         if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
         if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

         Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
         if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
                Print("BUY order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
            } else {
                Print("Error opening BUY order : ", GetLastError());
            }
         }
         if (EachTickMode) TickCheck = True;
         if (!EachTickMode) BarCount = Bars;
         return(0);
      }
   }

   //Sell
   if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
      if(!IsTrade) {
         //Check free margin
         if (AccountFreeMargin() < (1000 * Lots)) {
            Print("We have no money. Free Margin = ", AccountFreeMargin());
            return(0);
         }

         if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
         if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

         Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
         if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
                Print("SELL order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
            } else {
                Print("Error opening SELL order : ", GetLastError());
            }
         }
         if (EachTickMode) TickCheck = True;
         if (!EachTickMode) BarCount = Bars;
         return(0);
      }
   }

   if (!EachTickMode) BarCount = Bars;

   return(0);
}
//+------------------------------------------------------------------+
Post's attachments

AC+AO ea v1.mq4 10.44 kb, 11 downloads since 2015-04-28 

Share

Re: AC+AO ea v1 (+source code)

thanks for sharing this information, i will have a try on it also

Share

Re: AC+AO ea v1 (+source code)

Hello.

I  try on it also



I made a backtest.

Then Demo.

It look good.

Thanks.
Manuel

Share

Posts: 3

Pages 1

You must login or register to post a reply

Last Posts

  • 26/03: profit box v7
  • 26/03: In forex,
  • 25/03: Sofy Robot - ( tested with over $100,000 profit)
  • 25/03: EA Laba-Laba
  • 25/03: trader must take care of
  • 25/03: trader needs to bestow highlight
  • 24/03: super profit EA robot for eurusd gbpusd-(tested with over1000% profit)
  • 24/03: EA - Budak Ubat
  • 24/03: I am happy with my broker
  • 24/03: Quantina Inteligence Forex News Trader Ea
  • 23/03: Get The ATB Sniper Indicator
  • 23/03: Envelop Basic
  • 23/03: EA's collection number 3 - (tested with over 2,200% profit)
  • 23/03: Cent account with high leverage brokers
  • 23/03: forex-expert-advisors.at
  • 23/03: SUper Scalping EA - (tested with over 1,800% profit)
  • 23/03: TradeWise : Truely Free Forex Signals from a Professional Trader
  • 23/03: Arbitrage EA
  • 23/03: Hedging EA - Always in profit
  • 23/03: EURUSD USDCHF CORRELATION USING TRAILING CLOSEDABASKETATPROFIT()
  • 22/03: best 2018 from china hihi win come in here
  • 22/03: what is leverage all about?
  • 22/03: As each trader is different
  • 21/03: Af Global and Af Scalper code
  • 21/03: Peak and Valley by Sir Fx
  • Online Users & Stats

    • Total number of registered users: 30,349
    • Newest registered user: Solomon Ishaya
    • Total number of topics: 11,825
    • Total number of posts: 38,274

    Online users: 1,971 guests, 156 Members:

    4tisbk, Addyson, Adel Eskandari, Adler42, admin, Alberto Pierobon, Albertos, alemariani5200, amrismail2000, antobozic, Argo Vilberg, Aspysource1, b78sandeau, ball2goal, bestkid321, betuboxem, binkchn, boubou852, Cleiton Zauri, cruelzhang, cumehxp, Dale McMurrin, dannymignault, Dany Anjar Widianto, david795g, deepaksabari2911, diegaos1189, dinhtt, Donnie Drajat, Donovan Sissing, Dtsuperman, dumisawhite, dvorynen, EAInspirer, eatrade123, eceric2, fewcha, Fishmen, FloridaTraderLLC, flsekme, Forex Stock Trading, forexnfx, frankhez200, ges4688, gooatom, grinti01, Gys Burger, hajar, Hamid Salehi, hertzognel36, hinaponn, Houman Ahouman, hporta, IftimieD, igik1967, jaffarmsh, Jahanzib86, jammer, Jan De Juan, jaysonajax, jbarrero22, john.solgaard, johnsun888, Jordan Pritchett, josualeonard, judeekatherinexx, Jungsik Kang, juris.gulans, jurv2186, jyameogo87, KatMan, Khadare, komikami, koube202, krutimshah1981, kumron2548, Kunnaput Otop, Kyosuke Tagawa, leonvaldez, luisinho.nl, machemitoccafa, MagerMoLcH4, marcus, MarianNick123, mathisonrichard, matttodorovski_au, Maurilio7, Medoune Beye, mgatua2000, milojohzak, mioraz2050, Mix Lin, Mombinou Dorichamou, Monday Adaji, Mostafa Alsheikh, mouton.hanno@gmail.com, murugeswaranb, Mustafa Ateş, mwatcher, Neosul, noyful, olegsbajuks, omer_jabbar, otomc, pantherrilla, parmi99, phismo77, piyadela, Primex, Profit Forex, Renato Hi Fi, rkkgs, rocky1821, Ruslan, safron, sango, sansores1984, sasastephe, selorm65, shakeel744, Shegzsucre, Sheyifund, softfire, Sol-s Square, Solomon Ishaya, sonel, stefan78calcan, Stephen-One, Taposki99, tellanup, testobjekt, thon11, Timyx, tomd0361, topaz790, topcat275, tradingralf, Trady Re, trail5.wheels, umt4, vadvid, Vinh, vishwa4145, vodafone2066, vrodvmax, warrenteoh, why, woodya22, www.ernestdube, xirixiao, yahavuzan, yucelhuner, Yudi Hermawan, Алексей Отмахов, Алексей Российский, דרור וסרמן

     


    NOTE: 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.

     

    IMPORTANT: MT4talk.com is a public Forex forum, where forum members can upload open source Forex robots to share with other members. MT4talk.com forum does not sell or rent Forex robots, and does not provide guarantee or support for the uploaded Forex robots! If you have any question about any Forex robot, please open a forum topic! If you have a question about your forum account, contact: mt4talk@gmail.com

    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 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.


    Copyright MT4talk.com Forum Rules - Privacy Policy.