Re: Momentum with signal line

2
Lionheart wrote: Tue Sep 06, 2022 8:24 pm How can i code a momentum with signal line which in this example is SMA20 previous indicator's data and to use it in an ea?
I want both lines to be in a seperate window like in the attached image.

Thanks
oh noes......... did u gave up on the solar wind??
Official Forex-station GIF animator at your service 👨‍⚖️
See a GIF with Forex-station.com on it? I probably made it
The best divergence indicator in the world.
Real news exists: Infowars.com 👈


Re: Momentum with signal line

7
Lionheart wrote: Tue Sep 06, 2022 8:24 pm How can i code a momentum with signal line which in this example is SMA20 previous indicator's data and to use it in an ea?
I want both lines to be in a seperate window like in the attached image.

Thanks
Image
This would be one way to do it.
These users thanked the author mrtools for the post (total 2):
Chickenspicy, Lionheart

Re: Momentum with signal line

8
Hello , i am here again to share the code Momentum with previous MAs. I also add an extra piece of code to use a custom indicator.
You can add, multiply the custom indicator with what you believe is going to work better.

//+------------------------------------------------------------------+
//| 2MA_Momentum.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "Evaghoras Heorhiu"
#property link "Evagoras1981@gmail.com"

#property indicator_separate_window
//#property indicator_minimum 0
//#property indicator_maximum 100
//#property indicator_level1 20
//#property indicator_level2 80
#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 Aqua
#property indicator_color3 MediumOrchid
#property indicator_color4 Red

extern int Momentum_Timeframe=0;//0=current chart,1=m1,5=m5,15=m15,30=m30,60=h1,240=h4,etc...
extern int Momentum_Period = 7;
extern int Momentum_Applied_Price = 0;//0=close, 1=open, 2=high, 3=low, 4=(high+low)/2, 5=(high+low+close)/3, 6=(high+low+close+close)/4
extern int MA1_Period = 22;
extern int MA1_Method = 1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA
extern int MA2_Period = 42;
extern int MA2_Method = 1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA
extern int Custom_Indicator_Period = 0;

//------------------- UpandDown inputs

extern int period = 10; //36
extern bool Arrow = true;
extern int ArrowSize = 1;
extern int SIGNAL_BAR = 1;
extern color clArrowBuy = Blue;
extern color clArrowSell = Red;

//------------------- ! Up and Down END

double MA1_Array[],MA2_Array[],Momentum[],Custom_Indicator[];


void OnTick()
{

}

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators setting
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1);

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
IndicatorShortName("Momentum "+Momentum_Timeframe);

SetIndexBuffer(0,MA1_Array);
SetIndexLabel(0,"MA1-Momentum "+MA1_Period);

SetIndexBuffer(1,MA2_Array);
SetIndexLabel(1,"MA2-Momentum "+MA2_Period);

SetIndexBuffer(2,Momentum);
SetIndexLabel(2,"Momentum "+Momentum_Period);

SetIndexBuffer(3,Custom_Indicator);
SetIndexLabel(3,"Custom Indicator"+Custom_Indicator_Period);

SetLevelValue(1,100);
// SetLevelValue(2,-1);SET SECOND LEVEL

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




//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit = Bars - IndicatorCounted() - 1;

//---- indicator calculation

for(int i=limit; i>=0; i--)
{
// RSI= iMomentum(_Symbol,_Period,30,PRICE_CLOSE,i);
//RSI= iRSI(NULL,RSI_Timeframe,RSI_Period,RSI_Applied_Price,i);
Momentum = iMomentum(_Symbol,Momentum_Timeframe,Momentum_Period,Momentum_Applied_Price,i);

}

for(i=limit; i>=0; i--)
{
// MA1_Array = iMAOnArray(RSI,0,MA1_Period,0,MA1_Method,i); ORIGINAL CODE FOR MA1 on RSI
// MA2_Array = iMAOnArray(RSI,0,MA2_Period,0,MA2_Method,i); ORIGINAL CODE FOR MA2 on RSI

MA1_Array = iMAOnArray(Momentum,0,MA1_Period,0,MA1_Method,i);
MA2_Array = iMAOnArray(Momentum,0,MA2_Period,0,MA2_Method,i);
// Custom_Indicator = iCustom(_Symbol,_Period,"Name_Of_Custom_Indicator",MODE,i); MODE=a number

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


Who is online

Users browsing this forum: Amazon [Bot], ChatGPT [Bot] and 33 guests