You can use an Expert Advisor code to open buy and sell operations. Afaik indicators are for analysing trends and not placing orders
On MetaEditor (MT4) open File, New, Expert Advisor template
Copy the necessary code from your indicator to the EA template
Among other changes Your OnCalculate(...) function will be replaced by OnTick()
To initiate orders e.g. BUY you can read a bit here: https://docs.mql4.com/trading/ordersend
For example
int ticket=OrderSend(Symbol(),OP_BUY,1,price,3,stoploss,takeprofit,"My order",16384,0,clrGreen);
If you want to read the indicator values, set up the EA then in your EA code inside OnTick() function place the following
int lineindex=0;
Int bar = 0;
double var = iCustom("CMA",lineindex,bar);
This will read the latest value of line 0.
There are 5 graph lines in your CMA indicator so from 0 to 4 you can read.
Your CMA indicator has this code below so there are 5 graph lines:
SetIndexBuffer(0,ma,INDICATOR_DATA);
SetIndexBuffer(1,cma,INDICATOR_DATA);
SetIndexBuffer(2,up,INDICATOR_DATA);
SetIndexBuffer(3,dn,INDICATOR_DATA);
SetIndexBuffer(4,trend,INDICATOR_CALCULATIONS);
But your CMA indicator specified 4 buffers instead of 5 buffers. You can fix that
#property indicator_buffers 4
Just remove 4 and type 5
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi everyone
i have an indiator i want to get signal from it
please help me how can i get buy and sell signal from it thank you