Need Help converting script into Indicator

 

Hello every one, Happy new year to you all,

I find many scripts in the internet like the sample below written in mql and it is somehow converted to be .mq4 indicator file. Please, I need your help to know how to convert these scripts into .mq4 file.

I appreciate you help and guidance.

Thank you..

//+------------------------------------------------------------------+

//| MACD MA Price.mq4 |

//| Paladin80 |

//+------------------------------------------------------------------+

#property copyright "Paladin80"

#property link "forevex@mail.ru"

//---- indicator settings

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Silver

#property indicator_color2 Red

#property indicator_width1 2

//---- indicator parameters

extern int Fast_period=12;

extern int Slow_period=26;

extern int Signal_period=9;

//----

extern int MACD_MA_method=1;

extern int Signal_MA_method=0;

extern int Applied_price=0;

bool error=false;

/* MACD_MA_method and Signal_MA_method:

 

rimallz

Both scripts and indicators are a .mq4 files

It only depends on scripts if it can be coneverted to indicator or not. For example, orders management can not be done from indicatros at all and if a script does it, you can not convert it to an indicator.

rimallz:
Hello every one, Happy new year to you all,

I find many scripts in the internet like the sample below written in mql and it is somehow converted to be .mq4 indicator file. Please, I need your help to know how to convert these scripts into .mq4 file.

I appreciate you help and guidance.

Thank you..

//+------------------------------------------------------------------+

//| MACD MA Price.mq4 |

//| Paladin80 |

//+------------------------------------------------------------------+

#property copyright "Paladin80"

#property link "forevex@mail.ru"

//---- indicator settings

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Silver

#property indicator_color2 Red

#property indicator_width1 2

//---- indicator parameters

extern int Fast_period=12;

extern int Slow_period=26;

extern int Signal_period=9;

//----

extern int MACD_MA_method=1;

extern int Signal_MA_method=0;

extern int Applied_price=0;

bool error=false;

/* MACD_MA_method and Signal_MA_method:
 

Mladen, thank you fro your reply...

It seems to me such scripts are posted website, are compiled to be used as an indicator with mt4. But my question, what kind of software used to convert them into xxx.mq4 file?

Can you please explain the procedures to me?

thanks,

 

Sorry, but I do not understand exactly your question

mq4 file is a source file. That is written in metaeditor (press F4, press the metaeditor button or go to tools->Metaquotes language editor and you will see it).

rimallz:
Mladen, thank you fro your reply...

It seems to me such scripts are posted website, are compiled to be used as an indicator with mt4. But my question, what kind of software used to convert them into xxx.mq4 file?

Can you please explain the procedures to me?

thanks,
 

I am sorry I could not make myself clear enough.

For example, when I come across an indicator source code such as the one at this link EMA CROSSOVER SIGNAL.mq4 - MQL4 Code Base

how can I convert it from script form to .mq4 file so I can import it in the mt4 platform?

Thank you very much

 

Still not sure if this is what you are asking for, but this is a mq4 form file (already an indicator)

Just save it in indicators folder

rimallz:
I am sorry I could not make myself clear enough.

For example, when I come across an indicator source code such as the one at this link EMA CROSSOVER SIGNAL.mq4 - MQL4 Code Base

how can I convert it from script form to .mq4 file so I can import it in the mt4 platform?

Thank you very much
Files:
 

mladen, Thank you very much indeed.

 

Hi mladen,

First, thanks for all the great indicators you've posted. It's much appreciated every time I come across a new one.

I, too, need similar help. It's obviously a simple step I'm missing. I have a script. I saved it in a *.txt file. I then renamed it to *.mq4 and placed it into the indicator folder but it didn't work. What am I missing?

Here is the script:

//

// @author LazyBear

// List of all my indicators:

//

study(shorttitle = "SQZMOM_LB", title="Squeeze Momentum Indicator [LazyBear]", overlay=false)

length = input(20, title="BB Length")

mult = input(2.0,title="BB MultFactor")

lengthKC=input(20, title="KC Length")

multKC = input(1.5, title="KC MultFactor")

useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)

// Calculate BB

source = close

basis = sma(source, length)

dev = multKC * stdev(source, length)

upperBB = basis + dev

lowerBB = basis - dev

// Calculate KC

ma = sma(source, lengthKC)

range = useTrueRange ? tr : (high - low)

rangema = sma(range, lengthKC)

upperKC = ma + rangema * multKC

lowerKC = ma - rangema * multKC

sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)

sqzOff = (lowerBB upperKC)

noSqz = (sqzOn == false) and (sqzOff == false)

val = linreg(source - avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)),

lengthKC,0)

bcolor = iff( val > 0,

iff( val > nz(val[1]), lime, green),

iff( val < nz(val[1]), red, maroon))

scolor = noSqz ? blue : sqzOn ? black : gray

plot(val, color=bcolor, style=histogram, linewidth=4)

plot(0, color=scolor, style=cross, linewidth=2)

 
abba:
Hi mladen,

First, thanks for all the great indicators you've posted. It's much appreciated every time I come across a new one.

I, too, need similar help. It's obviously a simple step I'm missing. I have a script. I saved it in a *.txt file. I then renamed it to *.mq4 and placed it into the indicator folder but it didn't work. What am I missing?

Here is the script:

//

// @author LazyBear

// List of all my indicators:

//

study(shorttitle = "SQZMOM_LB", title="Squeeze Momentum Indicator [LazyBear]", overlay=false)

length = input(20, title="BB Length")

mult = input(2.0,title="BB MultFactor")

lengthKC=input(20, title="KC Length")

multKC = input(1.5, title="KC MultFactor")

useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)

// Calculate BB

source = close

basis = sma(source, length)

dev = multKC * stdev(source, length)

upperBB = basis + dev

lowerBB = basis - dev

// Calculate KC

ma = sma(source, lengthKC)

range = useTrueRange ? tr : (high - low)

rangema = sma(range, lengthKC)

upperKC = ma + rangema * multKC

lowerKC = ma - rangema * multKC

sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)

sqzOff = (lowerBB upperKC)

noSqz = (sqzOn == false) and (sqzOff == false)

val = linreg(source - avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)),

lengthKC,0)

bcolor = iff( val > 0,

iff( val > nz(val[1]), lime, green),

iff( val < nz(val[1]), red, maroon))

scolor = noSqz ? blue : sqzOn ? black : gray

plot(val, color=bcolor, style=histogram, linewidth=4)

plot(0, color=scolor, style=cross, linewidth=2)

As far as I see that is what is known as Bollinger bands squeeze indicator

Check this thread (multiple metatrader versions already there =) : https://www.mql5.com/en/forum/175337

 

Can you direct me to a web page which will guide me in changing this this .txt file, or others like it, to a proper working .mq4 file?

 
abba:
Can you direct me to a web page which will guide me in changing this this .txt file, or others like it, to a proper working .mq4 file?

abba

There is no such thing

You have to "read" one coding language and the "tell" the same thing using another coding language. But you can simply use the BB squeeze for metatrader since that code is BB squeeze

Reason: