Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-04-2007, 05:05 PM
Member
 
Join Date: Jan 2007
Posts: 20
gm6510 is on a distinguished road
any one know the problem here?

hi all
iam making my first indicator
but ther is some thing wrong

here is the code

Code:
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
//---- input parameters
extern int    rsiPeriod = 10;
//---- buffers
double buySignal[];
double sellSignal[];

static datetime lastAlertTime;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexStyle(1, DRAW_ARROW);

   SetIndexBuffer(0, buySignal);
   SetIndexBuffer(1, sellSignal);

   SetIndexEmptyValue(0, 0.0);
   SetIndexEmptyValue(1, 0.0);
   
   SetIndexArrow(0, 233);
   SetIndexArrow(1, 234);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   for (int i = Bars - IndicatorCounted(); i >= 0; i--)
   {
      
      double rsi1 = iRSI(NULL, 0, rsiPeriod, PRICE_CLOSE, i+1);
      double rsi2 = iRSI(NULL, 0, rsiPeriod, PRICE_CLOSE, i+2);
      double displacement = GetArrowDisplacement(i);
   
      if (rsi1>40&&rsi2<40||rsi1>50&&rsi2<50)
      {
         buySignal[i+1] = Low[i+1] - displacement;
         
      }
      
      if (rsi1<50&&rsi2>50||rsi1<40&&rsi2>40)
      {
         sellSignal[i+1] = High[i+1] + displacement;
         
      }      

   }

   return(0);
}
//+------------------------------------------------------------------+
void SignalAlert(string message)
{
   if (Time[0] != lastAlertTime)
   {
      Alert(message, Symbol(), ", ", Period(), " Minutes chart");
      lastAlertTime = Time[0];
   }
}
//+------------------------------------------------------------------+
double GetArrowDisplacement(int i)
{
   double high = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_HIGH, i);
   double low = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_LOW, i);
   
   return ((high - low) / 2);

as you see in the pic when the RSI line across level 50 and 40 it give me two arrow!!
is there is any code to solve this?

Attached Images
File Type: gif 11111111111111111111111111111.gif (11.8 KB, 154 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-04-2007, 05:24 PM
Senior Member
 
Join Date: Dec 2005
Posts: 144
trevman is on a distinguished road
Code:
(rsi1<50&&rsi2>50||rsi1<40&&rsi2>40)
its doing as its told, first arrow the rsi at close is less than 50 but the previous was greater than 50, the second arrow is the same but with 40
__________________
There is no candle.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-04-2007, 05:45 PM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
What's wrong?

I can not see what you mean by wrong.
Each arrow represents the up or down passage of the 40 and 50 levels you have defined.
See attached picture. If you still do not agree, mark the locations where you have your doubts.

Cheers
Herbert
Attached Images
File Type: gif TestIndi.gif (19.3 KB, 137 views)
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-04-2007, 08:47 PM
Member
 
Join Date: Jan 2007
Posts: 20
gm6510 is on a distinguished road
i mean the problem is when rsi gives me buy signal it gives many arrows

many arrows tell me keep buy signal]

i want one arrow only says to me buy. then when rsi gives sell signal i want one arrow appears only.

u can notice here many arrows tell me buy i just want one arrow.

i know my program is making the arrows alot i want a code or some thing to not

the same arrows appears many time
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-04-2007, 09:52 PM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Mod

OK, here you have the modified result.
It now only switches between the Buy and Sell status. (Red - Blue - Red - Blue etc.)

Cheers
Herbert
Attached Files
File Type: mq4 Testindi.mq4 (2.4 KB, 9 views)
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-06-2007, 11:56 AM
Member
 
Join Date: Jan 2007
Posts: 20
gm6510 is on a distinguished road
thank you HerbertH

i added MA to my indicator but there is problem can you help me?

the code

Code:
//+------------------------------------------------------------------+
//|                                               FX5_OmarSherif.mq4 |
//|                                            FX5, Copyright Đ 2007 |
//|                                                    hazem@uk2.net |
//+------------------------------------------------------------------+
#property copyright "FX5, Copyright Đ 2007"
#property link      "hazem@uk2.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
//---- input parameters

extern bool   enableAlert = true;
//---- buffers
double buySignal[];
double sellSignal[];

static datetime lastAlertTime;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexStyle(1, DRAW_ARROW);

   SetIndexBuffer(0, buySignal);
   SetIndexBuffer(1, sellSignal);

   SetIndexEmptyValue(0, 0.0);
   SetIndexEmptyValue(1, 0.0);
   
   SetIndexArrow(0, 233);
   SetIndexArrow(1, 234);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   for (int i = Bars - IndicatorCounted(); i >= 0; i--)
   {
      double ali1 = iRSI(NULL, 0, 21, PRICE_CLOSE, i+1);
      double ali2 = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE,i+1);
      double ali3 = iMA(NULL, 0, 25, 0, MODE_SMA, PRICE_CLOSE,i+1);
      
      double displacement = GetArrowDisplacement(i);
   
      if (ali1>50&&ali2>ali3)
      {
         buySignal[i+1] = Low[i+1] - displacement;
         if (enableAlert == true && i == 0)
            SignalAlert("Buy signal On: ");
      }
      
      if (ali1<50&&ali2<ali3)
      {
         sellSignal[i+1] = High[i+1] + displacement;
         if (enableAlert == true && i == 0)
            SignalAlert("Sell signal On: ");
      }      

   }

   return(0);
}
//+------------------------------------------------------------------+
void SignalAlert(string message)
{
   if (Time[0] != lastAlertTime)
   {
      Alert(message, Symbol(), ", ", Period(), " Minutes chart");
      lastAlertTime = Time[0];
   }
}
//+------------------------------------------------------------------+
double GetArrowDisplacement(int i)
{
   double high = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_HIGH, i);
   double low = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_LOW, i);
   
   return ((high - low) / 2);
}
//+------------------------------------------------------------------+
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-06-2007, 05:19 PM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Please explain first

Quote:
Originally Posted by gm6510 View Post
thank you HerbertH

i added MA to my indicator but there is problem can you help me?

the code
With pleasure, but it's not a matter of fixing, you went back to the original coding and replaced 1 of the RSI values for 2 SMA's. By doing that you have removed the logic for detecting the RSI crossing.

Please explain what you want to achieve and then I can help or modify the code for you.
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-06-2007, 07:25 PM
Member
 
Join Date: Jan 2007
Posts: 20
gm6510 is on a distinguished road
hi
my indicator consists of two indicator

rsi and moving average

i want to get buy signal when rsi >50 and ema5 croosing ema15

i want to get sell signal when rsi<50 and ema15 crosing ema5
Attached Images
File Type: gif 11111111111111111111111111111.gif (10.2 KB, 60 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 07-06-2007, 09:48 PM
HerbertH's Avatar
Member
 
Join Date: May 2006
Posts: 88
HerbertH is on a distinguished road
Result

Quote:
Originally Posted by gm6510 View Post
hi
my indicator consists of two indicator

rsi and moving average

i want to get buy signal when rsi >50 and ema5 croosing ema15

i want to get sell signal when rsi<50 and ema15 crosing ema5
Find attached the indicator, now behaving like you described.

Cheers
Attached Files
File Type: mq4 Testindi2.mq4 (3.4 KB, 13 views)
__________________
Better being out, wishing to be in than being in and wishing to be out.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 07-06-2007, 10:05 PM
Senior Member
 
Join Date: Feb 2006
Posts: 1,110
et_phonehome_2 is on a distinguished road
HerbertH

Good work....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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
Problem with .ex4................. EFX General Discussion 4 10-21-2006 07:23 AM
iTime problem danielpasono Expert Advisors - Metatrader 4 3 07-06-2006 04:29 AM
Problem with BGcross EA Andrewsurfer Expert Advisors - Metatrader 4 2 05-26-2006 06:13 AM
My First EA problem demag Questions 4 02-10-2006 08:18 AM
I've a Problem here hellkas Metatrader 4 6 11-04-2005 12:30 AM


All times are GMT. The time now is 06:22 PM.



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