Hello everyone,
I'm trying to test the FastTMALines on off-line charts (15-30 seconds) and hopefully test an idea with an EA. I'm just learning how to code but does anybody know how to change the indicator to plot the lines multi-time-frame mode on off-line charts? I'm able to use the indicator on time-frame "0" or "current" on aforementioned off-line charts but other time-frames either don't plot correctly or don't draw at all. For example, say I want to plot 1minute TMA on a 30 second off-line chart, it doesn't work. I know mql4 has some issues with off-line charts and it's not something they support that much as the transition to mql5 continues on. Metratrader 5 does not support it at all. I realize the indicator was not designed for it and needs to be adjusted, so I'm wondering how to go about this. Can you help me? Indicator and tick charts are included.
Can you help me adapt an indicator
-
saunga2nd3
- Posts: 2
- Joined: Tue Feb 07, 2012 11:15 pm
Can you help me adapt an indicator
You do not have the required permissions to view the files attached to this post.
-
saunga2nd3
- Posts: 2
- Joined: Tue Feb 07, 2012 11:15 pm
Can you help me adapt an indicator
When I said I was testing Tma on offline-charts was not to use the indicator as a trading signal alone.
I adapted another indicator to do what the previous post requests but I'm having trouble with staircase effect on the line. I'm using imaonarray() function to average the average and it works but it's just too slow calculating on smaller time-frames.
Can anybody help me to figure out what's wrong with this code and how to make it faster?
I adapted another indicator to do what the previous post requests but I'm having trouble with staircase effect on the line. I'm using imaonarray() function to average the average and it works but it's just too slow calculating on smaller time-frames.
Can anybody help me to figure out what's wrong with this code and how to make it faster?
Code: Select all
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 PaleVioletRed
#property indicator_width1 2
//**************************************************************************/
extern int TimeFrame = 0;//0=current
extern int TMAPeriod = 20;
extern int Price = PRICE_CLOSE;
extern double ATRMultiplier = 2.0;
extern int ATRPeriod = 100;
extern int HalfLength = 12;
double buffer1[];
double RawBuffer[];
double SmoothBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
SetIndexBuffer(0,buffer1); //SetIndexDrawBegin(0,HalfLength);
//----
return(0);
}
//+------------------------------------------------------------------+
//| MTF Moving Average |
//+------------------------------------------------------------------+
int start()
{
Comment("Bid: ",Bid);
Draw();
return(0);
}
//+------------------------------------------------------------------+
void Draw()
{
//-------------------
int limit, i, UpperTfShift;
limit=Bars;
ArrayResize(RawBuffer, limit + 100);
ArrayResize(SmoothBuffer, limit + 100);
ArraySetAsSeries(RawBuffer,true);
ArraySetAsSeries(SmoothBuffer,true);
//
ArrayInitialize(RawBuffer, 0);
ArrayInitialize(SmoothBuffer, 0);
i= limit;
while(i >= 0)
{
UpperTfShift = iBarShift( Symbol(), TimeFrame, Time[i]);
buffer1[i]=calcTmaMtf(TimeFrame,TMAPeriod,UpperTfShift,Close[i]);
//if(ShowRawData) ExtMapBuffer3[i]= RawBuffer[i];
i--;
}
i= limit;
while(i >= 0)
{
SmoothBuffer[i] = iMAOnArray(buffer1,0,(TimeFrame/Period() ),0,0,i);
if(SmoothBuffer[i] > SmoothBuffer[i+1] ) buffer1[i]=SmoothBuffer[i];
if(SmoothBuffer[i] < SmoothBuffer[i+1] ) buffer1[i]=SmoothBuffer[i];
i--;
}
//-------------------
return(0);
}
double calcTmaMtf(int Time_frame, int TMA_period, int Tf_Shift, double Candle_close)
{
int j, k;
double sum = ( TMA_period +1)* Candle_close;
double sumw = ( TMA_period +1);
//int UpperTfShift = iBarShift( Symbol(), TimeFrame, Time[i]);
//Print(UpperTfShift);
for(j=1, k= TMA_period; j<= TMA_period; j++, k--)
{
sum += k*iClose(Symbol(), Time_frame , Tf_Shift +j);
sumw += k;
//this next code is in question
if (j<= Tf_Shift )
{
sum += k*iClose(Symbol(), Time_frame , Tf_Shift -j);
sumw += k;
}
}
return(sum/sumw);
}