Experts: Easiest ever

 

Easiest ever:

Easiest daytrade robot ever - does the same what happened yesterday.

Author: George

 

even i like when people sharing code, but....

i don't know since when you are programming mql. but there are lots of errors in your code.

here we go.

                       
if (OrderSelect(i,SELECT_BY_POS,MODE_TIME)==true)    //MODE_TIME is not a valid option, it seems you are lucky and it works...

            if (OrderSelect(i,SELECT_BY_POS,MODE_TIME)==true)
             if (OrderType()==OP_BUY && Hour()>(marketclosehour-1))
             OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE);
        
            // following code gets executed even when OrderSelect() is false, because you have wrong blocking. 
            if (OrderType()==OP_SELL && Hour()>(marketclosehour-1))
            OrderClose(OrderTicket(),OrderLots(),Ask,0,CLR_NONE);
     {   //why this new block here??? i am quite surprised that it will compile...
     if (c1>o1 && OrdersTotal()<1 && Hour()<1)
     OrderSend(Symbol(),OP_BUY,lot,Ask,0,0,0,"Easiest ever",0,0);
 
     if (c1<o1 && OrdersTotal()<1 && Hour()<1)
     OrderSend(Symbol(),OP_SELL,lot,Bid,0,0,0,"Easiest ever",0,0);
      {  // adb here the same. why openig a block?

here is the code rewritten, check out the differences an try to understand why i have modified it in that way, if you have more questions you can write me a pm or put the code in the forum

//+------------------------------------------------------------------+
//| Easiest ever - daytrade robot                                    |
//+------------------------------------------------------------------+
 
extern double lot = 1;
extern double marketclosehour = 20; // on friday
 
int start()
  {
     double c1 = iClose(NULL,PERIOD_D1,1);
     double o1 = iOpen(NULL,PERIOD_D1,1);
     if (c1>o1 && OrdersTotal()<1 && Hour()<1)
       OrderSend(Symbol(),OP_BUY,lot,Ask,0,0,0,"Easiest ever",0,0);
 
     if (c1<o1 && OrdersTotal()<1 && Hour()<1)
       OrderSend(Symbol(),OP_SELL,lot,Bid,0,0,0,"Easiest ever",0,0);
 
     if (Hour()>(marketclosehour-1)){ 
       for (int i=OrdersTotal()-1; i>=0; i--){
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true){
           OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0,CLR_NONE);
         }
       }
     }
   return(0);
  }
//+------------------------------------------------------------------+

and befor thinking of putting live or on demo:

-your ea will NOT work with other EA's or manual open orders. check out MagicNumber() for that issue

-no error handling!!!

-no normalized values!

i dont know what you mean by it closes on friday, but i dont see it in the code, every day at 20.00 the order get's closed..

 

You can see, this is my first expert advisor, i have just started learning to code this month, so i still don't really know, what i'm doing. I was proud to see it working on backtest, better than many (much more difficult) experts on the internet.

"i dont know what you mean by it closes on friday, but i dont see it in the code, every day at 20.00 the order get's closed.. " - it is to avoid leaving opened position in weekend; at this timezone and broker the market closes every friday at 20.45.

(("here is the code rewritten" - i compiled it, but it does not work. Opens one position only, and holds it until going out of margin.))

I know that, my codes are to be parts of a "real expert" at the most, but i wanted to get comments because i really want to learn this coding, and i welcome everything, what can help.

Otherwise i did not want to copy codes from other experts (error handling, normalized values) what i still don't know how to code alone, because of the copyrights.

You may see, there isn't any copyright in this code. First of all i try to share the principle or formula, what i discover, and which seems to work. I think there are many good programmers on this site.. if they think my code is useful, they will correct the mistakes in it while i cannot.

Please take a look at my newest work, (contains the same number of mistakes but can be compiled and backtested) this one gives the best results so far:

//+------------------------------------------------------------------+
//| Swing Third Easiest                                              |
//+------------------------------------------------------------------+
extern double lot = 5,
              ts  = 70,
              sl  = 100;
int start()
  {
     double h1 = iHigh(NULL,1440,0);
     double l1 = iLow(NULL,1440,0); 
     double o1 = iOpen(NULL,1440,0);
     
     {
     if ((Bid>o1 && (o1-l1)>15*Point && OrdersTotal()<1) || (OrderType()==OP_BUY && OrdersTotal()>=1 && 
          OrdersTotal()<3 && Bid>OrderOpenPrice()+20*Point))
     OrderSend(Symbol(),OP_BUY,lot,Ask,0,Ask-sl*Point,0,"Swing Third Easiest",0,0);
     if ((Ask<o1 && (h1-o1)>15*Point && OrdersTotal()<1) || (OrderType()==OP_SELL && OrdersTotal()>=1 && 
          OrdersTotal()<3 && Ask<OrderOpenPrice()-20*Point))
     OrderSend(Symbol(),OP_SELL,lot,Bid,0,Bid+sl*Point,0,"Swing Third Easiest",0,0);
       {
          for (int i=0; i<OrdersTotal(); i++)
         {                                               
            if (OrderSelect(i,SELECT_BY_POS,MODE_TIME)==true)
             if (OrderType()==OP_BUY && Bid-ts*Point>OrderStopLoss()+5*Point)
             OrderModify(OrderTicket(),OrderOpenPrice(),Bid-ts*Point,0,0,CLR_NONE);
        
            if (OrderType()==OP_SELL && Ask+ts*Point<OrderStopLoss()-5*Point)
             OrderModify(OrderTicket(),OrderOpenPrice(),Ask+ts*Point,0,0,CLR_NONE);
         }   
       }
     }
   return(0);
  }
//+------------------------------------------------------------------+

EUR/USD H1 2010.01.01 - 07.27. Deposit: 10000, lots: 5(!).

Well, it is luck only, nothing else, i know too..:)

Thank you for your help!

 

hi,

you are right, i have made a mistake in the orderclose() i edited the code and now it should work.

i never meant to offend you, i like when people share code. i only want to show you some mistakes you made. i hope you are here to learn something, and so i wanted to show you where you made some syntax errors.

btw, your OrderCloseLoop() is dangerous,while it works if you have only one order open, it won't work with more then one open order, you have to loop backwards trough your Orders.

your ea closes every day at 20.00 not only on fridays.

logic of your new EA seams to work fine, i like the curve of the balance. i think you should maybe hold on that, maybe some kind of filter to avoid some loosing trades. but if i only watch at the equity/balance i have seen worser EA's.

and keep in mind, often the simplest strategies can beat 10 combinated indicators.

 

Hi!

I am quite grateful for your comments and help. I am absolutely beginner in coding, but i hope i will be able to share some really good experts this year. Mostly i work on this only because my plan is to create an "install and forget" style expert. That's why this ea closes every day at 20.00, not only on fridays. This way users don't need to keep the celebrities in mind, when the market is not opened for 5 days in a week.

I have tested thousands of free experts, but i still did not find one, to which i would give money. I think, if one creates an ea which is suited for working on real account, that person will not share it for free - he (or she) will start to sell it. If you know any exeption on the internet, please show me that.

Thanks

&

Regards

 

I too was wondering what that extra bracket 'block' was doing in there. I figured it would throw an 'unbalanced {' error

 
It was on the right side of the eurusd m1 demo trade which I use to test everything to see how it behaves and to not waste time or expense or energy, but it apparently does not have any trail or stop because it gave away a huge profit and went under and meandered all over the place for huge dd and waste of time. It's garb dude