Results 1 to 3 of 3
 0 Attachment(s)    

Thread: Code needed to continuously load an indicator

  1. #1

    Default Code needed to continuously load an indicator

    I was wondering if anyone with good programming skills can tell me how to produce code that can continuously load an indicator every 90 seconds.
    I'm sure there must be a way.
    Just so you know I have produced this indicator that uses only one other indicator to draw arrows on a price chart.

    If you have any idea please drop me a line.

    Thanks

  2. #2
    Junior Member
    Join Date
    Feb 2009
    Posts
    25

    Default

    Hi tradability


    I'll give u an example How to produce code that can continuously load Rsi Indicator every 90 seconds.

    you will let a script work with your EA and RSI Indicator


    In script you will write this code below

    Code:
     #property show_confirm
    
    double  R;
    
    int start()
      {
    int y=0;
    while(y==0){
    R=iRSI(NULL, 0, 14, PRICE_CLOSE, 0);
    GlobalVariableSet("RSI",R);
    Sleep(90000);
    RefreshRates();
    }
       return(0);
      }
    In your EA u will write this code

    Code:
    double MyIndicator;
    int start()
      {
    MyIndicator=GlobalVariableGet("RSI");
    
    // You will complete the EA code and use MyIndicator (double value ) It load each 90 Seconds 
       return(0);
      }
    Then you will set the script on the chart with your EA , The script will send RSI value to your EA each 90 Seconds

    For example if your Indicator call El_Indicator you will use

    Code:
    iCustom(NULL,0,"El_Indicator",.......;
    replace
    Code:
    iRSI(NULL, 0, 14, PRICE_CLOSE, 0)
    I must test your Indicator before I complete iCustom() and tell u how can u use it.
    because there 's a different between Indicators ,some indicators return (double value) and zero ,some return empty value and (double value)
    Last edited by trader12; 11-10-2009 at 19:49.

  3. #3

    Default Trader12

    Thanks for the information. I wrote following code and according to you, it is supposed to reaload the custom indicator every time it is being called in a script.

    //+------------------------------------------------------------------+
    //| EI_Reloader.mq4 |
    //+------------------------------------------------------------------+

    int token;

    int init() {
    ObjectsDeleteAll();
    token = 0;
    }

    //+------------------------------------------------------------------+
    //| script program start function |
    //+------------------------------------------------------------------+
    int start()
    {
    //----
    while(!IsStopped()) {
    RefreshRates();
    double up = iCustom(Symbol(),0,"ABC",0,0,1);
    double dn = iCustom(Symbol(),0,"ABC",0,1,1);
    if (up>0.0) {
    token++;
    ObjectCreate("Buy" + token, OBJ_ARROW, 0, Time[1], Low[1]);
    ObjectSet("Buy" + token, OBJPROP_STYLE, STYLE_DOT);
    ObjectSet("Buy" + token, OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
    ObjectSet("Buy" + token, OBJPROP_COLOR, Blue);
    } else if(dn>0.0) {
    token++;
    ObjectCreate("Sell" + token, OBJ_ARROW, 0, Time[1], High[1]);
    ObjectSet("Sell" + token, OBJPROP_STYLE, STYLE_DOT);
    ObjectSet("Sell" + token, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
    ObjectSet("Sell" + token, OBJPROP_COLOR, Red);
    }
    Sleep(90000);
    }
    //----
    return(0);
    }
    //+------------------------------------------------------------------+

    However, it does not reaload the indicator. I looked into the MQL4 documentation and did not find any reference to what you explained. Why would it re-load custom indicator when called in script and wont when it is called from EA?

Similar Threads

  1. Code needed to track ea in order to hedge
    By snkpool in forum MQL programming
    Replies: 0
    Last Post: 09-28-2010, 03:57
  2. How to load iCUSTOM for this indicator?
    By hanna in forum MQL programming
    Replies: 0
    Last Post: 05-14-2010, 07:42
  3. EA needed for this indicator plz.
    By cashgrade in forum Indicators
    Replies: 2
    Last Post: 01-19-2010, 02:54
  4. EA needed for Float indicator
    By bcajes in forum Ideas for expert advisors
    Replies: 2
    Last Post: 01-08-2010, 03:39
  5. Simple EA needed for indicator
    By forexpop in forum MQL programming
    Replies: 0
    Last Post: 07-16-2009, 04:00

Tags for this Thread

abc, color, custom indicator, high, how to, indicator, indicators, mq4, mql, programming, rsi, test, time, trader

Posting Permissions

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