Forex



Go Back   Forex Trading > Downloads > Indicators - 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 09-10-2007, 07:40 PM
Senior Member
 
Join Date: Jan 2007
Posts: 102
Melpheos is on a distinguished road
Stochastic Indicator - problem with SAR filtering

I have made the following indicator, it put up/down arrow when 3 stoch with different K value (10-20-40 accordingly) goes in the same direction on their signal line (well this is details only)

Here is the code

Code:
//+------------------------------------------------------------------+
//|                                         Melpheos_Stoch.mq4       |
//|         Copyright © 2007, A.Meignan                              |
//|                   http://www.forexfactory.com                    |
//+------------------------------------------------------------------+

/*
  +------------------------------------------------------------------+
  | Shows up and down arrow when 3 stoch are going in the same       |
  | direction                                                        |
  |                                                                  |
  +------------------------------------------------------------------+
  
*/   
#property copyright "Copyright © 2007, Melpheos"
#property link      "http://www.forexfactory.com"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Lime
#property indicator_color2 Magenta
#property indicator_width1 1
#property indicator_width2 1


extern int K1 = 10;
extern int D1 = 2;
extern int S1 = 2;
extern int M1 = 3; //0=sma, 1=ema, 2=smma, 3=lwma
extern int K2 = 20;
extern int D2 = 2;
extern int S2 = 2;
extern int M2 = 3; //0=sma, 1=ema, 2=smma, 3=lwma
extern int K3 = 40;
extern int D3 = 2;
extern int S3 = 2;
extern int M3 = 3; //0=sma, 1=ema, 2=smma, 3=lwma


double up[];
double down[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, up);
   SetIndexStyle(1, DRAW_ARROW, EMPTY);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, down);

   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
  ObjectDelete("up");
  ObjectDelete("down");
  
  
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double stoch4now, stoch4previous;
   double stoch8now, stoch8previous;
   double stoch16now, stoch16previous;
   double RSI, SAR;
   double Range, AvgRange;
   
   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;
   
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;

      stoch4now = iStochastic( NULL, 0, K1, D1, S1, M1, 1, MODE_SIGNAL, i+1);
      stoch4previous = iStochastic( NULL, 0, K1, D1, S1, M1, 1, MODE_SIGNAL, i+2);

      stoch8now = iStochastic( NULL, 0, K2, D2, S2, M2, 1, MODE_SIGNAL, i+1);
      stoch8previous = iStochastic( NULL,0, K2, D2, S2, M2, 1, MODE_SIGNAL, i+2);

      stoch16now = iStochastic( NULL, 0, K3, D3, S3, M3, 1, MODE_SIGNAL, i+1);
      stoch16previous = iStochastic( NULL, 0, K3, D3, S3, M3, 1, MODE_SIGNAL, i+2);
   
      RSI = iRSI (NULL, 0, 14, 1, i+1);
      SAR = iSAR (NULL, 0, 0.02, 0.2, i+1);

// Tests starts here

      if ((stoch4now > stoch4previous) 
       && (stoch8now > stoch8previous) 
       && (stoch16now > stoch16previous ) 
       && (stoch16now > 15 )
       && (RSI > 45)){
      up[i] = Low[i] - Range*0.8;
      
      }
      

      if ((stoch4now < stoch4previous) 
       && (stoch8now < stoch8previous) 
       && (stoch16now < stoch16previous ) 
       && (stoch16now < 85 )
       && (RSI <55)){
      down[i] = High[i] + Range*0.8;
      
      }
      }

   return(0);
   
}
My problem is that when i add the following lines to the tests, it wont work, more specificaly, i wont affect the down arrow (no filtering) and it will delete all up arrows.

This is the code i add

Code:
&& (Price_close > SAR)
This is for the up test arrow. Of course reverse for the other test.

Any clue ?
Attached Images
File Type: gif mtf2.gif (31.7 KB, 285 views)

Last edited by Melpheos; 09-10-2007 at 07:49 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
  #2 (permalink)  
Old 09-11-2007, 01:51 AM
Senior Member
 
Join Date: Mar 2007
Posts: 188
lodol2 is on a distinguished road
hi

very nice indicator thx
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

Tags
stochastic indicator


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
Stochastic Momentum Indicator (Index) licho Indicators - Metatrader 4 55 10-09-2009 12:34 PM
Stochastic Momentum Indicator Needed taipan09 Indicators - Metatrader 4 1 06-05-2006 01:29 PM
Stochastic cross indicator/EA alert babarmughal Metatrader 4 1 06-02-2006 07:06 AM
problem with adding indicator shiningstar Indicators - Metatrader 4 11 05-19-2006 04:25 PM


All times are GMT. The time now is 08:12 PM.



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