Download MetaTrader 5
To add comments, please log in or register
Searching on MQL5.community is performed in all sections. Try it!
fxnew5
58
fxnew5 2016.10.23 17:56 

hello,


I'm just going step by step through an introducaton by a good russian expert how to build an EA.

Now, I'm used to MT4 only. How do I get the values of a custom indicator(let's say Bar 0)  ---  in an EA?  (and an indicator displayed)

Since it's sunday and no real time data at the moment I put

int OnInit()

   {Comment("ABC"); return(INIT_SUCCEEDED);  the comment function works like in MT4  > shows "ABC"

  }   but when I replace ABC  by  iMA(NULL,0,0,0,MODE_SMA,PRICE_CLOSE) the comment shows "-1" which can't be a value of this MA!


I finally want to replace this iMA by a custom indicator (which I already have in MT5 and it works)

The design is basically: iCustom(NULL,0,"custom name",paramterNr1,Nr2,3,4,Nr5,0,0);  in MT4 the last 0 adresses the BAR and the one before that the buffer

my custom indicator has 3 buffers(0-2), I need buffer 1 and 2 for EA signals


If anyone knows how to solve it thanks in advance 

whroeder1
13936
whroeder1 2016.10.23 18:17  
fxnew5: but when I replace ABC  by  iMA(NULL,0,0,0,MODE_SMA,PRICE_CLOSE) the comment shows "-1" which can't be a value of this MA!
It is when you use an invalid call that doesn't even compile
iMA - Technical Indicators - MQL4 Reference
 
iMA(
   NULL,
   0,
   0,
   0,
   MODE_SMA,
   PRICE_CLOSE
   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
)
double  iMA(
   string       symbol,           // symbol
   int          timeframe,        // timeframe
   int          ma_period,        // MA averaging period
   int          ma_shift,         // MA shift
   int          ma_method,        // averaging method
   int          applied_price,    // applied price
   int          shift             // shift
   );
 
iMA - Technical Indicators - MQL4 Reference
iMA - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iMA - Technical Indicators - MQL4 Reference
Indra Lukmana
1782
Indra Lukmana 2016.10.23 18:21  
fxnew5:

hello,


I'm just going step by step through an introducaton by a good russian expert how to build an EA.

Now, I'm used to MT4 only. How do I get the values of a custom indicator(let's say Bar 0)  ---  in an EA?  (and an indicator displayed)

Since it's sunday and no real time data at the moment I put

int OnInit()

   {Comment("ABC"); return(INIT_SUCCEEDED);  the comment function works like in MT4  > shows "ABC"

  }   but when I replace ABC  by  iMA(NULL,0,0,0,MODE_SMA,PRICE_CLOSE) the comment shows "-1" which can't be a value of this MA!


I finally want to replace this iMA by a custom indicator (which I already have in MT5 and it works)

The design is basically: iCustom(NULL,0,"custom name",paramterNr1,Nr2,3,4,Nr5,0,0);  in MT4 the last 0 adresses the BAR and the one before that the buffer

my custom indicator has 3 buffers(0-2), I need buffer 1 and 2 for EA signals


If anyone knows how to solve it thanks in advance 

you can read the iCustom section or iMA section

 you have to ensure the indicator input sequence are correct, the last 2 input is indicator buffer and bar index

 iCustom(NULL,0,"custom name",paramterNr1,Nr2,3,4,Nr5,0,0)

whroeder1
13936
whroeder1 2016.10.23 18:22  
  1. whroeder1:
    It is when you use an invalid call that doesn't even compile
    iMA - Technical Indicators - MQL4 Reference
     
    iMA(
       NULL,
       0,
       0,            // Zero period?
       0,
       MODE_SMA,
       PRICE_CLOSE
       >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    )
    double  iMA(
       string       symbol,           // symbol
       int          timeframe,        // timeframe
       int          ma_period,        // MA averaging period
       int          ma_shift,         // MA shift
       int          ma_method,        // averaging method
       int          applied_price,    // applied price
       int          shift             // shift
       );
     
  2. Detailed explanation of iCustom - MQL4 forum
fxnew5
58
fxnew5 2016.10.23 19:18  

well, thanks for the fast feedback, folks, but

in MT4

Comment( iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,0));   works  ... and it shows the value of the MA

whereas in MT 5 (same code copied) I get "worng parameters count" ??  and that indicator is a  default one..

--

after I get this resolved I'd like to adress and check/ show by comment function the value of my custom indicator

iCustom(NULL,0,"custom name",paramterNr1,Nr2,3,4,Nr5,0,0);  in MT5!!  (since I got those things in MT4 for a long time)

whroeder1
13936
whroeder1 2016.10.23 19:46  
fxnew5: whereas in MT 5 (same code copied) I get "worng parameters count" ??  and that indicator is a  default one..
Of course it does. MT5 isn't the same. RTFM Technical Indicators / iMA - Reference on algorithmic/automated trading language for MetaTrader 5 OnInit creates a MA handle and OnCalculate uses it.
Documentation on MQL5: Technical Indicators / iMA
Documentation on MQL5: Technical Indicators / iMA
  • www.mql5.com
Technical Indicators / iMA - Reference on algorithmic/automated trading language for MetaTrader 5
fxnew5
58
fxnew5 2016.10.23 20:15  
whroeder1:
Of course it does. MT5 isn't the same. RTFM Technical Indicators / iMA - Reference on algorithmic/automated trading language for MetaTrader 5 OnInit creates a MA handle and OnCalculate uses it.
whroeder1:
Of course it does. MT5 isn't the same. RTFM Technical Indicators / iMA - Reference on algorithmic/automated trading language for MetaTrader 5 OnInit creates a MA handle and OnCalculate uses it.

so should one use this part of the manual ("The function returns the handle of the Moving Average indicator") in the declaration part of the EA (MT5)?

int  iMA(

   string               symbol,            // symbol name
   etc......
   ENUM_APPLIED_PRICE   applied_price      // type of price or handle

   );


and then using the command

iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE)

in the  OnTick() part     to adress it brings "function must have a body"  = error    ??


whroeder1
13936
whroeder1 2016.10.23 20:52  
fxnew5: and then using the command
What part of "MA handle and OnCalculate uses it," was unclear?
fxnew5
58
fxnew5 2016.10.23 21:05  

Thanks WH, but does one have to integrate - the complete - code on https://www.mql5.com/en/docs/indicators/ima

i.e. from "Example" downward..?

in a new MT5 EA to use (or adress) the simple iMA function?

I doubt it, cause that would be really cumbersome compared to the iCustom use in MT4 where you only got to have the function in the specific indicator folder and then use

the iCustom(xxxxx) properly to adress the parameter you want to retrieve in an MT4 EA...

Documentation on MQL5: Technical Indicators / iMA
Documentation on MQL5: Technical Indicators / iMA
  • www.mql5.com
Technical Indicators / iMA - Reference on algorithmic/automated trading language for MetaTrader 5
/
To add comments, please log in or register