no expert.ex4 created
Hi there i just wanted to experiment with my "MACD-expert" a bit.
Thats my whole source code:
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); }
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.
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!
does anybody know??
MQL4 documentation
MQL4 Book
Example from mql4.com forum.

Hi there i just wanted to experiment with my "MACD-expert" a bit.
Thats my whole source code: