
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have an indicator that I am trying to write. I have the formula in both Tradestation format and MetaStock format. Can someone help me convert this to MetaTrader please? I have tried, but it only prints flat lines on the bottom of the screen.
Tradestation Format:
Create two functions in EasyLanguage first. The first is a 9-period momentum study of RSI. This can be written as
RSIDelta = MOMENTUM(RSI(CLOSE,14),9)
Then a smoothed short period RSI is created,
RSIsma = AVERAGE(RSI(CLOSE,3),3)
The indicator can then be created:
INDICATOR: MY INDICATOR
Plot1(RSIDelta+RSIsma,"Plot1");
Plot2(average((plot1),13),"Plot2");
Plot3(average((plot1),33),"Plot3");
MetaStock Format:
A = RSI(14)-Ref(RSI(14),-9)+Mov(RSI(3),3,S);
Plot1 = Mov(A,13,S);
Plot2 = Mov(A,33,S);
A;Plot1;Plot2;
Here's what I've gotten so far:
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 Lime
#property indicator_color3 Yellow
//---- buffers
double PlotBuffer1[];
double PlotBuffer2[];
double PlotBuffer3[];
int counted_bars;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE); // Plot1
SetIndexBuffer(0,PlotBuffer1);
SetIndexStyle(1,DRAW_LINE); // Plot2
SetIndexBuffer(1,PlotBuffer2);
SetIndexStyle(2,DRAW_LINE); // Plot3
SetIndexBuffer(2,PlotBuffer3);
SetIndexDrawBegin(0,0);
SetIndexDrawBegin(1,0);
SetIndexDrawBegin(2,0);
IndicatorShortName("MyIndicator");
counted_bars=IndicatorCounted();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double RSIDelta;
double RSIsma;
int pos = counted_bars;
//----
// Alert("position: " + pos);
// Alert("current bar close: " + Close[pos]);
// Alert("bars: " + Bars);
RSIDelta = iMomentum(NULL,0,9,iRSI(NULL,0,14,PRICE_CLOSE,0),0);
RSIsma = iMA(NULL,0,3,0,MODE_SMMA,iRSI(NULL,0,3,PRICE_CLOSE,0),0);
PlotBuffer1[counted_bars] = RSIDelta+RSIsma;
PlotBuffer2[counted_bars] = iMA(NULL,0,13,0,MODE_SMA,PlotBuffer1,0);
PlotBuffer3[counted_bars] = iMA(NULL,0,33,0,MODE_SMA,PlotBuffer1,0);
pos--;
//----
return(0);
}
//+------------------------------------------------------------------+
Any help will be greatly appreciated. Thanks.