[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 790

 
obla4ko:

That's weird. You mean Momentum, what's that got to do with Mashka?

How about this?

double iMomentum( string symbol, int timeframe, int period, int applied_price, int shift)
 
artmedia70:

That's weird. You mean Momentum, what's that got to do with Mashka?

How about this?

double iMomentum( string symbol, int timeframe, int period, int applied_price, int shift)
I'm actually saying the same thing - only in MT4-momentum (see code above) NO(!!! )
double iMomentum()

...... and the question remains - where and how to put it in

string symbol
into the existing mt4-motroom code, if there is no
double iMomentum()

...

write it again based on

double iMomentum()

, or can it be written into the existing code!

 
obla4ko:
I actually mean the same thing - only in MT4-momentum (see code above) NO(!!!)

Honestly, I don't understand the question either.

double iMomentum( string symbol, int timeframe, int period, int applied_price, int shift) 
Does it not work or what?
 
Abzasc:

To be honest, I don't understand the question either.

Doesn't it work?

I need the Eura momentum to hang on the Pound window! - and if you don't write the symbol separately, it defaults to the currency it's attached to in the window... i see why i need this stuff so much :))?
 
Let's think together, where in the code could there be a symbol? A quick look will show us that apart from Close[i] no price parameters are used in the code. We look in the Close[] reference and find out that this time series is the closing price at the current symbol. But another time series, iClose( string symbol, int timeframe, int shift) allows us to get data from the specified symbol. So, replace Close[i] in the code with iClose( _Symbol, 0, i) and enter the external variable extern string _Symbol="EURUSD"; set the value of the required symbol in it and enjoy the result. I haven't tested it but it should work.
 
granit77:
Let's think together, where in the code can a symbol be present? A cursory inspection will show that no price parameters are used apart from Close[i]. Let's look at Close[] in the reference and find out that this time series is the closing price at the current symbol. But another time series, iClose( string symbol, int timeframe, int shift) allows us to get data from the specified symbol. So, replace Close[i] in the code with iClose( _Symbol, 0, i) and enter the external variable extern string _Symbol="EURUSD"; set the value of the required symbol in it and enjoy the result. I haven't checked it but it should work.


It is not quite like this. As always, "the devil is in the nuances".

If you are trying to display an indicator based on the bars of another symbol on the current symbol, you must take care to match the bars.

I.e. the bar numbers for the same time for different symbols may not be the same.

 
obla4ko:
I need the eura momentum to hang on the pound window! - and if you don't write the symbol separately, it defaults to the currency it's attached to in the window... i see why i need this stuff so much :))?

Ah, I thought the data needed to be pulled out...

I don't know, I would make an indicator and pull data into it via iMomentum... or iMomentumOnArray maybe

 
PapaYozh:


Not really. As always "the devil is in the nuances".

If you are trying to display an indicator based on the bars of another symbol on the current symbol, you must take care to match the bars.

I.e. the bar numbers for the same time for different symbols may not coincide.

Where have you been before? You're right. Added it, it's working.

//+------------------------------------------------------------------+
//|                                                     Momentum.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//---- input parameters
extern int     MomPeriod = 14;
extern string  _Symbol   = "EURUSD"; 
//---- buffers
double MomBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MomBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="Mom("+MomPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,MomPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Momentum                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
   
//----
   if(Bars<=MomPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=MomPeriod;i++) MomBuffer[Bars-i]=0.0;
      
//----
   
   i=Bars-MomPeriod-1;
   if(counted_bars>=MomPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
      int baropen =iBarShift(_Symbol,0,Time[i]);
      int barclose=iBarShift(_Symbol,0,Time[i+MomPeriod]);
      MomBuffer[i]=iClose(_Symbol,0,baropen) *100/iClose(_Symbol,0,barclose);
      i--;
     }
   return(0);
  }
 
granit77:

Where have you been before? You're right. Added it, it's working.


Well done, Victor!
And the cloud is silent... :))
 
granit77:

Where have you been before? That's true. Added it, it's working.


Well, I sometimes have one eye on this thread and sometimes reply.

So "excuse me", helping out, so to speak, as much as possible.

:)

Reason: