Results 1 to 9 of 9
 0 Attachment(s)    

Thread: Indicators embedding in the EA - Help please!!!

  1. #1

    Question Indicators embedding in the EA - Help please!!!

    Hello! I would like to use the Cronex DeMarker direct in the EA code, I wrote the following lines, but the EA is not working, please could you debug the code? Thanks in advance!

    //Signal Conditions

    //Indicator Parameters
    int DeMarker=25;
    int FastMA=14;
    int SlowMA=25;

    //Indicator Buffers
    double DeMarkerBuffer[];
    double FastMABuffer[];
    double SlowMABuffer[];

    //Cronex DeMarker
    int limit;
    int counted_bars=IndicatorCounted();

    //Last Counted Bar Will Be Recounted
    if(counted_bars>0) counted_bars--;
    limit=Bars-counted_bars;

    //DeMarker Counted In The 1st Buffer
    for(int i=0; i<limit; i++)
    DeMarkerBuffer[i]=iDeMarker(NULL,0,DeMarker,i);

    //Signal Line Counted In The 2nd Buffer
    for(i=0; i<limit; i++)
    {
    FastMABuffer[i]=iMAOnArray(DeMarkerBuffer,Bars,FastMA,0,MODE_LWMA ,i);
    SlowMABuffer[i]=iMAOnArray(DeMarkerBuffer,Bars,SlowMA,0,MODE_LWMA ,i);

    bool BUY=false;
    bool SELL=false;
    bool SignalBUY=false;
    bool SignalSELL=false;

    if((DeMarkerBuffer[i]>FastMABuffer[i])&&(FastMABuffer[i]>SlowMABuffer[i]))
    BUY=true;

    if((DeMarkerBuffer[i]<FastMABuffer[i])&&(FastMABuffer[i]<SlowMABuffer[i]))
    SELL=true;

    }
    Last edited by szmvscla; 06-23-2009 at 16:32.

  2. #2

    Question

    I did some change in the code, but it is not working yet, please help me if you can.

    //Signal Conditions

    //Indicator Parameters
    int DeMarker=25;
    int FastMA=14;
    int SlowMA=25;

    //Indicator Buffers
    double DeMarkerBuffer[];
    double FastMABuffer[];
    double SlowMABuffer[];

    //Cronex DeMarker
    int limit=1;
    for(int i=1;i<=limit;i++)
    {

    DeMarkerBuffer[i]=iDeMarker(NULL,0,DeMarker,i);
    FastMABuffer[i]=iMAOnArray(DeMarkerBuffer,Bars,FastMA,0,MODE_LWMA ,i);
    SlowMABuffer[i]=iMAOnArray(DeMarkerBuffer,Bars,SlowMA,0,MODE_LWMA ,i);

    bool BUY=false;
    bool SELL=false;

    if((DeMarkerBuffer[i]>FastMABuffer[i])&&(FastMABuffer[i]>SlowMABuffer[i]))
    BUY=true;

    if((DeMarkerBuffer[i]<FastMABuffer[i])&&(FastMABuffer[i]<SlowMABuffer[i]))
    SELL=true;

    }

    The indicator you can find here: Taichi DeMarker EA
    Last edited by szmvscla; 06-23-2009 at 16:48.

  3. #3

    Smile

    I changed the code again, but it is not working yet, please help me, thanks in advance!

    //Signal Conditions

    double DeMarker[];
    double FastMA[];
    double SlowMA[];

    int limit=1;
    for(int i=1;i<=limit;i++)
    {

    DeMarker[i]=iDeMarker(NULL,0,25,i);
    FastMA[i]=iMAOnArray(DeMarker,0,14,0,MODE_LWMA,i);
    SlowMA[i]=iMAOnArray(DeMarker,0,25,0,MODE_LWMA,i);

    bool BUY=false;
    bool SELL=false;


    if((DeMarker[i]>FastMA[i])&&(FastMA[i]>SlowMA[i]))
    BUY=true;

    if((DeMarker[i]<FastMA[i])&&(FastMA[i]<SlowMA[i]))
    SELL=true;

    }
    Last edited by szmvscla; 06-23-2009 at 17:49.

  4. #4

    Talking

    I changed again.

    //Signal Conditions

    double DeMarker[];
    double FastMA[];
    double SlowMA[];

    int limit=1;
    for(int i=1;i<=limit;i++)
    {

    DeMarker[i]=iDeMarker(NULL,0,25,i);
    FastMA[i]=iMAOnArray(DeMarker,0,14,0,MODE_LWMA,i);
    SlowMA[i]=iMAOnArray(DeMarker,0,25,0,MODE_LWMA,i);

    double DMS, DFM, DSM;

    DMS = DeMarker[i];
    DFM = FastMA[i];
    DSM = SlowMA[i];

    bool BUY=false;
    bool SELL=false;


    if((DMS>DFM)&&(DFM>DSM))
    BUY=true;

    if((DMS<DFM)&&(DFM<DSM))
    SELL=true;

    }

  5. #5

    Default

    Presumably Cronex De Marker is a variant of the standard MetaTrader De Marker indicator?

    If so, where is the souce code of the custom indicator?

    If not, and there's nothing special about the custom indicator, you don't need to bother.

  6. #6

    Arrow

    Quote Originally Posted by jezzer1961 View Post
    Presumably Cronex De Marker is a variant of the standard MetaTrader De Marker indicator?

    If so, where is the souce code of the custom indicator?

    If not, and there's nothing special about the custom indicator, you don't need to bother.
    The code is:

    //+------------------------------------------------------------------+
    //| Cronex DeMarker.mq4 |
    //| Copyright 2007, Cronex. |
    //| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
    //+------------------------------------------------------------------+
    #property copyright "Copyright 2007, Cronex"
    #property link "http://www.metaquotes.net/"
    //---- indicator settings
    #property indicator_separate_window
    #property indicator_buffers 3
    #property indicator_color1 Silver
    #property indicator_color2 Blue
    #property indicator_color3 Red
    //#property indicator_width1 2
    //---- indicator parameters
    extern int DeMarker=25;
    extern int FastMA=14;
    extern int SlowMA=25;
    //---- indicator buffers
    double DeMarkerBuffer[];
    double FastMABuffer[];
    double SlowMABuffer[];
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    int init()
    {
    //---- drawing settings
    SetIndexStyle(0,DRAW_LINE);
    SetIndexStyle(1,DRAW_LINE);
    SetIndexStyle(2,DRAW_LINE);
    SetIndexDrawBegin(1,SlowMA);
    // IndicatorDigits(Digits+1);
    //---- indicator buffers mapping
    SetIndexBuffer(0,DeMarkerBuffer);
    SetIndexBuffer(1,FastMABuffer);
    SetIndexBuffer(2,SlowMABuffer);
    //---- name for DataWindow and indicator subwindow label
    IndicatorShortName("Cronex DeMarker");
    SetIndexLabel(0,"DeMarker");
    SetIndexLabel(1,"Fast MA");
    SetIndexLabel(2,"Slow MA");
    //---- initialization done
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Cronex DeMarker |
    //+------------------------------------------------------------------+
    int start()
    {
    int limit;
    int counted_bars=IndicatorCounted();
    //---- last counted bar will be recounted
    if(counted_bars>0) counted_bars--;
    limit=Bars-counted_bars;
    //---- DeMarker counted in the 1-st buffer

    for(int i=0; i<limit; i++)
    DeMarkerBuffer[i]=iDeMarker(NULL,0,DeMarker,i);
    //---- signal line counted in the 2-nd buffer
    for(i=0; i<limit; i++)
    {
    FastMABuffer[i]=iMAOnArray(DeMarkerBuffer,Bars,FastMA,0,MODE_LWMA ,i);
    SlowMABuffer[i]=iMAOnArray(DeMarkerBuffer,Bars,SlowMA,0,MODE_LWMA ,i);
    }
    //---- done
    return(0);
    }
    //+------------------------------------------------------------------+

    I know how to use it with the iCustom technical indicator, but I want to write it in the EA code direct, but I don't know how to do that, please help me if you can, thanks a lot!

  7. #7

    Default

    When you use iAnythingOnArray within an EA, you need first to set the array as a series.

    It's difficult to explain very easily, but if you use Google I think you will find plenty of links to explain how to do it.

  8. #8

    Thumbs up

    Quote Originally Posted by jezzer1961 View Post
    When you use iAnythingOnArray within an EA, you need first to set the array as a series.

    It's difficult to explain very easily, but if you use Google I think you will find plenty of links to explain how to do it.
    Thank you very much! I will try to find it and if possible when you have free time, please post here the code that I have to write in the EA "body".

  9. #9
    Member
    Join Date
    Jan 2009
    Location
    Austria
    Posts
    325

    Default

    Quote Originally Posted by szmvscla View Post
    Thank you very much! I will try to find it and if possible when you have free time, please post here the code that I have to write in the EA "body".
    i suggest you should confirm the DeMarker signals like

    EMA+RSI

    if(TradeEMARSI)
    {
    if(iMA(0,0,5,0,MODE_EMA,PRICE_CLOSE,0)>iMA(0,0,12,0,MODE_EMA,PRICE_CLOSE,0) && iRSI(0,0,21,PRICE_CLOSE,0)>50
    && (iRSI(0,0,21,PRICE_CLOSE,1)<50 || iRSI(0,0,21,PRICE_CLOSE,2)<50)){myOrderType=0;} //Buy

    if(iMA(0,0,5,0,MODE_EMA,PRICE_CLOSE,0)<iMA(0,0,12, 0,MODE_EMA,PRICE_CLOSE,0) && iRSI(0,0,21,PRICE_CLOSE,0)<50
    && (iRSI(0,0,21,PRICE_CLOSE,1)>50 || iRSI(0,0,21,PRICE_CLOSE,2)>50)){myOrderType=1;} //Sell
    }

Similar Threads

  1. Indicators
    By Kovactrader in forum Indicators
    Replies: 9
    Last Post: 03-31-2012, 11:00
  2. EMA indicators
    By forexpop in forum Indicators
    Replies: 0
    Last Post: 09-13-2009, 14:18
  3. Embedding a Custom Indicator into an EA
    By jeet1970 in forum MQL programming
    Replies: 3
    Last Post: 09-10-2009, 12:13
  4. EMA of indicators
    By przem81621 in forum Ideas for expert advisors
    Replies: 0
    Last Post: 03-18-2009, 19:13

Tags for this Thread

backtesting, change, color, custom indicator, expert, forex, forex trading, free, how to, indicator, indicators, limit, metatrader, mq4, signal, signals, thank you, time, trading, trading platform, trading software

Posting Permissions

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