Download MetaTrader 5

Moving Average for the only last two days

To add comments, please log in or register
Samih Abdelli
67
Samih Abdelli  

hi guys

‌‌have anyone seen a modified moving average, I need one the gimme the MA of the only last one or two days if I apply it to short TF, and last week or two weeks if it is in for hours TF

l‌ink or a hint on code will be good

t‌hank you

Fernando Carreiro
3389
Fernando Carreiro  
s4m111h: ‌‌have anyone seen a modified moving average, I need one the gimme the MA of the only last one or two days if I apply it to short TF, and last week or two weeks if it is in for hours TF. l‌ink or a hint on code will be good

Please explain in more details, as you are not making any sense! Do you mean Multi-Time-frame MA or maybe MA Period Transposition?

  • If you are talking about ‌Multi-Time-frame MA, then search the CodeBase as there are several.
Samih Abdelli
67
Samih Abdelli  
Fernando Carreiro:

Please explain in more details, as you are not making any sense! Do you mean Multi-Time-frame MA or maybe MA Period Transposition?

  • If you are talking about ‌Multi-Time-frame MA, then search the CodeBase as there are several.


hi Fernando

w‌hen Im looking for is and Indicator that start calculating only from the beguining of the day till the end (from period separator to an other)

https://charts.mql5.com/14/290/eurusd-m15-weltrade.png

‌this of small time frame, I want the same if FourHours time frame

Fernando Carreiro
3389
Fernando Carreiro  
s4m111h: w‌hen Im looking for is and Indicator that start calculating only from the beguining of the day till the end (from period separator to an other)

https://charts.mql5.com/14/290/eurusd-m15-weltrade.png

‌this of small time frame, I want the same if FourHours time frame

Sorry, but that still does not make sense! Your image is not for an MA but some other indicator.

Plus a MA (in the case of a SMA), is inherently non-cumulative, so you can easily place it on your chart and it would be the same whether you separate the periods or not.

Do you have true screenshots of an actual example, maybe from a different trading system, so as to illustrate your point?‌

Samih Abdelli
67
Samih Abdelli  
Fernando Carreiro:

Sorry, but that still does not make sense! Your image is not for an MA but some other indicator.

Plus a MA (in the case of a SMA), is inherently non-cumulative, so you can easily place it on your chart and it would be the same whether you separate the periods or not.

Do you have true screenshots of an actual example, maybe from a different trading system, so as to illustrate your point?‌


sorry for that chart, check this one

https://charts.mql5.com/14/290/eurusd-m5-weltrade-2.png

I dont want the last period to be calculated in the new one, thats all
Fernando Carreiro
3389
Fernando Carreiro  
s4m111h: sorry for that chart, check this one

https://charts.mql5.com/14/290/eurusd-m5-weltrade-2.png

I dont want the last period to be calculated in the new one, thats all

What kind of MA is that? It is definitely NOT an SMA for it to be so different (between the blue and the black MAs). Even for an EMA the difference would not be so profound.

Plus, what did you use to make the MA to only start at that point in the ScreenShot?

Samih Abdelli
67
Samih Abdelli  
Fernando Carreiro:

What kind of MA is that? It is definitely NOT an SMA for it to be so different (between the blue and the black MAs). Even for an EMA the difference would not be so profound.

Plus, what did you use to make the MA to only start at that point in the ScreenShot?


thank you for the help, I found what I was looking for, take a look

extern int MA_LD=56;
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Green

int ExtCountedBars=0;

double Buf_0[];

//--------------------------------------------------------------------
int init()
  {
//--------------------------------------------------------------------
   SetIndexBuffer(0,Buf_0);
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);
//--------------------------------------------------------------------
   return(0);
  }
//--------------------------------------------------------------------
int start()
  {
   int ld;

   //ld=Bars(Symbol(),Period(),TimeCurrent(),TimeCurrent() - 60 * 60 * 24);
   ld=Bars(Symbol(),Period(),TimeCurrent(),TimeCurrent() - 60 * 60 * 48);
   //ld=Bars(Symbol(),Period(),TimeCurrent(),iTime(NULL,PERIOD_W1,0));
  
      
   double sum=0, vol=0;
   int i,pos=ld-ExtCountedBars-1;
   if(pos<MA_LD) pos=MA_LD;
   for(i=1;i<MA_LD;i++,pos--){
      vol+=Volume[pos];
      sum+=Close[pos]*Volume[pos];
   }
   while(pos>=0){
      vol+=Volume[pos];
      sum+=Close[pos]*Volume[pos];
      //Buf_0[pos]=sum/MA_LD;
      Buf_0[pos]=sum/vol;
      sum-=Close[pos+MA_LD-1]*Volume[pos+MA_LD-1];
      vol-=Volume[pos+MA_LD-1];
      pos--;
   }
   if(ExtCountedBars<1)
      for(i=1;i<MA_LD;i++) Buf_0[pos]=0;

//--------------------------------------------------------------------
   return(0);
  }
//--------------------------------------------------------------------

I created three indicators like this, in everyone I uncomment ld var, Im not looking for perection, I just want it to functionality

thank you again

whroeder1
16295
whroeder1  
The image posted is a daily volume profile. The code posted is a volume weighted simple moving average. Not even close to the same.
Samih Abdelli
67
Samih Abdelli  
whroeder1:
The image posted is a daily volume profile. The code posted is a volume weighted simple moving average. Not even close to the same.

Im attaching them both to the chart
To add comments, please log in or register