Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 04-20-2006, 12:26 AM
Mohammed's Avatar
Senior Member
 
Join Date: Mar 2006
Posts: 119
Mohammed is on a distinguished road
Post ِِِِِAli EA

Salam,

This is an EA I want to share!
Its name "Ali" is the name of one of my friends who suggest the idea!
The idea behind it is:

The EURUSD go the opposite way of the USDCHF,
Well!
We place 2 Buy or Sell orders, one for the EURUSD and one for USDCHF and when the price of one of them go up to 5 pips we place another order of this currency.
We take the profit by calculating all the opened positions (3 or 2) and close them all.

No big profit and no big loss!
Attached Files
File Type: mq4 Ali.mq4 (3.6 KB, 266 views)
__________________
There is a fine line between freedom of expression and hate literature.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2006, 01:27 AM
Shahzadfx's Avatar
Senior Member
 
Join Date: Dec 2005
Location: USofA
Posts: 381
Shahzadfx is on a distinguished road
salaam

Quote:
Originally Posted by Mohammed
Salam,

This is an EA I want to share!
Its name "Ali" is the name of one of my friends who suggest the idea!
The idea behind it is:

The EURUSD go the opposite way of the USDCHF,
Well!
We place 2 Buy or Sell orders, one for the EURUSD and one for USDCHF and when the price of one of them go up to 5 pips we place another order of this currency.
We take the profit by calculating all the opened positions (3 or 2) and close them all.

No big profit and no big loss!
Salaam Mohammed,
Thank you for sharing an ea.
I want a little more explaination how if works, if you don't mind.
Peace.
SFX
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2006, 05:53 AM
Senior Member
 
Join Date: Apr 2006
Posts: 158
InTrance is on a distinguished road
I was working on something similar. So you close positions when you have P/L of +5?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 04-20-2006, 06:31 AM
Member
 
Join Date: Apr 2006
Posts: 46
sampson is on a distinguished road
Interesting, I'll let it run over night and see what happens.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 04-20-2006, 09:26 AM
Fast_cris's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 197
Fast_cris is on a distinguished road
Quote:
Originally Posted by Mohammed
Salam,

This is an EA I want to share!
Its name "Ali" is the name of one of my friends who suggest the idea!
The idea behind it is:

The EURUSD go the opposite way of the USDCHF,
Well!
We place 2 Buy or Sell orders, one for the EURUSD and one for USDCHF and when the price of one of them go up to 5 pips we place another order of this currency.
We take the profit by calculating all the opened positions (3 or 2) and close them all.

No big profit and no big loss!

Thanks for EA my friend,

Who realy works... i have 2 buys on eur/usd and 1 buy usd/chf.

What is the settings.. is default? and the best time frame?

Thanks

Fast_cris
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 04-20-2006, 02:51 PM
Member
 
Join Date: Apr 2006
Posts: 46
sampson is on a distinguished road
Time frame doesn't matter. You can use the default settings.

But, it doesn't seem to be closing trades? I looked at the code and I'm not sure why. I'll have another look.

I also think I might change it so that it opens a Lot of USD/CHF with the same dollar value as the lot of EUR/USD, because right now the hedge is a bit lop-sided. Or was that intentional?

Last edited by sampson; 04-20-2006 at 02:53 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 04-20-2006, 02:54 PM
DOMIANDR000's Avatar
Member
 
Join Date: Dec 2005
Posts: 55
DOMIANDR000 is on a distinguished road
I've tried this strategy before, well the difference in movement is depicted in the EUR/CHF pair, since you would be indiretly buying or seling it when you enter into the 2 positions.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 04-20-2006, 06:32 PM
Mohammed's Avatar
Senior Member
 
Join Date: Mar 2006
Posts: 119
Mohammed is on a distinguished road
Post Update!

Salam,

The previous version was not able to close the opened position.
Please try this verison!

The idea:

The EURUSD go in the opposite direction of USDCHF.
When we buy EURUSD and USDCFH it's very like that we buy EURUSD and sell EURUSD. but the only advantage is that some brokers limit you to hedge your positions by buy and selling the same currency.
The both of opened positions now going in contrary directions and they maintain the loss (it's almost the spread of opening 2 passions).
When one of the two currency make profit (5 pips) we open another position of this currency.
We take profit at 5Pips and close all the poisons or we close them when we make 10 Pips loss.

PHP Code:
//---- Includes
#include <stdlib.mqh>
//---- Trades limits
extern double ProfitToTake 5;
extern double LossToPrevent = -15;
extern int Sell 1// use 0 for Buy
extern double Lots 0.1;
extern int Slippage 5;
extern int Level=5;
//--- Global variables
int MagicNumber 101090;
string ExpertComment "Ali";
 
//+------------------------------------------------------------------
int init()
{
return(
0);
}
int deinit() 
{
return(
0);
}
//+------------------------------------------------------------------
 
//+------------------------------------------------------------------+
int start()
{
int cnt,total;
 
if(
Bars<100) {Print("bars less than 100"); return(0);}
 
 
 
total OrdersTotal();
 
if(
total 1
{
if(
Sell==0)
{
RefreshRates();
OrderSend("EURUSD",OP_BUY,Lots,MarketInfo("EURUSD",MODE_ASK),Slippage,0,MarketInfo("EURUSD",MODE_ASK)+100*Point,ExpertComment,MagicNumber,0,Green);
RefreshRates(); 
OrderSend("USDCHF",OP_BUY,Lots,MarketInfo("USDCHF",MODE_ASK),Slippage,0,MarketInfo("USDCHF",MODE_ASK)+100*Point,ExpertComment,MagicNumber,0,Green);
 
}
else
{
RefreshRates();
OrderSend("EURUSD",OP_SELL,Lots,MarketInfo("EURUSD",MODE_BID),Slippage,0,MarketInfo("EURUSD",MODE_BID)-100*Point,ExpertComment,MagicNumber,0,Red);
RefreshRates(); 
OrderSend("USDCHF",OP_SELL,Lots,MarketInfo("USDCHF",MODE_BID),Slippage,0,MarketInfo("USDCHF",MODE_BID)-100*Point,ExpertComment,MagicNumber,0,Red);
}
return(
0);
}
ProfitProtect(); 
return(
0);
}
//+------------------------------------------------------------------+
void ProfitProtect()
{
int total OrdersTotal();
double MyCurrentProfit=0;
for (
int cnt cnt total cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (
OrderMagicNumber() == MagicNumber)
{
MyCurrentProfit += OrderProfit();
 
RefreshRates();
 
if (
OrderProfit()>=(Level) && total 3)
{
if(
OrderType() ==OP_BUY )
{
OrderSend(OrderSymbol(),OP_BUY,Lots,MarketInfo(OrderSymbol(),MODE_ASK),Slippage,0,MarketInfo(OrderSymbol(),MODE_ASK)+100*Point,ExpertComment,MagicNumber,0,Green);
}
if(
OrderType() ==OP_SELL )
{
OrderSend(OrderSymbol(),OP_SELL,Lots,MarketInfo(OrderSymbol(),MODE_BID),Slippage,0,MarketInfo(OrderSymbol(),MODE_BID)-100*Point,ExpertComment,MagicNumber,0,Red);

}
 
}
}
 
 
if(
MyCurrentProfit >= ProfitToTake)
CloseAll();
if(
MyCurrentProfit <= LossToPrevent)
CloseAll();
}
 
void CloseAll()
{
int total OrdersTotal();
 
for (
int cnt cnt <= total cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if (
OrderMagicNumber() == MagicNumber)
{
RefreshRates();
if(
OrderType()==OP_BUY)
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,Violet);
if(
OrderType()==OP_SELL
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,Violet);
}
}

__________________
There is a fine line between freedom of expression and hate literature.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 04-20-2006, 07:12 PM
Fast_cris's Avatar
Senior Member
 
Join Date: Dec 2005
Posts: 197
Fast_cris is on a distinguished road
Red face

Quote:
Originally Posted by Mohammed
Salam,

The previous version was not able to close the opened position.
Please try this verison!

The idea:

The EURUSD go in the opposite direction of USDCHF.
When we buy EURUSD and USDCFH it's very like that we buy EURUSD and sell EURUSD. but the only advantage is that some brokers limit you to hedge your positions by buy and selling the same currency.
The both of opened positions now going in contrary directions and they maintain the loss (it's almost the spread of opening 2 passions).
When one of the two currency make profit (5 pips) we open another position of this currency.
We take profit at 5Pips and close all the poisons or we close them when we make 10 Pips loss.

PHP Code:
//---- Includes
#include <stdlib.mqh>
//---- Trades limits
extern double ProfitToTake 5;
extern double LossToPrevent = -15;
extern int Sell 1// use 0 for Buy
extern double Lots 0.1;
extern int Slippage 5;
extern int Level=5;
//--- Global variables
int MagicNumber 101090;
string ExpertComment "Ali";
 
//+------------------------------------------------------------------
int init()
{
return(
0);
}
int deinit() 
{
return(
0);
}
//+------------------------------------------------------------------
 
//+------------------------------------------------------------------+
int start()
{
int cnt,total;
 
if(
Bars<100) {Print("bars less than 100"); return(0);}
 
 
 
total OrdersTotal();
 
if(
total 1
{
if(
Sell==0)
{
RefreshRates();
OrderSend("EURUSD",OP_BUY,Lots,MarketInfo("EURUSD",MODE_ASK),Slippage,0,MarketInfo("EURUSD",MODE_ASK)+100*Point,ExpertComment,MagicNumber,0,Green);
RefreshRates(); 
OrderSend("USDCHF",OP_BUY,Lots,MarketInfo("USDCHF",MODE_ASK),Slippage,0,MarketInfo("USDCHF",MODE_ASK)+100*Point,ExpertComment,MagicNumber,0,Green);
 
}
else
{
RefreshRates();
OrderSend("EURUSD",OP_SELL,Lots,MarketInfo("EURUSD",MODE_BID),Slippage,0,MarketInfo("EURUSD",MODE_BID)-100*Point,ExpertComment,MagicNumber,0,Red);
RefreshRates(); 
OrderSend("USDCHF",OP_SELL,Lots,MarketInfo("USDCHF",MODE_BID),Slippage,0,MarketInfo("USDCHF",MODE_BID)-100*Point,ExpertComment,MagicNumber,0,Red);
}
return(
0);
}
ProfitProtect(); 
return(
0);
}
//+------------------------------------------------------------------+
void ProfitProtect()
{
int total OrdersTotal();
double MyCurrentProfit=0;
for (
int cnt cnt total cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (
OrderMagicNumber() == MagicNumber)
{
MyCurrentProfit += OrderProfit();
 
RefreshRates();
 
if (
OrderProfit()>=(Level) && total 3)
{
if(
OrderType() ==OP_BUY )
{
OrderSend(OrderSymbol(),OP_BUY,Lots,MarketInfo(OrderSymbol(),MODE_ASK),Slippage,0,MarketInfo(OrderSymbol(),MODE_ASK)+100*Point,ExpertComment,MagicNumber,0,Green);
}
if(
OrderType() ==OP_SELL )
{
OrderSend(OrderSymbol(),OP_SELL,Lots,MarketInfo(OrderSymbol(),MODE_BID),Slippage,0,MarketInfo(OrderSymbol(),MODE_BID)-100*Point,ExpertComment,MagicNumber,0,Red);

}
 
}
}
 
 
if(
MyCurrentProfit >= ProfitToTake)
CloseAll();
if(
MyCurrentProfit <= LossToPrevent)
CloseAll();
}
 
void CloseAll()
{
int total OrdersTotal();
 
for (
int cnt cnt <= total cnt++)
{
OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if (
OrderMagicNumber() == MagicNumber)
{
RefreshRates();
if(
OrderType()==OP_BUY)
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,Violet);
if(
OrderType()==OP_SELL
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,Violet);
}
}


Hi my friend,

I have made some backtest to the new version... i used original settings and in atachment is the results.


What is the best settings for this?

Fast_cris
Attached Images
File Type: gif ali.gif (5.3 KB, 144 views)
Attached Files
File Type: htm ali.htm (669.9 KB, 88 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 04-20-2006, 07:20 PM
Mohammed's Avatar
Senior Member
 
Join Date: Mar 2006
Posts: 119
Mohammed is on a distinguished road
Quote:
Originally Posted by Fast_cris
Hi my friend,

I have made some backtest to the new version... i used original settings and in atachment is the results.


What is the best settings for this?

Fast_cris
Salam my friend Fast_cris,

These kind of EAs can't be backtested!
That's because:

Trading is permitted for the symbol under test only, no portfolio testing
Attempts to trade using another symbol will return error


Please refer to:
http://www.metaquotes.net/experts/ar.../tester_limits
__________________
There is a fine line between freedom of expression and hate literature.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT. The time now is 11:10 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.