Mql5 not work like it. you need use " CopyBuffer " to get value of indicator.
GonzaloV:
Hi, i have this problems, in every chart it always returns "10". What i done wrong?
this is the code, very very simply.
Help Please
You are getting the handle of the indicator.
You need to use ArraySetAsSeries declared @ OnInit() part of your EA and, CopyBuffer, declared @ OnTick() part of your EA to get the indicator values.
Hi GonsaloV,
please try this approach:
//+------------------------------------------------------------------+ //| CruceDeMedias.mq5 | //| Copyright 2014, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" int Media_Movil; double MA_Buffer[]; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { Media_Movil = iMA(Symbol(),PERIOD_M5,3,1,MODE_SMA,PRICE_CLOSE); ArraySetAsSeries(MA_Buffer,true); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { IndicatorRelease(Media_Movil); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if(CopyBuffer(Media_Movil,0,0,2,MA_Buffer)!=2) return; //--- Comment("Media_Movil[0] = ",DoubleToString(MA_Buffer[0],6),"\n","Media_Movil[1] = ",DoubleToString(MA_Buffer[1],6)); } //+------------------------------------------------------------------+

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, i have this problems, in every chart it always returns "10". What i done wrong?
this is the code, very very simply.
Help Please