Moving Average for the only last two days if it is in for hours TF

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

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.
If you are talking about Period transposition than just adjust the period of the MA accordingly
(‌see the following post for some explanation on transposition:


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)

‌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?‌

sorry for that chart, check this one

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?

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()
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);
int start()
   int ld;

   //ld=Bars(Symbol(),Period(),TimeCurrent(),TimeCurrent() - 60 * 60 * 24);
   ld=Bars(Symbol(),Period(),TimeCurrent(),TimeCurrent() - 60 * 60 * 48); 
   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++) Buf_0[pos]=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

The image posted is a daily volume profile. The code posted is a volume weighted simple moving average. Not even close to the same.