Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions


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 (2) Thread Tools Display Modes
  #1121 (permalink)  
Old 06-06-2008, 10:46 PM
cutzpr's Avatar
Member
 
Join Date: Jan 2008
Posts: 50
cutzpr is on a distinguished road
Need help my indicator wont paint

I am in need of some help. This is my first attempt in trying to code.
I am trying to modify the RSI Filter indicator made by igorad with no success. Pretty much all I want is to combine two different periods into one indicator.
I would like the new indicator to only paint when both values of both periods are exactly the same. My code is compiling correctly but is not painting.

PHP Code:
//+------------------------------------------------------------------+
//|                                             RSIFilter_v1_MOD.mq4 |
//|                                  Copyright © 2006, Forex-TSD.com |
//|                         Written by IgorAD,igorad2003@yahoo.co.uk |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |                                      
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"

#property indicator_separate_window
#property indicator_minimum -1 //Min. and Max were set to 1 and -1 in order to have clear signals. A zero or no signal will mean no trade.
#property indicator_maximum 1
#property indicator_buffers 3
#property indicator_color1 SkyBlue
#property indicator_color2 Orange

//---- input parameters
extern int lfPeriodRSI=3//Short RSI time period
extern int sfPeriodRSI=10//Long RSI time period
double SgBuffer[]; //This array will include all filtered out signals from the two different time frames.

        
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  
  
int init()
  {
   
string short_name;
//---- indicator line
   
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1); 
   
SetIndexBuffer(0,SgBuffer);
      
   
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   
short_name="RSI Signal Filter";
   
IndicatorShortName(short_name);
   
SetIndexLabel(0,"SgBuffer");
//----
   
SetIndexDrawBegin(0,SgBuffer);
//----
   
return(0);
  }
  
//+------------------------------------------------------------------+
//| RSIFilter_v1                                                         |
//+------------------------------------------------------------------+
int start()
  {
   
int shift,trend;
   
double lfRSI,sfRSI;  // Returned Value of iRSI Functions
   
double lfUpBuffer[]; //Longer TF Buffers               
    
double lfDnBuffer[];    
    
double sfUpBuffer[]; //Shorter TF Buffers
    
double sfDnBuffer[]; 

   for(
shift=Bars-lfPeriodRSI-1;shift>=0;shift--)
   {
   
lfRSI=iRSI(NULL,0,lfPeriodRSI,PRICE_CLOSE,shift);
       
      if (
lfRSI>70)  trend=1
      if (
lfRSI<30)  trend=-1;
      
      if (
trend>0
      {
      if (
lfRSI 40lfUpBuffer[shift]=1.0;
      else 
lfUpBuffer[shift] = EMPTY_VALUE;
      
lfDnBuffer[shift]=0;
      }
      if (
trend<0
      {
      if (
lfRSI 60lfDnBuffer[shift]=-1.0;
      else 
lfDnBuffer[shift] = EMPTY_VALUE;
      
lfUpBuffer[shift]=0;
      }
    }
    
     for(
shift=Bars-sfPeriodRSI-1;shift>=0;shift--)
   {    
   
sfRSI=iRSI(NULL,0,sfPeriodRSI,PRICE_CLOSE,shift);
       
      if (
sfRSI>70)  trend=1
      if (
sfRSI<30)  trend=-1;
      
      if (
trend>0
      {
      if (
sfRSI 40sfUpBuffer[shift]=1.0;
      else 
sfUpBuffer[shift] = EMPTY_VALUE;
      
sfDnBuffer[shift]=0;
      }
      if (
trend<0
      {
      if (
sfRSI 60sfDnBuffer[shift]=-1.0;
      else 
sfDnBuffer[shift] = EMPTY_VALUE;
      
sfUpBuffer[shift]=0;
      }
    }
//Code was added to filter out signals. Both peroids must have the same
//trend in order for the signal to be valid.

    
if    ((lfUpBuffer[shift]>0) && (sfUpBuffer[shift]>0))
        
SgBuffer[shift]=1;
    else if ((
lfDnBuffer[shift]<0) && (sfDnBuffer[shift]<0))
        
SgBuffer[shift]=-1;
    else 
SgBuffer[shift]=0// Will show a zero value when the two expressions above are false.

    
return(0);    
 } 
Attached Images
File Type: gif RSI.GIF (80.9 KB, 133 views)
Attached Files
File Type: mq4 RSIFilter_v1.mq4 (2.4 KB, 3 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1122 (permalink)  
Old 06-06-2008, 11:09 PM
Senior Member
 
Join Date: Nov 2006
Posts: 122
Yoda_Glenn is on a distinguished road
Quote:
Originally Posted by IN10TION View Post
you are almost there
yes you have a "init" part (initialization) and also a "start" part...
put it in the start part as I did it in the example...

why?
1. because init will run only ones, in the "start" part it will block continues.
2. your error message = you can't use a start() into a init() function

Have a nice weekend

Thanks for your help! I compiled it with no errors, but I have to wait till the market opens up on Monday to test it. I have one question about expiration codes with EAs: What does the EA check the date against? Is it getting the date information from the Meta Quotes charts, the broker's server or from the actual computer that the EA is running on? If it is the latter (from the actual user's computer) then what keeps a user from simply changing the date on his computer to fool the EA's expiration? Just wondering...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1123 (permalink)  
Old 06-06-2008, 11:37 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 569
Blog Entries: 1
IN10TION is on a distinguished road
TimeCurrent( )
Returns the last known server time (time of incoming of the latest quote) as number of seconds elapsed from 00:00 January 1, 1970.

Note: At the testing, the last known server time is modelled.

Quote:
Originally Posted by Yoda_Glenn View Post
Thanks for your help! I compiled it with no errors, but I have to wait till the market opens up on Monday to test it. I have one question about expiration codes with EAs: What does the EA check the date against? Is it getting the date information from the Meta Quotes charts, the broker's server or from the actual computer that the EA is running on? If it is the latter (from the actual user's computer) then what keeps a user from simply changing the date on his computer to fool the EA's expiration? Just wondering...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1124 (permalink)  
Old 06-07-2008, 12:56 AM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 569
Blog Entries: 1
IN10TION is on a distinguished road
try this one...

Quote:
Originally Posted by cutzpr View Post
I am in need of some help. This is my first attempt in trying to code.
I am trying to modify the RSI Filter indicator made by igorad with no success. Pretty much all I want is to combine two different periods into one indicator.
I would like the new indicator to only paint when both values of both periods are exactly the same. My code is compiling correctly but is not painting.
Attached Files
File Type: mq4 RSIMixFilter_v1.mq4 (3.6 KB, 16 views)

Last edited by IN10TION; 06-07-2008 at 01:08 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1125 (permalink)  
Old 06-07-2008, 01:38 AM
kiromano's Avatar
Junior Member
 
Join Date: Feb 2008
Posts: 6
kiromano is on a distinguished road
Can anyone answer this question... I would really appreciate the help...

Quote:
Originally Posted by kiromano View Post
Guru,

I have been racking my brain to figure out how to get my indicator to use a simple dash instead of Wingdings. I am trying to avoid using ObjectCreate if possible. I know there must be a simple way, because it's listed in the online help at MT4 site. If I'm reading it correctly the number 4 should be a dash, however when I use the number 4 as and arrow, it gives me the default checkmark.

I'm not looking for a dashed line, just a single dash to mark a point on any given bar.

Great thread, by the way.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1126 (permalink)  
Old 06-07-2008, 08:57 AM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 569
Blog Entries: 1
IN10TION is on a distinguished road
can you send your code, the way it is now... and if possible make a picture in what you want... it's a little unclear about the result...

Have a nice weekend!


Quote:
Originally Posted by kiromano View Post
Can anyone answer this question... I would really appreciate the help...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1127 (permalink)  
Old 06-07-2008, 11:09 AM
sonicdeejay's Avatar
Member
 
Join Date: Apr 2008
Posts: 98
sonicdeejay is on a distinguished road
I am having some headache now...the current indicator doesn't really do what I want it to do....

what I want is...


Buy
Sellflag != 1 (Sellflag is not 1)
OzFX Buy signal
If ADX>25, Set Buyflag=1


SELL
Buyflag != 1 (buyflag is not 1)
OzFX Sell signal
If ADX>25,Set sellflag=1


When ADX<25, reset the buy/sellflag=0

By Doing so, we can filter out fake/weak breakout!!!
I have attached, the source code for the guru to help me out!!

sonic
Attached Files
File Type: mq4 Sonic_Ind_v2.1.mq4 (8.3 KB, 5 views)
__________________
~It's not who I am underneath but, what I do that defines me!!

My FOREX Journal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1128 (permalink)  
Old 06-07-2008, 01:24 PM
IN10TION's Avatar
Senior Member
 
Join Date: Mar 2007
Posts: 569
Blog Entries: 1
IN10TION is on a distinguished road
I start to change things... but...
your main loop is wrong, and your logic "and" and "or" functions are not fitted well in the code... so I think there is something wrong with the logic...

can you tell me about AC and STOCH and ADX in your own words?

The way it's programmed now will give a big load on your pc to calculate... have to change almost everything...

...

Quote:
Originally Posted by sonicdeejay View Post
I am having some headache now...the current indicator doesn't really do what I want it to do....

what I want is...


Buy
Sellflag != 1 (Sellflag is not 1)
OzFX Buy signal
If ADX>25, Set Buyflag=1


SELL
Buyflag != 1 (buyflag is not 1)
OzFX Sell signal
If ADX>25,Set sellflag=1


When ADX<25, reset the buy/sellflag=0

By Doing so, we can filter out fake/weak breakout!!!
I have attached, the source code for the guru to help me out!!

sonic
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1129 (permalink)  
Old 06-07-2008, 04:04 PM
sonicdeejay's Avatar
Member
 
Join Date: Apr 2008
Posts: 98
sonicdeejay is on a distinguished road
Quote:
Originally Posted by IN10TION View Post
I start to change things... but...
your main loop is wrong, and your logic "and" and "or" functions are not fitted well in the code... so I think there is something wrong with the logic...

can you tell me about AC and STOCH and ADX in your own words?

The way it's programmed now will give a big load on your pc to calculate... have to change almost everything...

...
the for loop is correct???

PHP Code:
int start()
{
   for (
Bars 205>= 0--)
   { 
__________________
~It's not who I am underneath but, what I do that defines me!!

My FOREX Journal
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1130 (permalink)  
Old 06-07-2008, 05:18 PM
kiromano's Avatar
Junior Member
 
Join Date: Feb 2008
Posts: 6
kiromano is on a distinguished road
Thanks for the reply,

This is the section of code. It's just a moving average envelope that I would like to have mark the high and low points on each bar. Since I am using about six or eight points on each bar, the dash would crowd the screen less than the current smallest arrow I could find (the "110" square arrow shape).

//---- indicators
IndicatorBuffers(2);

SetIndexBuffer(0,ma1);
SetIndexBuffer(1,ma2);

SetIndexStyle(0,DRAW_ARROW,0,0);
SetIndexStyle(1,DRAW_ARROW,0,0);
SetIndexArrow(0,110);
SetIndexArrow(1,110);
SetIndexShift(0,shift);
SetIndexShift(1,shift);
SetIndexLabel(0,"MA Down");
SetIndexLabel(1,"MA Up");
//----
return(0);


I have attached a pic with two MA's indicated. You can see what I have once I activate all 4 of them.



Quote:
Originally Posted by IN10TION View Post
can you send your code, the way it is now... and if possible make a picture in what you want... it's a little unclear about the result...

Have a nice weekend!
Attached Images
File Type: gif chartpick.gif (18.5 KB, 101 views)
__________________
“A loss never bothers me after I take it. I forget it overnight. But being wrong - not taking the loss - that is what does damage to the pocketbook and to the soul.”
Jesse Livermore.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram, forex, ZUP_v1.mq4

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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
Posted By For Type Date
OzFx System:) - Page 639 This thread Refback 06-21-2008 10:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 12:46 PM


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



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