Download MetaTrader 5
To add comments, please log in or register
Are you used to trading from your smartphone? Mobile version of MetaTrader 5 will suit you best!
Nato
22
Nato 2014.03.09 13:25 

Dears,

I need to get value of iMA from a specified time, how I do this?

thanks

whroeder1
13596
whroeder1 2014.03.09 13:42  
Convert the "specified time" to a bar shift, use that in iMA
Nato
22
Nato 2014.03.09 13:49  
WHRoeder:
Convert the "specified time" to a bar shift, use that in iMA

I'm sorry, but I don't know that I do. could you give me an example?
Keith Watford
Moderator
7886
Keith Watford 2014.03.09 20:09  

This thread

https://forum.mql4.com/61669

Has an example

Nato
22
Nato 2014.03.10 20:51  

What is wrong with this script and how to fix?

<SRC by Moderator: Ubzen>

//+------------------------------------------------------------------+
//| test.mq4 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
    //---- indicators
    shift = iBarShift(NULL, PERIOD_H1, 13 : 00)
    iMA(NULL, 0, 13, 8, MODE_SMMA, PRICE_MEDIAN, shift);
    //----
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
    //----
    //----
    return (0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
     int counted_bars = IndicatorCounted();
    //----
    //----
    return (0);
}
//+------------------------------------------------------------------+
Keith Watford
Moderator
7886
Keith Watford 2014.03.10 21:37  

unless this is something new in mql4, I don't think that you can input datetime like that

shift = iBarShift(NULL, PERIOD_H1, 13 : 00)

You can use

shift = iBarShift(NULL, PERIOD_H1, D'2014.03.09 13:00');
Nato
22
Nato 2014.03.10 21:50  

This is the errors

'iMA' - an operator expected C:\Program Files (x86)\FXDD Malta - MetaTrader 4\experts\indicators\teste.mq4 (16, 5)
'=' - assignment expected C:\Program Files (x86)\FXDD Malta - MetaTrader 4\experts\indicators\teste.mq4 (15, 11)
'iMA' - semicolon expected C:\Program Files (x86)\FXDD Malta - MetaTrader 4\experts\indicators\teste.mq4 (16, 5)
'}' - semicolon expected C:\Program Files (x86)\FXDD Malta - MetaTrader 4\experts\indicators\teste.mq4 (18, 1)

Keith Watford
Moderator
7886
Keith Watford 2014.03.11 00:04  

if you double click the error report line, the cursor will go to the problem area, makes them easier to find

I've inserted the missing ; I'm still not sure about the 13:00

int init() {
    //---- indicators
    shift = iBarShift(NULL, PERIOD_H1, 13 : 00) ;
    iMA(NULL, 0, 13, 8, MODE_SMMA, PRICE_MEDIAN, shift);
    //----
}
/
To add comments, please log in or register