Page 1 of 2

Momentum with signal line

Posted: Tue Sep 06, 2022 8:24 pm
by Lionheart
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

Re: Momentum with signal line

Posted: Tue Sep 06, 2022 9:17 pm
by moey_dw
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??

Re: Momentum with signal line

Posted: Tue Sep 06, 2022 10:52 pm
by Lionheart
To start with solar indi i must first to know how i can create a signal

Re: Momentum with signal line

Posted: Tue Sep 06, 2022 10:58 pm
by wojtek
Try to use the iMAOnArray() function.

Re: Momentum with signal line

Posted: Wed Sep 07, 2022 1:56 am
by Lionheart
I find a mq4 file , RSI on MA and it works. I observed that Up and Down indicator (period 36) is very very similar with xb4d(period 27) indicator (SEFC084 other name)
and propably is the xb4d indicator.
I forget to say in reverse.

Re: Momentum with signal line

Posted: Wed Sep 07, 2022 3:31 am
by wojtek
The names of indicators are meaningless.
One and the same indicator can circulate with thousand different names.
... and all indicators you mentioned are Solar Wind or Running Fisher
(or close variations with some minor corrections).

Re: Momentum with signal line

Posted: Wed Sep 07, 2022 7:09 am
by mrtools
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.

Re: Momentum with signal line

Posted: Wed Sep 07, 2022 8:13 pm
by Lionheart
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);
}
//+------------------------------------------

Re: Momentum with signal line

Posted: Wed Sep 07, 2022 8:15 pm
by Lionheart
Thanks for the idea on the image MrTools

Re: Momentum with signal line

Posted: Sun Sep 11, 2022 5:34 pm
by josi
moey_dw wrote: Tue Sep 06, 2022 9:17 pm oh noes......... did u gave up on the solar wind??
by Tankk