SpreadProbe

0
(0)
Name:
Simple Scalping EA
Author: picassoinaction (2011.11.07 11:45)
Downloaded: 24127
Download:
SpreadProbe 1
 Scalping EA.mq4 (19.8 Kb) View

Description:

Very simple scalping EA, no Indicators. Logic is based on very fast price movements.

Here is my scalping EA idea works most of the time, but needs to be better programmed.

If some1 can help to modify it so it can be used on many pairs at the same time.

Idea is very simple, no indicators at all.
it keeps updating BuyStop and SellStop orders with each price movements.
And when the market becomes heavy or news it won't get a chance to get updated quick... which means very fast price movement in one of the directions. This practically guarantees 10-15 pips movement.

If some1 can help me to code it properly it would be very cool.. For the last 3 month i have a ratio of this working 4-6 wins vs 1 loss. ( and i noticed the loss mostly because i programmed wrong). Stop Loss should be adjusted to 5-7 pips ( if broker allowed)Works fine on Alpari US.

PS. For some reason and i cant identify the problem- after executing the order it may not send another order till i disable and re=enable EA ( gotta be a bug somewhere). Would appreciated any help.)
oops. One more thing, i used the coding template from IBFX scripts and modified for my use.

Thanks for the Help... And ignore the grammar.

22 comments: 1 2 3   To post a new comment, please log in or register

"For the last 3 month i have a ratio of this working 4-6 wins vs 1 loss"

What currency pair & TF you use it.

Can I put TP=12, SL=0.

Buy Stop & Sell Stop only gap 5 pips from market price?

What the result, more profit or more loss?

26.12.2013 07:46 ardi8888

picassoinaction:
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 can you add ?

extern int Distance = 100;

pls add sometime we want 100 PIP some time 80 sometim 150

 

20.12.2013 03:53 apnihost

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

 

02.11.2012 11:03 stormer

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.

20.09.2012 14:08 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.

19.09.2012 13:30 nlenz

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 , [email protected]" //( 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;
}
26.01.2012 02:50 1105

Get free profitable EA: http://tinyurl.com/86ounpw
25.01.2012 16:35 brg

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.

09.01.2012 08:46 1105

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

06.01.2012 12:51 1105

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

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?



Author: Forex Wiki Team
We are a team of highly experienced Forex Traders [2000-2023] who are dedicated to living life on our own terms. Our primary objective is to attain financial independence and freedom, and we have pursued self-education and gained extensive experience in the Forex market as our means to achieve a self-sustainable lifestyle.