Results 1 to 6 of 6
 0 Attachment(s)    

Thread: Can anyone help with icustom?

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    2

    Default Can anyone help with icustom?

    I am trying in an EA

    val1= iCustom(NULL,0,"DT-ZZ-M1",50,5,0);

    but all I can get is an empty value

    Any suggestions please

    here is the indicator
    //+------------------------------------------------------------------+
    //| DT-ZigZag-Lauer.mq4 |
    //+------------------------------------------------------------------+
    #property copyright "Copyright 2005, klot"
    #property link "klot@mail.ru"
    //----
    #property indicator_separate_window
    #property indicator_minimum 0
    #property indicator_maximum 2
    #property indicator_buffers 2
    #property indicator_color1 Blue
    #property indicator_color2 Red
    #property indicator_width1 4
    #property indicator_width2 4
    //---- input parameters
    extern int depth=50;//was 5
    extern int GrossPeriod=5;//was 15
    extern int MAX_Limit=300;
    //---- buffers
    double ExtMapBuffer1[];
    double ExtMapBuffer2[];
    datetime daytimes[];
    double alertBar;
    double prev;

    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //---- indicators
    string short_name;

    //---- name for DataWindow and indicator subwindow label
    short_name="MY(" + depth + ")";
    IndicatorShortName(short_name);
    SetIndexLabel(0, short_name);
    IndicatorDigits(0);
    //----
    SetIndexStyle(0,DRAW_HISTOGRAM, STYLE_SOLID);
    SetIndexBuffer(0,ExtMapBuffer1);
    SetIndexEmptyValue(0,0.0);
    SetIndexStyle(1,DRAW_HISTOGRAM, STYLE_SOLID);
    SetIndexBuffer(1,ExtMapBuffer2);
    SetIndexEmptyValue(1,0.0);
    //----
    //----
    // if (Period()>GrossPeriod) { Alert("DT-ZigZag: Current timeframe must be less than", GrossPeriod); return(0); }
    // All Time[ ] series of time is sorted out in the direction of the decrease
    ArrayCopySeries(daytimes,MODE_TIME,Symbol(),GrossP eriod);
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Custor indicator deinitialization function |
    //+------------------------------------------------------------------+
    int deinit()
    {
    //----
    //----
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Custom indicator iteration function |
    //+------------------------------------------------------------------+
    int start()
    {
    int counted_bars=IndicatorCounted();
    int limit=MAX_Limit,bigshift;
    double zigzag1;
    if (counted_bars<0) return(-1);
    if (counted_bars>0) counted_bars--;
    limit=Bars-counted_bars;
    //----
    for(int i=0; i<limit; i++)
    {
    if(Time[i]>=daytimes[0]) bigshift=0;
    else
    {
    bigshift=ArrayBsearch(daytimes,Time[i-1],WHOLE_ARRAY,0,MODE_DESCEND);
    if(Period()<=GrossPeriod) bigshift++;
    }
    for(int cnt=bigshift; cnt<(300+bigshift); cnt++)
    {
    zigzag1=iCustom(NULL,GrossPeriod,"Zigzag",depth,15 ,9,0,cnt+1);
    if(zigzag1!=0)break;
    }
    if(iClose(NULL,0,i+1)<=zigzag1)ExtMapBuffer2[i]=1; else ExtMapBuffer2[i]=0.0;
    if(i==0 && prev != ExtMapBuffer2[i] && ExtMapBuffer1[i] == 1 && ExtMapBuffer2[i] == 0 && Bars>alertBar) {Alert("DT-ZZ Alert changing Up " + Symbol() + " on the " + Period() + " minute chart.");alertBar = Bars;prev = ExtMapBuffer2[i];}
    if(iClose(NULL,0,i+1)>=zigzag1)ExtMapBuffer1[i]=1; else ExtMapBuffer1[i]=0.0;
    if(i==0 && prev != ExtMapBuffer2[i] && ExtMapBuffer1[i] == 0 && ExtMapBuffer2[i] == 1 && Bars>alertBar) {Alert("DT-ZZ Alert changing Down " + Symbol() + " on the " + Period() + " minute chart.");alertBar = Bars;prev = ExtMapBuffer2[i];}
    ObjectsRedraw();
    }
    // Comment("zigzag1 = ",zigzag1);
    //----
    return(0);
    }
    //+------------------------------------------------------------------+

    I want to buy and sell on the dot colour change

  2. #2
    Administrator funyoo's Avatar
    Join Date
    Sep 2008
    Posts
    7,003

    Default

    Can you post your EA ?

    Maybe you have not well defined the entry conditions that should be something like that :

    Code:
    int start(){
    
    limit=1;
    double BV=0,SV=0;
    
    for(int i=1;i<=limit;i++){
    
    double DTZ1=iCustom(NULL,0,"DT-ZigZag-Lauer",depth,GrossPeriod,0,i);
    double DTZ2=iCustom(NULL,0,"DT-ZigZag-Lauer",depth,GrossPeriod,1,i);
    
    if(DTZ1>0){BV=1; break;}
    if(DTZ2>0){SV=1; break;}}
    I have already worked with this indicator, and there was no problem. Note that it is repainting if I well remind.

  3. #3
    Junior Member
    Join Date
    Jan 2009
    Posts
    5

    Default

    Increase,
    You have not specified an amount of bars to process in your iCustom call. Further, you have no specified either a buffer or an index.

    I like giving examples because I feel its more helpful

    val1= iCustom(NULL,0,"DT-ZZ-M1",50,5,300,0,0);

    I wonder if you can post your EA? As funyoo said it is a repainting indicator, and I would like to see how you plan to implement it.

    Regards

  4. #4

    Default

    Quote Originally Posted by increase View Post
    I am trying in an EA

    val1= iCustom(NULL,0,"DT-ZZ-M1",50,5,0);

    but all I can get is an empty value

    Any suggestions please

    increase,

    icustom function detail below..

    double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)
    Calculates the specified custom indicator and returns its value. The custom indicator must be compiled (*.EX4 file) and be in the terminal_directory\experts\indicators directory.
    Parameters:
    symbol - Symbol the data of which should be used to calculate indicator. NULL means current symbol.
    timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
    name - Custom indicator compiled program name.
    ... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator.
    mode - Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions.
    shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

    Sample:
    double val=iCustom(NULL, 0, "SampleInd",13,1,0);

    but in your formula , you write has " 5 " while your indi doesnt have buffer number 5

    thats the why , your icustom function or its parameters doesnt work properly

  5. #5
    Junior Member
    Join Date
    Jan 2009
    Posts
    5

    Default

    assassin,

    note that his 5 is part of iCustom input parameters. With iCustom you cannot have partial inputs if you choose to use them. 5 is correct for what is asked, specifying a var. The third var is referenced next in the call, and since he did not see it, it has been assigned 0. Now it is missing the buffer reference.

    He is using incomplete input parameters, but is referencing the 1st buffer.

    Edit: I was going to post an example, however my previous post illustrates the correct call
    Last edited by codobro; 01-14-2009 at 02:16. Reason: more

  6. #6

    Default

    codobro,

    be aware of this " ... - Parameters set (if necessary). The passed parameters and their order must correspond with the desclaration order and the type of extern variables of the custom indicator. "

    im not sure how it works (or not ) if we use partial ... but the icustom function that increase put, searching fifth buffer in the indi.

    anyway.. your example surely right placed

    you gave him a fish, i wanted to explain how fishing by himself.

Similar Threads

  1. Programming question on icustom and Elabunsky VolaPresser
    By roodstaart in forum Ideas for expert advisors
    Replies: 4
    Last Post: 06-07-2010, 12:42
  2. How to load iCUSTOM for this indicator?
    By hanna in forum MQL programming
    Replies: 0
    Last Post: 05-14-2010, 07:42
  3. Excessive iCustom Indicator Loading
    By MusicMan in forum MQL programming
    Replies: 2
    Last Post: 12-28-2009, 15:48
  4. AbsoluteStrength iCustom
    By Rengoku in forum MQL programming
    Replies: 3
    Last Post: 10-26-2009, 12:29

Tags for this Thread

change, color, custom indicator, ex4, experts, index, indicator, indicators, limit, mq4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •