Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course
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
  #81 (permalink)  
Old 03-11-2009, 03:10 AM
FatherJack's Avatar
Senior Member
 
Join Date: Aug 2008
Location: Sakhalin Island
Posts: 147
FatherJack is on a distinguished road
A code sample, please

Could someone share a sample code of an indicator that would take the values of two custom indicators on chart at the bar close, and based on that, either give an alert, or draw coloured bars, it does not really matter what it does.
For example, we have two LWMAs on the chart with different period settings. As the bar closes, the indicator would compare their values, and if the shorter one is higher than the longer, it would draw a blue bar in a separate window. As simple as that.
I need it for my mql studies, I'm a bit overwhelmed with theory now and want to do something practical. Thanks in advance!
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
  #82 (permalink)  
Old 03-15-2009, 07:20 PM
Junior Member
 
Join Date: Aug 2007
Posts: 1
prasantha60 is on a distinguished road
How to call Function when when the trade is execuating ?

Please help me
how I call a funcion when the trade is executing when opening new trade or closing a trade or creating a pending order, I I want to call function
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
  #83 (permalink)  
Old 03-16-2009, 01:49 AM
wolfe's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 820
wolfe is on a distinguished road
Quote:
Originally Posted by prasantha60 View Post
Please help me
how I call a funcion when the trade is executing when opening new trade or closing a trade or creating a pending order, I I want to call function
What function do you want to call? Not really sure what you're question is.
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
  #84 (permalink)  
Old 03-23-2009, 11:43 PM
Junior Member
 
Join Date: Jun 2008
Posts: 19
Pied Piper is an unknown quantity at this point
Quote:
Originally Posted by codersguru View Post
Hi homi,

Let’s assume we want to return the value of the indicator “Supertrend” of a specific bar using iCustom.

If we want to get the returned value of the Supertrend first line:
We can write this price of code inside start() function:

Code:
double val=iCustom(NULL, 0, "SuperTrend",0,0,pos);
Here val will hold the returned value of Supertrend indicator(first line).

If you want the returned value of the second line, we can write:

Code:
double val=iCustom(NULL, 0, "SuperTrend",0,1,pos);
This is a program which will use Supertrend indicator using iCustom:


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

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }


int start()
  {
   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--;
   
   int pos=Bars-counted_bars;
   
     
 
   while(pos>=0)
     {
         ExtMapBuffer1[pos] = iCustom(NULL, 0, "SuperTrend",0,0,pos);
         ExtMapBuffer2[pos] = iCustom(NULL, 0, "SuperTrend",0,1,pos);

         pos--;
     }
     
     
     
//----
   return(0);
  }
//+------------------------------------------------------------------+


Dear Codersguru,

Can you please take a look at the attached chart. Is it possible for you to code the attached SuperTrend indicator in candle form just like CJA did in this post? The one he attached is a .ex4 file and it crashes my FxPro and other MT4 platforms each time it is loaded but it works perfectly with Alpari UK.

Here's the link to CJA's first post: SuperTrend Candles

If you're tied up with work, kindly refer to a link where the tutorial can be found please. Thanx so much.
Attached Images
File Type: gif SuperTrend Candles.gif (37.0 KB, 121 views)
Attached Files
File Type: mq4 SuperTrend.mq4 (4.0 KB, 20 views)
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
  #85 (permalink)  
Old 03-28-2009, 08:21 PM
Junior Member
 
Join Date: Jan 2006
Posts: 22
forex2006 is on a distinguished road
Talking I-Customer Section for Expert Advisors

hello traders and programmers

i hope i´m right here to open this new thread , the idea is to post ONLY expert advisor code of ALL INDICATORS what you know for programming and test your own expert advisor .
SORRY FOR MY BAD ENGLISH.......

the form looks like a "FUNCTION" - my first examples :

Indikator: TURBO JRSX:

Quote:
Int CheckTurboJRSX()
{
double rsxcurr = 0,rsxprev1 = 0,rsxprev2 = 0;
rsxcurr = iCustom(Symbol(), Period(), "Turbo_JRSX", 17, 0, 1);
rsxprev1 = iCustom(Symbol(), Period(), "Turbo_JRSX", 17, 0, 2);
rsxprev2 = iCustom(Symbol(), Period(), "Turbo_JRSX", 17, 0, 3);

if (rsxcurr > rsxprev1 && rsxcurr > 30 && rsxprev1 < 30) return ( 1) ; //BUY
if (rsxcurr < rsxprev1 && rsxcurr < 70 && rsxprev1 > 70) return ( -1) ; //SELL
return(0);
}
FUNCTION CALLING:
Quote:
if(CheckTurboJRSX()== 1) {example: open order buy ....}
if(CheckTurboJRSX()==-1) {example: open order sell ....}
-----------------------------------------------------------------------

Indikator: Parabolic Sar:

Quote:
int CheckParabolicSar()
{
double sarCurrent = iSAR(NULL, 0, 0.02, 0.2, 0);
double sarPrevious = iSAR(NULL, 0, 0.02, 0.2, 1);
if(sarCurrent <= Ask && sarPrevious>sarCurrent) return ( 1) ; //BUY
if(sarCurrent >= Bid && sarPrevious<sarCurrent) return ( -1) ; //SELL
return(0);
}
FUNCTION CALLING:
Quote:
if(CheckParabolicSar()== 1 {example: open order buy ....}
if(CheckParabolicSar()==-1 {example: open order sell ....}
note: parabolic sar is standard indicator , it`s not needed to attach for downloading....
-----------------------------------------------------------------------

Indikator: Fisher:

EXTERN VARIABLES:

Quote:
extern int FisherPeriod = 5;
extern double UP_Value = 0.25;
extern double DN_Value =-0.25;
Quote:
int FisherCheck()
{
double FisherUP = iCustom(NULL,0,"Fisher_Yur4ik",FisherPeriod,1,0);
double FisherDN = iCustom(NULL,0,"Fisher_Yur4ik",FisherPeriod,2,0);

if(FisherUP>UP_Value) return ( 1) ; //BUY
if(FisherDN<DN_Value) return (-1); //SELL
return (0);
}
FUNCTION CALLING:

Quote:
if(FisherCheck()== 1 {example: open order buy ....}
if(FisherCheck()==-1 {example: open order sell ....}
-----------------------------------------------------------------------

Indikator: iBullsPower/iBearsPower:

EXTERN VARIABLES:

Quote:
extern int BullBearPeriod=5;
Quote:
int CheckiBullsBearsPower()
{
double bull = iBullsPower(NULL,0,BullBearPeriod,PRICE_CLOSE,1);
double bear = iBearsPower(NULL,0,BullBearPeriod,PRICE_CLOSE,1);

if(bull +bear>0) return ( 1) ; //BUY
if(bull+bear<0) return ( -1) ; //SELL
return(0);
}
FUNCTION CALLING:

Quote:
if(CheckiBullsBearsPower()== 1 {example: open order buy ....}
if(CheckiBullsBearsPower()==-1 {example: open order sell ....}
note: iBullsPower and iBearsPower are standard indicators , it`s not needed to attach for downloading....

-----------------------------------------------------------------------

Indikator: Support and Resistance:

Quote:
int CheckSupportResident()
{
double iTmpR = iCustom(Symbol(),0,"Support and Resistance",0,0);
double iTmpS = iCustom(Symbol(),0,"Support and Resistance",1,0);
if (Close[0]==iTmpR) return ( 1) ; //BUY
if (Close[0]==iTmpS) return ( -1) ; //SELL
return(0);
}
FUNCTION CALLING:

Quote:
if(CheckSupportResident()== 1 {example: open order buy ....}
if(CheckSupportResident()==-1 {example: open order sell ....}
-----------------------------------------------------------------------

Indikator: TrendEnvelopes_v2:

EXTERN VARIABLES:

Quote:
extern int SignalCandle =1;
extern int MA_Period =34;

Quote:
Int CheckTrendEnvelopes_V2()
{
double TrendEnv_long = iCustom(Symbol(),Period(),"TrendEnvelopes_v2",MA_P eriod,0,SignalCandle); //buy
double TrendEnv_short = iCustom(Symbol(),Period(),"TrendEnvelopes_v2",MA_P eriod,1,SignalCandle); //sell

(TrendEnv_long <9999) return ( 1) ; //BUY
(TrendEnv_short <9999) return ( -1) ; //SELL
return(0);
}
FUNCTION CALLING:

Quote:
if(CheckTrendEnvelopes_V2()== 1 {example: open order buy ....}
if(CheckTrendEnvelopes_V2()==-1 {example: open order sell ....}
-----------------------------------------------------------------------

hope this samples help to inspirit this thread..... will add more indicators next time .......

have fun and greetings from austria

forex2006
Attached Files
File Type: mq4 Turbo_JRSX.mq4 (2.7 KB, 20 views)
File Type: mq4 Fisher_Yur4ik.mq4 (2.0 KB, 19 views)
File Type: mq4 Support and Resistance.mq4 (5.2 KB, 20 views)
File Type: mq4 TrendEnvelopes_v2.mq4 (4.2 KB, 24 views)
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
  #86 (permalink)  
Old 03-30-2009, 12:24 AM
Junior Member
 
Join Date: May 2008
Posts: 8
zyco is on a distinguished road
Hi, could you help me with the elaboration of this expert.

Based on FreedomBar indicator...

If previous square closes red -> sell (market price) -> close trade in the next previous square change to blue and reverse to buy (market price)

Idem on buy orders

TF, tp, sl and trailing stop options would be nice.

Thanks in advance
Attached Files
File Type: mq4 FreedomBar.mq4 (6.7 KB, 13 views)
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
  #87 (permalink)  
Old 04-11-2009, 09:55 AM
increase's Avatar
Senior Member
 
Join Date: May 2006
Posts: 845
increase is on a distinguished road
Any help please. I am reading from and indicator into an EA using icustom, during backtest the trend runs quite happily, then for some reason the icustom parameters reverse so my trend is going up instead of down even though the indicator is showing down after the trade is activated i corrects itself then happens again some time later

__________________
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
  #88 (permalink)  
Old 04-12-2009, 06:27 AM
increase's Avatar
Senior Member
 
Join Date: May 2006
Posts: 845
increase is on a distinguished road
Quote:
Originally Posted by increase View Post
Any help please. I am reading from and indicator into an EA using icustom, during backtest the trend runs quite happily, then for some reason the icustom parameters reverse so my trend is going up instead of down even though the indicator is showing down after the trade is activated i corrects itself then happens again some time later

mmm so the indicator seems to be the problem it is SuperTrend volty like but I have had the problem with other non repainting indicators such as FX Sniper Ergodic and Fisher.

The challenge seems to be that there are many times when the indicator points in a direction say down, but the start point of the move ends up being lower than the finish causing the indicator to show down but the data reads up.

Any comment s on this, does anyone have a non repainting indicator that does not do this, or any other solution?

Please see attached pic
Attached Images
File Type: jpg pic.jpg (37.5 KB, 79 views)
__________________
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
  #89 (permalink)  
Old 06-26-2009, 07:15 AM
Junior Member
 
Join Date: Feb 2007
Posts: 1
archangel4 is on a distinguished road
Question iCustom function

hi all... this is my first post

i need some help with the ea im trying to create. this ea will be used to close position based on the color of the indicator but i'll open the position manually. since i don't have the decompile version the indicator, i think icustom is the way to go.

but how do i call the function based on the color?

eg. if i used Heikin Ashi_SW and i want to close sell position when the color is blue after the bar is closed and vice versa.


thanx in advance
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
  #90 (permalink)  
Old 06-28-2009, 09:30 PM
Junior Member
 
Join Date: May 2009
Posts: 2
Xaun is on a distinguished road
ICustom problems

I have a simple Custom Indicator with no externs called #TestIndicator that fills 8 buffers with the number 1.0 but when I bring back the buffers in my EA the buffer results are always 0 . Can you help me with this.

#TestIndicator
Code:
#property indicator_chart_window
#property indicator_buffers 8

double buf4_up[];
double buf4_down[];
double buf3_up[];
double buf3_down[];
double buf2_up[];
double buf2_down[];
double buf1_up[];
double buf1_down[];

int UniqueNum = 0070;

string shortname = "";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
      shortname = "#TFX";
         IndicatorBuffers(8);
   
         IndicatorShortName(shortname);
      //---- indicators
         SetIndexBuffer(0,buf4_up);
         SetIndexBuffer(1,buf4_down);
         SetIndexBuffer(2,buf3_up);
         SetIndexBuffer(3,buf3_down);
         SetIndexBuffer(4,buf2_up);
         SetIndexBuffer(5,buf2_down);
         SetIndexBuffer(6,buf1_up);
         SetIndexBuffer(7,buf1_down);
        
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
      int limit;
      int counted_bars = IndicatorCounted();
  //---- the last calculated bar will be recalculated
      if(counted_bars > 0) 
          counted_bars--;
      limit = Bars - counted_bars - 1;
  //---- the main cycle
      for(int i = limit; i >= 0; i--)
        {
          //---- 
         buf4_up[i]=1.0;
         buf4_down[i]=1.0;
         buf3_up[i]=1.0;
         buf3_down[i]=1.0;
         buf2_up[i]=1.0;
         buf2_down[i]=1.0;
         buf1_up[i]=1.0;
         buf1_down[i]=1.0;

         
        }
//----
//----
   
//----
   return(0);
  }
//+------------------
EA Code
Code:
double test4_up[];
double test4_down[];
double test3_up[];
double test3_down[];
double test2_up[];
double test2_down[];
double test1_up[];
double test1_down[];

int UniqueNum = 009;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
      Print("Inside init");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
      Print("Inside deinit");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   Print("Inside start");
   int counted_bars=IndicatorCounted();
   int y5m=0, y1h=0, y30m=0, y15m=0, yy=0;
   int i=0;
   int limit=Bars-counted_bars;

    for(i=0;i<limit;i++)
    {
      test4_up[i] = iCustom(NULL, 0, "#TestIndicator",0,i);
      test4_down[i] = iCustom(NULL, 0, "#TestIndicator",1,i);
      
    }
    for(i=0;i<30;i++)
    {
      Print("Test 4 UP ", test4_up[i]," Bar ",i );
      Print("Test 4 DOWN ", test4_down[i]," Bar ",i );
      //Print("This is a test");
    }
    
//----
   return(0);
  }
//+---------
Results in Tester
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
icustom, icustom function, iCustom()


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
Easy iCustom and Alerts! codersguru Indicators - Metatrader 4 58 04-13-2009 09:30 AM
iCustom question .. yaniv_av Indicators - Metatrader 4 16 06-20-2008 05:37 PM
icustom maje Questions 24 12-05-2007 10:26 AM
I need help on creating an Icustom statement for my EA using this indicator as input! iscuba11 Expert Advisors - Metatrader 4 4 09-11-2006 08:18 PM
iCustom() problem billritz Indicators - Metatrader 4 5 08-23-2006 08:22 AM


All times are GMT. The time now is 08:37 AM.



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