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 03-05-2006, 10:06 AM
Member
 
Join Date: Jan 2006
Posts: 51
white_tiger is on a distinguished road
Smile [request]simple hedging EA

hi, i have a strategy that i posted at http://www.forex-tsd.com/suggestions...ng-system.html
i'll apreciate if somebody make an EA for this strategy & help me to test that strategy
welcome to any improvement...
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 06-05-2006, 01:06 PM
Bongo's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 496
Bongo is an unknown quantity at this point
hedging

Hi,
Here is help from CodersGuru:
HEDGING:
http://www.metatrader.info/node/113

Today we are going to talk about a very important trading idea and take further step by creating a simple Expert Advisor for this idea.
We are going to study the "Hedging"
What's the meaning of Hedging?
Hedging is a method the Forex trader take to reduce the risk involved in holding an investment. You can think in it as the insurance!
When you open an EURUSD position, there are only two future possibilities, the price moves in your direction or it moves against you. Hedging this position is the method you'll take to reduce the risk of the open EURUSD position by opening an opposite position (Buy when you've already sold and sell when you've already bought).
Hedging methods in Forex:
Opening an opposite position as mentioned above is is not the only method of hedging positions in Forex. And a lot of brokers do not allow their client to open two opposite positions of the same currency at the same time!
There are a lot of hedging methods but we are going to study one of them that works and in the same time no brokers will prevent you from using this method!
Our method is hedging the position by opening the same position (buy/sell) for another currency pairs that has negative correlation with the first currency we trade.
Negative correlation?
The correlation is the relation between the currency pairs. When two pairs have a positive correlation that means they are going the same direction. i.e. The EURUSD has a positive correlation with GBPUSD. (figure 1).

When two pairs have a negative correlation that means they are going the opposite direction. i.e. The EURUSD has a negative correlation with USDCHF. (figure 2).
Note: More details about correlation will be discuss in a separated article!
Our Expert advisor:
We are going to implement the idea of hedging by using the negative correlation between two pairs to write a simple Expert advisor.
Our expert advisor will open two positions (buy) of EURUSD and USDCHF (no much no less). Just notice the sum of the two trades and you will see clearly how the two positions have been hedged.
Note: You can take this Expert further more if you want to double the lot size of one of the opened traders when it make profit. or you can close the two opened positions when the total profit is a specified value (ex: 100 Pips).
Note: This kind of Expert Advisors (which trade more than one currency pair) couldn't be tested with MetaTrader Strategy Tester due the limitation detailed here:
"Trading is permitted for the symbol under test only, no portfolio testing
Attempts to trade using another symbol will return error"
http://www.metaquotes.net/experts/ar.../tester_limits

The code:

//+------------------------------------------------------------------+
//| Hedging.mq4 |
//| Coders Guru |
//| http://www.forex-tsd.com |
//+------------------------------------------------------------------+

#property copyright "Coders Guru"
#property link "http://www.forex-tsd.com"

extern string Sym_1 = "EURUSD";
extern string Sym_2 = "USDCHF";

extern double Lots = 1;
extern int Slippage = 5;

bool Sell = true;

//+------------------------------------------------------------------+
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(Sym_1,OP_BUY,Lots,MarketInfo(Sym_1,MODE_ ASK),Slippage,0,MarketInfo(Sym_1,MODE_ASK)+1000*Po int,"Hedging",1234,0,Green);
RefreshRates();
OrderSend(Sym_2,OP_BUY,Lots,MarketInfo(Sym_2,MODE_ ASK),Slippage,0,MarketInfo(Sym_2,MODE_ASK)+1000*Po int,"Hedging",1234,0,Green);
}
else
{
RefreshRates();
OrderSend(Sym_1,OP_SELL,Lots,MarketInfo(Sym_1,MODE _BID),Slippage,0,MarketInfo(Sym_1,MODE_BID)-1000*Point,"Hedging",1234,0,Red);
RefreshRates();
OrderSend(Sym_2,OP_SELL,Lots,MarketInfo(Sym_2,MODE _BID),Slippage,0,MarketInfo(Sym_2,MODE_BID)-1000*Point,"Hedging",1234,0,Red);
}
return(0);
}
return(0);
}


About the code:

As you see in the code above we open two similar trades for EURUSD and USDCHF which have a negative correlation.
We used the MarketInfo() function to get the bid/ask price for each pairs. This is the most important thing in this code because MarketInfo() function is the only way to get the bid/ask prices for another pairs of the currently symbol of chart! You can't use here the functions Bid or Ask.
Before using the MarketInfo() we have used the function RefreshRates() to be sure that we getting the up-to-date market data.

Hope you find the code and the article helpful and hope to drop me a comment!
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
simple hedging system... white_tiger Martingale/Average Cost and Hedging 19 02-10-2008 06:41 AM
Simple indicator request -25- Indicators - Metatrader 4 1 01-24-2007 10:12 AM
For all the Programmers out there can I request a simple indicator please toxic_jo Indicators - Metatrader 4 3 12-06-2006 08:26 PM
Need Help with hedging ea zleepan Expert Advisors - Metatrader 4 3 08-22-2006 11:33 AM
Request SIMPLE EA using StepMA_Stoch_V1 stu Expert Advisors - Metatrader 4 3 04-19-2006 04:18 AM


All times are GMT. The time now is 11:49 AM.



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