Experts: Simple Scalping EA - page 2

 
afterburner.pl:

Hello,

I'm backtesting this EA on EUR/USD and it don't trade.

Do you have any idea what am I doing wrong ?



Hi

You cant back test the EA. You can test this EA only in demo mode on live servers, since it depends on the current market moves.

 

@ Picassoinaction...or anybody can update/upload the best working version?

Thanks

 
cybertrade:

@ Picassoinaction...or anybody can update/upload the best working version?

Thanks


I just hope no one loses sight of this EA. This is a MONEY MAKER !!!!!!!!!!! Few bugs, which can be corrected, but definetly not worth tossing aside.
 

Hi Picassociation,

I like your idea, which reminds me of another EA I'm studying right now, its name is STOP HUNTER,made by MT CODER.

I really find some similar thing between these two EAs, not only both Scalping EA(my favorite type),but also sth else, you will find it after you read through it.

I haven't worked into details of your EA, but I will definitely do, and hope I can give your some good suggestions to improve its performance))

 

Yan,

I feel strange when I tried this EA on a live demo account. When price moves, BUY_STOP and SELL_STOP also move accordingly, distance between current price and OrderOpenPrice() are always the same, it works like magnetic iron: if distance is too big, pending order will move towards current price;vice versa,if distance is too small, pending order will move away from current price. Then my question is, when will it be executed?

another question is about detailed codes,I find in function UpdateD() there is a sentence as "if ((OrderOpenPrice()+Bid)>0.007) and if ((OrderOpenPrice()+Bid)<0.0005)", I'm confused, should it be sth like "Bid-OrderOpenPrice()" ?

Then I applied it for Backtest, I used tick data and found it can be tested, but when a pending order is executed, the test would stop, with two pending orders left as well. I am not sure whether it's the problem you mentioned before, if yes, I guess it's caused by program logic that when a pending order is executed, the other pending order is not deleted and more pending orders will be opened again.

The only pity is, the possibility of pending orders to be executed is too small, most of time you need to wait patiently, whlie the result of waiting is not so dramatic, just very small profit...

maybe I have some misunderstanding, please correct me and I'm very pleasant to make this EA better and better. thanks.

 
Get free profitable EA: http://tinyurl.com/86ounpw
 
1105:

Yan,

I feel strange when I tried this EA on a live demo account. When price moves, BUY_STOP and SELL_STOP also move accordingly, distance between current price and OrderOpenPrice() are always the same, it works like magnetic iron: if distance is too big, pending order will move towards current price;vice versa,if distance is too small, pending order will move away from current price. Then my question is, when will it be executed?

another question is about detailed codes,I find in function UpdateD() there is a sentence as "if ((OrderOpenPrice()+Bid)>0.007) and if ((OrderOpenPrice()+Bid)<0.0005)", I'm confused, should it be sth like "Bid-OrderOpenPrice()" ?

Then I applied it for Backtest, I used tick data and found it can be tested, but when a pending order is executed, the test would stop, with two pending orders left as well. I am not sure whether it's the problem you mentioned before, if yes, I guess it's caused by program logic that when a pending order is executed, the other pending order is not deleted and more pending orders will be opened again.

The only pity is, the possibility of pending orders to be executed is too small, most of time you need to wait patiently, whlie the result of waiting is not so dramatic, just very small profit...

maybe I have some misunderstanding, please correct me and I'm very pleasant to make this EA better and better. thanks.

Finally, I revised it and applied some methods from MT-CODER's HUNTER EA. It can be backtested now and no hangon any more. But the only issue is, it must be applied in very low spread environmnet, otherwise no profit!!! I just treat it as an ending to my thoughts about this thread....

//+------------------------------------------------------------------+

//|                                                  Scalping EA.mq4 |
//|                       Copyright ?2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Interbank FX, LLC" //( original template)
 
#property copyright "PicassoInActions , 123@donothing.us" //( original idea)
 
 
#include <stderror.mqh> 
//+------------------------------------------------------------------+
//| Global Variables / Includes                                      |
//+------------------------------------------------------------------+
datetime   CurrTime = 0;
datetime   PrevTime = 0;
     int  TimeFrame = 0;
     int      Shift = 1;
     
     int  SymDigits;
  double  SymPoints;
     int  POS_n_BUY;
     int  POS_n_SELL;
     int  POS_n_BUYSTOP;
     int  POS_n_SELLSTOP;
     int  POS_n_total;
  double  OrderLevelB;
  double  OrderLevelS;
 
//+------------------------------------------------------------------+
//| Expert User Inputs                                               |
//+------------------------------------------------------------------+
extern double               Lots = 0.01;
extern double            MinLots = 0.01;
extern    int              magic = 1111;
extern    int         TakeProfit = 30; 
extern    int           StopLoss = 50; 
extern    int          MaxBuyPos = 1;//maximum Buy positions at once
extern    int         MaxSellPos = 1;//maximum Sell positions at once
extern    int           Distance = 100;
extern    int               Near = 15;
extern    int                Far = 100;
 
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{
 return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() 
{ 
 return(0); 
}
 
//+------------------------------------------------------------------+
//| Expert start function                                            |
//+------------------------------------------------------------------+
int start() 
{    
 int cnt, total;
 int ticketB, ticketS, ticketC,ticketM;//ticket number of Buy,Sell,Close,Modify
 int MaxOpenPos = MaxBuyPos + MaxSellPos;
//----Count Positions 
 count_position(); 
 RefreshRates();
 
//----Open Pending Orders 
 if(POS_n_BUYSTOP + POS_n_BUY < MaxBuyPos && POS_n_SELL == 0) 
 {
  ticketB=OrderSend(Symbol(),OP_BUYSTOP,Lots,Ask+Distance*Point,1,0,0,"Scalping EA",magic,0,Green);
  if(ticketB>0)
  {
   if(OrderSelect(ticketB,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY Stop order sent : ",OrderOpenPrice());
  }
  else 
  {
   Print("Error sending BUY Stop order : ",GetLastError()); 
   return(0); 
  }
  return(0);   
 }
 
 if(POS_n_SELLSTOP + POS_n_SELL < MaxSellPos && POS_n_BUY == 0) 
 {
  ticketS=OrderSend(Symbol(),OP_SELLSTOP,Lots,Bid-Distance*Point,1,0,0,"Scalping EA",magic,0,Red);
  if(ticketS>0)
  {
   if(OrderSelect(ticketS,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL Stop order sent : ",OrderOpenPrice());
  }
  else 
  {
   Print("Error sending SELL Stop order : ",GetLastError()); 
   return(0); 
  }
  return(0);  
 }
 
//---- delete the useless positions && achieve the hidden TakeProfit and StopLoss
  total=OrdersTotal();
  for(cnt=total-1;cnt>=0;cnt--)
  {
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
   if(OrderMagicNumber() != magic) break;
//----   
   if(OrderType()==OP_BUYSTOP && POS_n_SELL != 0  && OrderSymbol() == Symbol())  OrderDelete(OrderTicket());
   if(OrderType()==OP_SELLSTOP && POS_n_BUY != 0 && OrderSymbol() == Symbol())  OrderDelete(OrderTicket());
//----
   RefreshRates();
   if(OrderType()==OP_BUY  && OrderSymbol() == Symbol())
   {
    if(Ask >= OrderOpenPrice() + TakeProfit*Point || Bid <= OrderOpenPrice() - StopLoss*Point)
    ticketC = OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
//    if(Bid <= OrderOpenPrice() - StopLoss*Point) {Lots=2*Lots;ticketC = OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);}
//    if(Ask >= OrderOpenPrice() + TakeProfit*Point) {Lots=MinLots;ticketC = OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);}
    if(ticketC <= 0) {Print("Error closing order : ",GetLastError()); }
   }  
   
//----   
   RefreshRates();
   if(OrderType()==OP_SELL && OrderSymbol() == Symbol())
   {
    if(Bid <= OrderOpenPrice() - TakeProfit*Point || Ask >= OrderOpenPrice() + StopLoss*Point)
    ticketC = OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
//    if(Ask >= OrderOpenPrice() + StopLoss*Point) {Lots=2*Lots;ticketC = OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);}
//    if(Bid <= OrderOpenPrice() - TakeProfit*Point) {Lots=MinLots;ticketC = OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);}
    if(ticketC <= 0) {Print("Error closing order : ",GetLastError()); }
   }  
  }
//----Update Pending Orders in accordance with Price Movements
  RefreshRates();
  total=OrdersTotal();
  for(cnt=total-1;cnt>=0;cnt--)
  {
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
   if(OrderMagicNumber() != magic) break;
//----   
   if(OrderType()==OP_BUYSTOP  && OrderSymbol() == Symbol())
   {
    if((OrderOpenPrice()-Ask)<=Point*Near || (OrderOpenPrice()-Ask)>=Point*Far )
    {
     ticketM=OrderModify(OrderTicket(),Ask+Distance*Point,0,0,0,CLR_NONE );
     if(ticketM <= 0) {Print("Error modify order : ",GetLastError()); }
    }
   }
//----
   if(OrderType()==OP_SELLSTOP && OrderSymbol() == Symbol())   
   {
    if((Bid-OrderOpenPrice())<=Point*Near || (Bid-OrderOpenPrice())>=Point*Far )
    {
     ticketM=OrderModify(OrderTicket(),Bid-Distance*Point,0,0,0,CLR_NONE );
     if(ticketM <= 0) {Print("Error modify order : ",GetLastError()); }
    }
   }
  }
}
//+------------------------------------------------------------------+
//| Seperate Functions                                               |
//+------------------------------------------------------------------+
void count_position()
{
    POS_n_BUY  = 0;
    POS_n_SELL = 0;
    
    POS_n_BUYSTOP = 0;
    POS_n_SELLSTOP = 0;
    
    for( int i = 0 ; i < OrdersTotal() ; i++ )
    {
     if( OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) == false || OrderMagicNumber() != magic) break;
//     if( OrderSymbol() != Symbol() )   continue; 
     if( OrderType() == OP_BUY  && OrderSymbol() == Symbol() && OrderMagicNumber()==magic) POS_n_BUY++;
     
     else
     if( OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber()==magic) POS_n_SELL++;
     
     else   
     if( OrderType() == OP_BUYSTOP  && OrderSymbol() == Symbol() && OrderMagicNumber()==magic)
     {
      POS_n_BUYSTOP++;
      OrderLevelB = OrderOpenPrice();
     }
     
     else
     if( OrderType() == OP_SELLSTOP  && OrderSymbol() == Symbol() && OrderMagicNumber()==magic)
     {
      POS_n_SELLSTOP++;
      OrderLevelS = OrderOpenPrice();
     }        
    }
        
    POS_n_total = POS_n_BUY + POS_n_SELL + POS_n_BUYSTOP + POS_n_SELLSTOP;
}
 
1105:

Finally, I revised it and applied some methods from MT-CODER's HUNTER EA. It can be backtested now and no hangon any more. But the only issue is, it must be applied in very low spread environmnet, otherwise no profit!!! I just treat it as an ending to my thoughts about this thread....

..... (code)

This last code works. However, in live trading it won't work if you already have your own open trade/s. (The backtest works because it assumes no other trades are open only this EA's). To make it work even so in a real account, change all 3 occurrences of "break;" to -> "continue;" (without the double quotes " ). Also, it (after my fix) seems to be profitable only on "good" brokers. (i.e. It lost on a broker which is slow and has a 3 pip E/U spread, while it is profitable so far [after 18 hours and 9 trades] on a broker with average spread of 1.6 pips for the E/U, fast execution, no dealing desk etc.). I think it will only gain for the EUR/USD, the timeframe doesn't matter you get the same results, but I use H1 anyway.
 
nlenz:
1105:

Finally, I revised it and applied some methods from MT-CODER's HUNTER EA. It can be backtested now and no hangon any more. But the only issue is, it must be applied in very low spread environmnet, otherwise no profit!!! I just treat it as an ending to my thoughts about this thread....

..... (code)

This last code works. However, in live trading it won't work if you already have your own open trade/s. (The backtest works because it assumes no other trades are open only this EA's). To make it work even so in a real account, change all 3 occurrences of "break;" to -> "continue;" (without the double quotes " ). Also, it (after my fix) seems to be profitable only on "good" brokers. (i.e. It lost on a broker which is slow and has a 3 pip E/U spread, while it is profitable so far [after 18 hours and 9 trades] on a broker with average spread of 1.6 pips for the E/U, fast execution, no dealing desk etc.). I think it will only gain for the EUR/USD, the timeframe doesn't matter you get the same results, but I use H1 anyway.

O.K. I'm not sure anymore that it is profitable even under good conditions, because it lost more than the backtest indicated it would after 2 days of trading. It might do better in the future or under other brokers or conditions, and certainly 2 days isn't enough to know for sure, but I've stopped my live test.
 

Hello Sir,

i want change PIP for Buy Stop and Sell Stop when entry oder, now it is 100 PIP, i want < 100 pip. Please Guide me.


i can not use for another EUR/USD, i want use for other symbol


Help me

Reason: