FREE FOREX STRATEGIES

Scalping system #19 (X-Scalper)


Submitted by Azim.

Just want to share a simple strategy that I use to trade on daily basis. It is similar to AzimXsystem, but the accuracy is far better because this system is designed to scalp the market. Since it is also based on EMA crossing, I named it
X-Scalper
.


Read entire post >>>


 


Three warnings appear when you compile the code... It is still in beta state, so you can ignore them.

Good news though. Go to http://www.pheeque.com/fx/index.html to view the report of the strategy. The graph looks really cool. :)

I have just realized a breakthrough but there still lies one little problem. Support and resistance. There is very little documentation on how to implement it. I have been playing around with fractals and fractals tell you about historical points in time when support and resistance levels were reached.

It is also possible that I am getting the implementation of the S/R in the trading strategy. Azim, can you please explain further how the S/R levels work in your strategy?

By the way, the EA is written in MQL5. So make sure that you are compiling on the meta trader 5 platform. You can get one from instaforex. It works in Nigeria at least.

N.B Why does it take so long for posts to appear?

Thanks,
Pheeque

Hy,

thank you for your source code,but too many errors when i compile...

i ve tried it on Alpari

Thanks

Hi... I have been working on the algorithmic implementation of your trading strategy for almost a week now and I seem to be having a recurring problem...

I do not think that the strategy can be coded because a program is more accurate than its human counterparts - in this case traders - therefore, some trades a human might omit, the program would not.

I might be noticing this phenomena because I am an in-experienced trader, so if there is any other programmer out there, try to check out my source code and see where I could be making mistakes.

Here it goes :

//+------------------------------------------------------------------+
//| pheequeEA_Azim_Strategy.mq5 |
//| Pheeque |
//| http://www.pheeque.com |
//+------------------------------------------------------------------+
#property copyright "Pheeque"
#property link "http://www.pheeque.com"
#property version "1.00"

input int Magic = 12347;
input int Slippage=30;
input double Lots=1.0;
input int FastPeriod=20;
input int SlowPeriod=33;
input int Hysteresis=4;

static double Bid;
static double Ask;
static int Dig;
static color clBuy = DodgerBlue;
static color clSell = Crimson;
static ulong OrderNumber;
static bool crossed_over;

double lot = 0.1;
ENUM_APPLIED_PRICE appliedPrice = PRICE_CLOSE;
double tp = 3;

int rsiPeriod = 14;
int rsiHandle;
double rsiVal[];

static double FastEmaHandle;
int FastEmaPeriod = 5;
double FastEma[];

static double SlowEmaHandle;
int SlowEmaPeriod = 12;
double SlowEma[];

int bars_to_check = 3;

datetime oldtime;

enum MQL4_OrderTypes {
OP_BUY,
OP_SELL
};

//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---

initSystem();

//---
return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---

}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
if(newBar()){
EMA_trade();
}

return;

}

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

/************** CUSTOM FUNCTIONS **********/

bool EMA_trade(){

if(CopyBuffer(SlowEmaHandle,0, 0, bars_to_check, SlowEma) > 0){

if(CopyBuffer(FastEmaHandle, 0, 0, bars_to_check, FastEma) > 0){

//Start trade logic...
if(!crossed_over && FastEma[0] > SlowEma[0]){
//Fast EMA is greater than Slow EMA and RSI is above 50, Buy

if(RSI_choice() != 1){
return false;
}

if(OrderNumber > 0){
//CloseMarket(_Symbol);
}

OrderNumber = Order( _Symbol, OP_BUY, Ask, Lots, tp, 0.0);

if(OrderNumber > 0){
crossed_over = true;
return true;
}
}else if(crossed_over && FastEma[0] < SlowEma[0]){
//Fast EMA is lower than Fast EMA and RSI is less than 50, Sell

if(RSI_choice() != -1){
return false;
}

if(OrderNumber > 0){
//CloseMarket(_Symbol);
}

OrderNumber = Order( _Symbol, OP_SELL, Bid, Lots, tp, 0.0);
if(OrderNumber > 0){
crossed_over = false;
return true;
}
}

}else{
log_error("Error copying ema_5 buffers");
}

}else{
log_error("Error copying ema_12 buffers");
}

return false;
}

/**
RSI function:
1 == Above 50
-1 == Below 50
*/

int RSI_choice(){
rsiHandle = iRSI(_Symbol, _Period, rsiPeriod, appliedPrice);

SetIndexBuffer(0, rsiVal, INDICATOR_DATA);

if(CopyBuffer(rsiHandle, 0, 0, 3, rsiVal) > 0){
if(rsiVal[0] > 50){
return(1);
}else if(rsiVal[0] < 50){
return(-1);
}
}

return (0);
}

/**
Check for new bar...
**/
bool newBar(){
datetime newtime[1];
int copied = CopyTime(_Symbol, _Period, 0, 1, newtime);
if(copied > 0){
if(oldtime != newtime[0]){
oldtime = newtime[0];
return true;
}else{
return false;
}
}else{
Alert("Error copying historical times data. - error", GetLastError());
ResetLastError();
return false;
}
}

void log_error(string error){
Alert(error, " | Error : ", GetLastError());
ResetLastError();
//return false;
}

//+------------------------------------------------------------------+
//| Closes a position at market |
//+------------------------------------------------------------------+
bool CloseMarket(string symbol)
{
int ErrorCode;
MqlTradeRequest Request;
MqlTradeResult Result;

if (!PositionSelect(symbol)) {
Print("Cannot select ", symbol, " position to close.");
}

if (PositionGetInteger(POSITION_TYPE) == ORDER_TYPE_BUY) {
Request.type = ORDER_TYPE_SELL;
Request.price = SymbolInfoDouble(symbol, SYMBOL_BID);
}
else {
Request.type = ORDER_TYPE_BUY;
Request.price = SymbolInfoDouble(symbol, SYMBOL_ASK);
}

Request.symbol = symbol;
Request.volume = PositionGetDouble(POSITION_VOLUME);
Request.deviation = Slippage;
Request.sl = 0.0;
Request.tp = 0.0;
Request.magic = Magic;
Request.action = TRADE_ACTION_DEAL;
Request.type_filling = ORDER_FILLING_AON;
Request.type_time = ORDER_TIME_GTC;

if (OrderSend(Request, Result)) {
return (true);
}

ErrorCode = GetLastError();
ResetLastError();
Print("Error ", ErrorCode, " closing ", symbol,
" position, Current Bid = ", Bid,
", Current Ask = ", Ask);

return (false);
}

//+------------------------------------------------------------------+
//| Places an order |
//+------------------------------------------------------------------+
long Order(string symbol, int Type, double Entry, double Quantity,
double TargetPrice, double StopPrice, string comment="")
{
string TypeStr;
color TypeCol;
int ErrorCode;
ulong Ticket;
double Price, FillPrice;
bool Res;

MqlTradeRequest Request;
MqlTradeResult Result;
MqlTick Quote;

SymbolInfoTick(Symbol(), Quote);

Bid = Quote.bid;
Ask = Quote.ask;

Price = NormalizeDouble(Entry, Dig);

switch (Type) {
case OP_BUY:
TypeStr = "BUY";
TypeCol = clBuy;
Request.type = ORDER_TYPE_BUY;
Request.tp = Ask + TargetPrice;
break;
case OP_SELL:
TypeStr = "SELL";
TypeCol = clSell;
Request.type = ORDER_TYPE_SELL;
Request.tp = Bid - TargetPrice;
break;
default:
Print("Unknown order type ", Type);
break;
}

Request.symbol = symbol;
Request.volume = Quantity;
Request.price = Price;
Request.deviation = Slippage;
Request.sl = StopPrice;
Request.comment = comment;
Request.magic = Magic;
Request.action = TRADE_ACTION_DEAL;
Request.type_filling = ORDER_FILLING_AON;
Request.type_time = ORDER_TIME_GTC;

Res = OrderSend(Request, Result);
if (Res) {
Ticket = Result.order;
if (Result.retcode == TRADE_RETCODE_DONE) {
FillPrice = Result.price;
if (Entry != FillPrice) {
Print("Slippage on order ", Ticket, " - Requested = ",
Entry, ", Fill = ", FillPrice, ", Current Bid = ",
Bid, ", Current Ask = ", Ask);
}
}
else {
Print("Unexpected result opening market order ",
Ticket, " (", Result.retcode, ")");
}
return (Ticket);
}

ErrorCode = GetLastError();
ResetLastError();
Print("Error opening ", TypeStr, " order (", ErrorCode, ")",
", Entry = ", Price, ", Target = ", TargetPrice,
", Stop = ", StopPrice, ", Current Bid = ", Bid,
", Current Ask = ", Ask);

return (-1);
}

void initSystem(){
if(_Digits==5){
tp*=10;
}
Dig = Digits();

tp = NormalizeDouble(tp * _Point, _Digits);

SlowEmaHandle = iMA(_Symbol, _Period, SlowEmaPeriod, 0, MODE_EMA, appliedPrice);
FastEmaHandle = iMA(_Symbol, _Period, FastEmaPeriod, 0, MODE_EMA, appliedPrice);

if(SlowEmaHandle == INVALID_HANDLE){
log_error("Error loading ema_12");
if(FastEmaHandle == INVALID_HANDLE){
log_error("Error loading ema_5");
}
}

ArraySetAsSeries(SlowEma, true);
ArraySetAsSeries(FastEma, true);

}

/** End **/
Cheers.

N.B Try testing between 15 nov 2011 and 17 nov 2011 on the EURUSD 15 minute timeframe. You earn a three pip profit :)

Hello Leandro,

Drop me an email what do you need to know. Mine is [email protected]

P/S : o = Letter 'O'

Azim

seems to me a profitable strategy but from what I see and need to spend a long time to get profits. I as a programmer (c, c + +, sharp), I am beginning MQL4 programming, and what I noticed and a language very similar to C. So I wonder if it is possible a more precise explanation, or if it is available to explain in detail all the steps I was grateful.
I await your response

Leandro

Xpworks.com?I've tried to visit but there is none

Azim

Please don't trade this, a 1000 pip cushion, this guy is having a laugh, he was $300 down on penny trades and says wait the market will turn round. LEAVE WELL ALONE, this is madness.

XPworks.com is the best I used for some EA work.
Codeguru his name. Thanks
Manish

Hai AT

The EA is good but the only problem is to program the price not to open position at either the Support/Resistance.

If anyone know any programmer who can code it free, I would be grateful.

Azim

Hi Azim
how's EA going? :)
cheers
AT

Hello again,

Sorry for my bad english.

(a) Yeslook for buy trades only. Usually I continue to trade it normally. It's better. But Only when a clear signal is in place then we took the trade. Or else we are risking more by going short again.

(b) Exactly! If you have a short trade open(Floating negatively). It would be a wise decision to have a Buy setup and TP at the next Resistance level.

Dear Azim,

Thanks for your fast response, however I do not understand what you meant by:

"...Let's say if the current trade is in a short trade. Look for buy opportunity..Bit by bit we are increasing our margin. Or 2nd option would be set your take profit at the next resistance levels."

a) Do you mean to look only for buy trades? Or just continue to trade as per normal?
b) Does the "2nd option" mean that instead of taking profit with 3 pips with new trades, it is to take the profit at the next resistance level?

Sorry for troubling you. Thanks.

Hello there,

1. In order to take a new trade while our current position is in a loss..Let's say if the current trade is in a short trade. Look for buy opportunity..Bit by bit we are increasing our margin. Or 2nd option would be set your take profit at the next resistance levels.

2. Regarding on this I'm not sure if the price will never come back again. Based on my experience it always does. Supply and demand is perhaps one of the most fundamental concepts of economics and it is the backbone of a market economy. Naturally once demand exceeds supply, price will rise. Supply exceeds demand, the price will drop. In any case before entering a trade, it is better to check the higher TF whether the price is on a support/resistance. The price will always be in our favor if we avoid buying on support and selling at resistance. As for my advice if you are quite unsure in this situation. I would recommend to open your monthly chart and apply stochastic indicator for a long-term direction.

I hope that helps.

Regards,
Azim

Dear Azim,

The concept of having no SL is pretty new to me, and it would be interesting to understand the thinking behind.

When a trade goes against me, generically speaking, it could go against me by x pips and then in y min/hours/days, to go back to profitability to hit the TP.

So the questions are:

1) In your experience, what conditions need to satisfy in order for me to take a new trade, while the current one is still in a loss? I ask this because, one may not take a new trade, if he believes that in a short time, the trade will come back to TP.

2) As I firmly believed that in forex, anything could happen. It is therefore possible that the trade could go against me thousands of pips and never retrace back to TP. For example, USDSGD has moved up around 1200 pips in matter of days, and 28 days have passed, without returning to TP. Situations like this could happen, and I will not be surprised that the currency may not return to TP in months, or even continue moving further up. So I'm not sure how to handle this situation. What is your advice on this?

Thanks a great deal!

Sorry I overlooked that, The two long trades are valid. Thank you for the highlight ^_^

Azim


 

Post new comment

CAPTCHA
We read every comment. Proceed if you're a human: