Download MetaTrader 5

no expert.ex4 created

To add comments, please log in or register
nikoscher
105
nikoscher  

Hi there i just wanted to experiment with my "MACD-expert" a bit.

Thats my whole source code:

double MacdCurrent, MacdPrevious, SignalCurrent;
double SignalPrevious, MaCurrent, MaPrevious; 
int init()
{

}

int start()
{
Print("Account balance = ",AccountBalance());
Print("Account balance = ",AccountCurrency()); 
  
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1); 
   
Print("MACD CURRENT = ",MacdCurrent);
Print("MACD PREVIOUS = ",MacdPrevious);
Print("SIGNAL CURRENT = ",SignalCurrent);
Print("SIGNAL PREVIOUS = ",SignalPrevious);
Print("MA CURRENT = ",MaCurrent);
Print("MA PREVIOUS = ",MaPrevious);
}

int deinit()
{

}

But every time i compile it there are zero error´s, but when i try to insert this expert in my terminal for testing i get:

"Cannot open file'C:\Program Files\Metatrader 4 Admiral Markets AS\MQL4\Experts\expert.ex4'[2]" 

I use MAC OS and Metatrader 4.

Any suggestions?

I already tried to reinstall, copy and paste code in new file, compile etc...expert.ex4 is still not created!

Could anybody help me?

Greetings!
Umar Ismail
11903
Umar Ismail  
nikoscher:

Hi there i just wanted to experiment with my "MACD-expert" a bit.

Thats my whole source code:

please tipe
return(0);

double MacdCurrent, MacdPrevious, SignalCurrent;
double SignalPrevious, MaCurrent, MaPrevious; 
int init()
{
return(0);
}
int MATrendPeriod =12;
int start()
{
Print("Account balance = ",AccountBalance());
Print("Account balance = ",AccountCurrency()); 
  
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1); 
   
Print("MACD CURRENT = ",MacdCurrent);
Print("MACD PREVIOUS = ",MacdPrevious);
Print("SIGNAL CURRENT = ",SignalCurrent);
Print("SIGNAL PREVIOUS = ",SignalPrevious);
Print("MA CURRENT = ",MaCurrent);
Print("MA PREVIOUS = ",MaPrevious);
return(0);}

int deinit()
{
return(0);
}

Jack Thomas
1806
Jack Thomas  

This will compile and run just fine.

#property copyright "YOUR NAME"
#property link      "YOUR LINK"
#property version   "1.00"
#property strict

double MacdCurrent, MacdPrevious, SignalCurrent;
double SignalPrevious, MaCurrent, MaPrevious; 
int MATrendPeriod =12;

int OnInit(){
return(INIT_SUCCEEDED); 
}

void OnDeinit(const int reason){}

void OnTick(){
Print("Account balance = ",AccountBalance());
Print("Account currency = ",AccountCurrency()); 
 
MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1); 
   
Print("MACD CURRENT = ",MacdCurrent);
Print("MACD PREVIOUS = ",MacdPrevious);
Print("SIGNAL CURRENT = ",SignalCurrent);
Print("SIGNAL PREVIOUS = ",SignalPrevious);
Print("MA CURRENT = ",MaCurrent);
Print("MA PREVIOUS = ",MaPrevious);

}

Copy and paste that into your editor.

Compile it, and then drop it on a chart.

Then click on the experts tab in your terminal.

The data will display when your mt4 client gets a tick from the broker.


nikoscher
105
nikoscher  

Great thanks! Worked:)

If i have the oppurtunity to ask now, maybe i ask about something else,

I just need to draw an basic "up arrow" at the current chart, what i tried:

ObjectCreate("Obj_Arrow", OBJ_ARROW, 0, TimeCurrent(), Bid+0.02); //draw an up arrow

What happens:

A red quadrat appears in the middle of the chart.

Not an arrow. Not at the current chart.


Does anybody have an advice? (Mql4)

Greetings!

nikoscher
105
nikoscher  
does anybody know??
Jack Thomas
1806
Jack Thomas  
nikoscher:
does anybody know??

MQL4 documentation

https://docs.mql4.com


MQL4 Book

https://book.mql4.com


Example from mql4.com forum.

https://www.mql5.com/en/forum/103414

nikoscher
105
nikoscher  
Yea ok, but why Object(Arrow) is not displayed in backtest´s ??
Abdul Salam
2855
Abdul Salam  
did you try it on windows , , , , , , mac systems some times shows this error
To add comments, please log in or register