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

Quick Login / Register with Facebook Account!

Login with Facebook

Login with Username and Password!

     Username:       Password:  Login

Register  |  Forgot Password?

 

 

The latest topics with attached files (Forex robots, Forex Indicators, etc..)

Forums in this category with details of Replies, Views, last post

Adenan scalping EA

by machemitoccafa

Close all Script

by timbetapontos10

FxSCALPING

by viktor0

Accurate Indicator

by imetimex


[ Closed ]

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, 8 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


 

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.

 

Forex Risk Warning: Due to leverage, Forex comes with a high risk of losing money. Eighty to 90 percent of Forex traders lose money. You should not invest money that you cannot afford to lose.

Forum statistics

  • Total number of registered users: 22,874
  • Newest registered user: ctaicm02
  • Total number of topics: 11,252
  • Total number of posts: 36,835

Online users: 2,135 guests, 248 Members:

777legrand, aaalll30, admin, afsalme, alesnetusil, Alexander Han Ebd, alirezaxx25, amirhoo, amirhosein.dehqani, amjadjaved456, AnthonyT, arp1051, ball2goal, Benjamin Flores Bta, bensterk2, bestkid321, BillB, bwadd100, Carlox Ortega, carr217, christofer, cobbs, cocor1, Cporn Khunudom, crazypips, cristianozeppe, cruelzhang, cscottbarrett, ctaicm02, Cude, Dani Zuluaga, Darshana Samaraweera, DAVID APAZA, Dequan Ivory Jackson, devitor1, Dimitri Williams, dinkokaraval4ev, DMParry10, Donnie Drajat, douglaszd, Dung Pham Quoc, duraiganeshib, dvorynen, ekouliou, emanuel_scicchitano, enginemix, Enny Cuore Capone, evaluationengineer, evrashea, Expert2103, Faisal Surya, filo, flash1god, fordrimik, forexbillions, forexgovindan, fredericrigaud, Fredy Tello, fxqz1988, ganduruu3691, gazimiraj1977, George Kourogiorgas, Gilang Bagiada, Gizmo79, gofire, hadipurwanto, Hamad Ali, hamd45, hanal456, Hasanboshri, hashour, heartsotech, Horry Yue, Hriday Das, husain1990hh1, hussain.tradeexpress, iamkazi2050, imad2000, imetimex, instamage, itm4ex, jaysonajax, jbcdk, jchege35, jfcamps, Joe0013, johnfayii, johnlee, johnsun888, jonhypepe026, jonkaranja, Jordan Pritchett, José Luis Pérez, Jose Pereira Garcia, joskerone, jozmik, Juan Carlos Sepulveda Lopez, judeekatherinexx, kadir, kamalkumar_j, karimsmida, kcheller, kckcki, kfrankey1963, Kgalagadi Gemsbok, Khaled Jabid, kholo, kiko, kkavci, kleberleal, kooi, kuldsng, Lara Marco, latalsemiramis, lehuyvu1972, Lesli Ranasinghe, Limiter, linh678, logabyy, lori, Lucas Alonso, lyoung4472, mac.seloane, machemitoccafa, machs_nochmal, maestrozahori, MagerMoLcH4, marcial03, Master2501, Matas Milevicius, mates3000, maxheadroom, Maxime Le Mounier, MEDALY, mikemeng, mlcnemare, mmohy, Mohammed Hassan Alismail, Mohd Nizar, Mohd Zanizam Rozali, Mossie, mprafulla2, mrmbk_155, mutantsponge, Nabil Nabil Herradi, najjarja, nakatama1, Nasr Tahir, nejcjost, Nestor Guaman, Neville Carr, nigal, nugroz1805, numanuel, omrvega, osagiemoney, Osman Koç, Osmar Gimenez Retamozo, oxygenx, parlavink, pauljfitzpatrick, pentus01, peter.adshel, phnopporn, Piotr Wójtowicz, pitbull0525, pjarun_fr, pkfielden, pldupreez1981, Prince Victor, ptctodo, quoctu1091, R-Juggernaut Solomon, rad1958, radams10.earl, rafik_fex, rashad666, REKING86, rindhn, ritreis, rochellebrown30, Romario Anthony Nathan, Roson Chea, RUETTA, ryzobas, safari1881, sagheer, sasastephe, sbolungah, Sbuda Djmabura Khuzwayo, seelan.043, sembhi, sentosa101, seree.phetnaronk1968, shafiee, ShakEel Ashiq, shaolin1979, Sirlei Pacheco, sollyvuso, somagacast, sprizzon, Stephane Corneil, suyadi, taherkml, Taposki99, Thammarat Baokhao, Thayna Fantin, thomasmooregilbert, tijo45, Tim Serge Nkulu, timbetapontos10, Timiebi James, Timswood, tmandava, To Gabes, Tom Kuhn, TomaszKom, Tommy21, tonioboss, topcat275, trade3925, u.e.uktfd123, Urai Kenmart, urdivine, v.ribackov2014, Varich Patchotchai, vaverin, vebogeme, Verapan Ruampatanakit, Victor O. Setu, vkkchia, vshement, vylancetiong, wandiprojeto, Wei Deng, Welsige, why, Wilber Ramirez, william.yc.hui, willyxxx2, XP300, xwaynec, yaacob_nordin, yarofefuna, Yovie Joeliandi, Zuchi, جاملتل شهرو, જગદિશ કળસરીયા

 


Copyright MT4talk.com Forum Rules - Privacy Policy.