Forex



Go Back   Forex Trading > Discussion Areas > Suggestions for Trading Systems
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 10-20-2009, 03:25 PM
Junior Member
 
Join Date: Apr 2009
Posts: 2
surfandi is on a distinguished road
EA with Supertrend MTF

Hi to everyone!
I want to write a Strategy wich uses the Supertrend Indicator from 2 different timeframes. My problem is that i am a beginner in mql4.
So it would be really nice if someone could write a simple example just for Buy when the 1MIN_Supertrend and the 5MIN_Supertrend is green(in an uptrend)!

I already searched for Supertrend EA´s but they are all full of risk/moneymanagement and a lot of stuff wich make´s it to much complicated for me to understand and learn!

So please could someone help me with a very basic ea who just open a position!?

Thank´s a lot in advance!

Here´s the Indicator to give the signal:


---------------------------------------------------------------------
#property indicator_chart_window
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_buffers 2
double TrendUp[], TrendDown[];
int changeOfTrend;
extern int Nbr_Periods = 10;
extern double Multiplier = 3.0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0, TrendUp);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexLabel(0, "Trend Up");
SetIndexBuffer(1, TrendDown);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
SetIndexLabel(1, "Trend Down");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, i, flag, flagh, trend[5000];
double up[5000], dn[5000], medianPrice, atr;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars < 0) return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0) counted_bars--;
limit=Bars-counted_bars;
//Print(limit);

//----
for (i = Bars; i >= 0; i--) {
TrendUp[i] = EMPTY_VALUE;
TrendDown[i] = EMPTY_VALUE;
atr = iATR(NULL, 0, Nbr_Periods, i);
//Print("atr: "+atr[i]);
medianPrice = (High[i]+Low[i])/2;
//Print("medianPrice: "+medianPrice[i]);
up[i]=medianPrice+(Multiplier*atr);
//Print("up: "+up[i]);
dn[i]=medianPrice-(Multiplier*atr);
//Print("dn: "+dn[i]);
trend[i]=1;


if (Close[i]>up[i+1]) {
trend[i]=1;
if (trend[i+1] == -1) changeOfTrend = 1;
//Print("trend: "+trend[i]);

}
else if (Close[i]<dn[i+1]) {
trend[i]=-1;
if (trend[i+1] == 1) changeOfTrend = 1;
//Print("trend: "+trend[i]);
}
else if (trend[i+1]==1) {
trend[i]=1;
changeOfTrend = 0;
}
else if (trend[i+1]==-1) {
trend[i]=-1;
changeOfTrend = 0;
}

if (trend[i]<0 && trend[i+1]>0) {
flag=1;
//Print("flag: "+flag);
}
else {
flag=0;
//Print("flagh: "+flag);
}

if (trend[i]>0 && trend[i+1]<0) {
flagh=1;
//Print("flagh: "+flagh);
}
else {
flagh=0;
//Print("flagh: "+flagh);
}

if (trend[i]>0 && dn[i]<dn[i+1])
dn[i]=dn[i+1];

if (trend[i]<0 && up[i]>up[i+1])
up[i]=up[i+1];

if (flag==1)
up[i]=medianPrice+(Multiplier*atr);

if (flagh==1)
dn[i]=medianPrice-(Multiplier*atr);

//-- Draw the indicator
if (trend[i]==1) {
TrendUp[i]=dn[i];
if (changeOfTrend == 1) {
TrendUp[i+1] = TrendDown[i+1];
changeOfTrend = 0;
}
}
else if (trend[i]==-1) {
TrendDown[i]=up[i];
if (changeOfTrend == 1) {
TrendDown[i+1] = TrendUp[i+1];
changeOfTrend = 0;
}
}
}
WindowRedraw();

//----
return(0);
}
//+------------------------------------------------------------------+
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 10-20-2009, 03:42 PM
increase's Avatar
Senior Member
 
Join Date: May 2006
Posts: 844
increase is on a distinguished road
I believe I can save you some time here. I spent quite a long time with supertrend, it is a good indicator for manual trading. However, the problem when used in an EA is a problem common to nearly all indicators I have tried in EA's.

The problem is that the EA will work great whilst the market is trending up or down and make money.

But as soon as the market goes sideways or pauses waiting for direction, you get small zigzag movements which causes the EA to open and close buys way too late, the result is you get multiple small losses which cancel out the trend move wins and you end up going backwards.

I tried many filters to correct this, but to no avail.
__________________
New to Forex? Get all you need for Free at my site Click Here
You can also get my Hot Forex System (scroll to the bottom of the page): Click Here
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 10-20-2009, 04:20 PM
Junior Member
 
Join Date: Apr 2009
Posts: 2
surfandi is on a distinguished road
thanks...

thanks for your comment! I know that i doesn´t work when the market moves sideways. But I want to learn programming and for me this indicator is interesting.

please give me a simple example for coding this strategy!
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
SuperTrend jnrtrading Indicators - Metatrader 4 70 11-13-2009 07:26 PM
Supertrend as Histogram Hopexicerat Indicators - Metatrader 4 39 07-25-2009 05:00 PM
Anyone have Supertrend line Please? increase Indicators - Metatrader 4 24 02-23-2009 07:52 PM
EA of Supertrend etrade Expert Advisors - Metatrader 4 4 03-17-2008 07:05 PM
Supertrend Kurka Fund Expert Advisors - Metatrader 4 5 12-29-2006 10:27 AM


All times are GMT. The time now is 10:21 AM.



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