I have tried to write indicators by reference to EMA of different time frames using multiple sets of data in the same charts. But the results were not accurate in time synchronization.
I found these amazing ones. They plotted EMA 20 of time frame 15 and 60 minutes on 5-minute chart accurately and the time synchronization was precise.
I would like EMA 50 of time frame 5 and 15 minutes on 1-minute chart and
SMA 20 of time frame 5 and 15 minutes on 1-minute chart. How can I write it by modifying the indicators below? I think the number of current bar and Fracportion should be changed but I didn't understand the logic behind it.
Thank you.
{EMA20 of time frame 15 minutes on 5-minute chart}
Inputs: length(20);
If CurrentBar = 60 then Value1 = xaverage(C, 60);
If CurrentBar > 60 then begin
If Fracportion(time/15) = 0 then begin
value1 = value1[1] + (2 / ( Length + 1 )) * ( C - value1[1] );
Value2 = value1;
Plot1(value1, "15 min 20EMA");
end
else begin
Value2 = value1 + (2 / ( Length + 1 )) * ( C - value1[1] );
Plot1(value2, "15 min 20EMA");
end;end;
{EMA20 of time frame 60 minutes on 5-minute chart}
Inputs: length(20);
If CurrentBar = 240 then Value1 = xaverage(C, 240);
If CurrentBar > 240 then begin
If Fracportion((time - 30)/100) = 0 or time =1315 then begin
value1 = value1[1] + (2 / ( Length + 1 )) * ( C - value1[1] );
Value2 = value1;
Plot1(value1, "60 min 20EMA");
end
else begin
Value2 = value1 + (2 / ( Length + 1 )) * ( C - value1[1] );
Plot1(value2, "60 min 20EMA");
end;end;