How to get custom indior values?
Page 1 of 502 12 LastLast
Results 1 to 10 of 13

Thread: How to get custom indior values?

  1. #1
    I am trying to utilize the EMA Crossover Signal indior within an EA and am have trouble getting the values out of it. I'm use iCustom() and no matter what style I choose (0 or 1) the indior simply returns 2147483647. Any ideas on what I am doing wrong?

    Here is an illuion of what I am trying to do:

    dual EMA = iCustom(NULL,0,EMA Crossover Signal,5,13,false,0,0);

    Printing(EMA);

    Here is your indy code:

    // ------------------------------------------------------------------
    //| EMA-Crossover_Signal. Mq4 |
    //| Copyright © 2005, Jason Robinson (jnrtrading) |
    //| http://www.jnrtading.co.uk |
    //p------------------------------------------------------------------

    /*
    ------------------------------------------------------------------
    | lets you input two ema periods and it'll then show you in |
    | Which point they crossed over. It's more usful about the shorter |
    | spans that get obscured by the bars / candlesticks and when |
    | the zoom level is outside. Also allows you then to remove the emas |
    | in the chart. (emas are originally set at 5 and 6) |
    ------------------------------------------------------------------
    */
    #property copyright Copyright © 2005, Jason Robinson (jnrtrading)
    #property Hyperlink http://www.jnrtrading.co.uk

    #property indior_chart_window
    #property indior_buffers 2
    #property indior_color1 SeaGreen
    #property indior_color2 Red

    double CrossUp[];
    double CrossDown[];
    extern int FasterEMA = 5;
    extern int SlowerEMA = 13;
    extern bool SoundON=false;
    double alertTag;
    double control=2147483647;

    // ------------------------------------------------------------------
    //| Custom indior initialization function |
    // ------------------------------------------------------------------
    int init()

    //-- indiors
    SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
    SetIndexArrow(0, 233);
    SetIndexBuffer(0, CrossUp);
    SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
    SetIndexArrow(1, 234);
    SetIndexBuffer(1, CrossDown);
    //--
    return(0);

    // ------------------------------------------------------------------
    //| Custom indior deinitialization function |
    // ------------------------------------------------------------------
    int deinit()

    //--

    //--
    return(0);

    // ------------------------------------------------------------------
    //| Custom indior iteration function |
    // ------------------------------------------------------------------
    int start()
    int limit, I, counter;
    double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter;
    double Range, AvgRange;
    int counted_bars=IndiorCounted();
    //-- check for possible errors
    if(counted_barslt;0) return(-1);
    //-- last counted bar will be recounted
    if(counted_barsgt;0) counted_bars--;

    limit=Bars-counted_bars;

    for(I = 0; I lt;= limit; I )

    counter=I;
    Range=0;
    AvgRange=0;
    for (counter=I ;counterlt;=I 9;counter )

    AvgRange=AvgRange MathAbs(High[counter]-Low[counter]);

    Range=AvgRange/10;

    fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, I);
    fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, I 1);
    fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

    slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, I);
    slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, I 1);
    slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

    if ((fasterEMAnow gt; slowerEMAnow) (fasterEMAprevious lt; slowerEMAprevious) (fasterEMAafter gt; slowerEMAafter))
    CrossUp[I] = Low[I] - Range*0.5;

    else if ((fasterEMAnow lt; slowerEMAnow) (fasterEMAprevious gt; slowerEMAprevious) (fasterEMAafter lt; slowerEMAafter))
    CrossDown[I] = High[I] Range*0.5;

    if (SoundON==true I==1 CrossUp[I] gt; CrossDown[I] alertTag! =Time[0])
    Alert(EMA Cross Trend going Down on ,Symbol(), Stage());
    alertTag = Time[0];

    if (SoundON==accurate I==1 CrossUp[I] lt; CrossDown[Id] alertTag! =Time[0])
    Alert(EMA Cross Trend going On ,Symbol(), ,Stage());
    alertTag = Time[0];



    return(0);

  2. #2
    Check the file name of this icustom. Be sure you have all of the dashes and underscores in place. Also be sure that the capital letters are in the right spot. It must be just as the document is spelled.

  3. #3
    Quote Originally Posted by ;
    check the file name of the icustom. Be certain that you have all of the dashes and underscores in place. Also be certain the funds letters are in the ideal spot. As the file is spelled, it must be exactly.
    No fortune... the file name is EMA Crossover Signal and that is exactly how I have it entered.

  4. #4
    Publish the indior file into somthing simple like EMACS or some thing. I have had some issues with filenames and distances.

  5. #5
    Quote Originally Posted by ;
    Rename the indior document into somthing simple like EMACS or some thing. I have had some problems with filenames and distances.
    Nope, that didn't work either.

    I am thinking about just incorporating the indy code right into the EA or merely composing own MA cross code... however I was expecting not to reinvent the wheel and also the use the EMA Signals to see the arrows once it see that a cross.

  6. #6
    Have you looked at what worth the indior returns in the information window? It wouldn't have any values.

  7. #7
    Your iCustom should look something like this.

    ICustom(NULL, 0, EMA Crossover Signal , FasterEMA, SlowerEMA, 0);

    I'd edit the indior to set every non-arrow to 0, like this. I find it simpler when placing trade logic.

    Quote Originally Posted by ;
    // ------------------------------------------------------------------
    //| EMA-Crossover_Signal. Mq4 |
    //| Copyright © 2005, Jason Robinson (jnrtrading) |
    //| http://www.jnrtading.co.uk |
    //p------------------------------------------------------------------

    /*
    ------------------------------------------------------------------
    | lets you enter two ema periods and it will then show you at |
    | Which point they crossed over. It's more usful on the briefer |
    | spans which get obscured by the bars / candlesticks and when |
    | the zoom level is outside. Also allows you to take out the emas |
    | from the chart. (emas are initially set at 5 and 6) |
    ------------------------------------------------------------------
    */
    #property copyright Copyright © 2005, Jason Robinson (jnrtrading)
    #property hyperlink http://www.jnrtrading.co.uk

    #property indior_chart_window
    #property indior_buffers 2
    #property indior_color1 SeaGreen
    #property indior_color2 Red

    double CrossUp[];
    double CrossDown[];
    extern int FasterEMA = 5;
    extern int SlowerEMA = 13;
    extern bool SoundON=false;
    double alertTag;
    double control=2147483647;

    // ------------------------------------------------------------------
    //| Custom indior initialization function |
    // ------------------------------------------------------------------
    int init()

    //-- indiors
    SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
    SetIndexArrow(0, 233);
    SetIndexBuffer(0, CrossUp);
    SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
    SetIndexArrow(1, 234);
    SetIndexBuffer(1, CrossDown);
    //--
    return(0);

    // ------------------------------------------------------------------
    //| Custom indior deinitialization function |
    // ------------------------------------------------------------------
    int deinit()

    //--

    //--
    return(0);

    // ------------------------------------------------------------------
    //| Custom indior iteration function |
    // ------------------------------------------------------------------
    int start()
    int limit, I, counter;
    double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter;
    double Range, AvgRange;
    int counted_bars=IndiorCounted();
    //-- check for possible errors
    if(counted_barslt;0) return(-1);
    //-- last counted bar will be recounted
    if(counted_barsgt;0) counted_bars--;

    limit=Bars-counted_bars;

    for(I = 0; I lt;= limit; I )

    counter=I;
    Range=0;
    AvgRange=0;
    for (counter=I ;counterlt;=I 9;counter )

    AvgRange=AvgRange MathAbs(High[counter]-Low[counter]);

    Range=AvgRange/10;

    fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, I);
    fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, I 1);
    fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

    slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, I);
    slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, I 1);
    slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1);

    if ((fasterEMAnow gt; slowerEMAnow) (fasterEMAprevious lt; slowerEMAprevious) (fasterEMAafter gt; slowerEMAafter))
    CrossUp[I] = Low[I] - Range*0.5;
    else
    CrossUp[I] = 0;

    else if ((fasterEMAnow lt; slowerEMAnow) (fasterEMAprevious gt; slowerEMAprevious) (fasterEMAafter lt; slowerEMAafter))
    CrossDown[I] = High[I] Range*0.5;
    else
    CrossDown[I] = 0;

    if (SoundON==true I==1 CrossUp[I] gt; CrossDown[I] alertTag! =Timing[0])
    Alert(EMA Cross Trend going Down on ,Symbol(), ,Stage());
    alertTag = Timing[0];

    if (SoundON==true I==1 CrossUp[I] lt; CrossDown[I] alertTag! =Timing[0])
    Alert(EMA Cross Trend going On ,Symbol(), ,Stage());
    alertTag = Timing[0];



    return(0);

  8. #8
    Should you construct your EA to exchange according to this indior solely, please note that, this indior is repainting big time. The arrow will appear and vanish and reappear again. Read the indior code carefully, and alter these lines to make it a non repainting arrow.

  9. #9
    Quote Originally Posted by ;
    Have you really looked at what values the indior returns in the data window? It usually would not have any values.
    I'm interested, if a field for values within an indior are blank, what do I place in the commerce logic? EMPTY_VALUE does not do the job.

  10. #10
    Quote Originally Posted by ;
    I'm curious, if a field for values within an indior are blank, what do I put in the trade logic? EMPTY_VALUE doesn't work.
    I really don't understand. I can not really program, only edit. I just know when there is no value returned it generally creates a problem for me. I do not even know if it's the issue here but I thought I would bring it to the smarter member's attention as a potential issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information