To buy now, use OrderSend().
---
An EA can draw lines.
Take your indicator and copy it from /experts/indicators to /experts. Open the new copy in the editor and compile it.
See if that doesn't work.
Attach the new Expert to a chart.
To buy now, use OrderSend().
---
An EA can draw lines.
Take your indicator and copy it from /experts/indicators to /experts. Open the new copy in the editor and compile it.
See if that doesn't work.
Attach the new Expert to a chart.
OrderSend() doesn't work from a custom indicator, only an EA.
An EA, as far as I know, cannot plot data on a curve. It can only draw basic horizontal/vertical lines.
I have tried copying my indicator to an expert file - it compiled, but it didn't work. The initialisation screen at the beginning didn't even come up. I am assuming this is because of the various #property indicator lines that are not allowed in EAs.
Can anyone help? Thanks.
Ok, indicator buffers don't work in an expert.
Sorry to trouble you.
"I thought of calling iCustom() from my EA but Custom Indicators are state machines that continue to loop forever - so this doesn't make sense."
Yes it does.
Use iCustom(). That is what it is for.
"First I tried just converting the entire Custom Indicator into an EA, but this doesnt work because apparently you cannot plot data as lines in an EA, so I cannot plot my moving averages in an EA. "
No need to plot.
Use iCustom to call up a temporary instance of the EA, and collect values from one or more of its indexes. That is common usage.
Example, inside an EA:
Get the values of ema 5 and ema 10 at bar 0 and bar 1 using the included "Moving Averages" custom indicator.
There are three input parameters for the "Moving Averages" indicator, they go into the iCustom() call after the indicator name.
double ema5_bar0 = iCustom(Symbol(), 0, "Moving Averages", 5, 0, MODE_EMA, 0, 0);
double ema5_bar1 = iCustom(Symbol(), 0, "Moving Averages", 5, 0, MODE_EMA, 0, 1);
double ema10_bar0 = iCustom(Symbol(), 0, "Moving Averages", 10, 0, MODE_EMA, 0, 0);
double ema10_bar1 = iCustom(Symbol(), 0, "Moving Averages", 10, 0, MODE_EMA, 0, 1);
Thanks guys, you have been of great help :)
I understand it better now
You need 2 parts: indicator which computes values & give signals for opening positions and EA which takes data from indicator (signals) & realize orders on the market.
I am not advanced user with metatrader, just know the basics. For example I have written my own indicator and the file is in /experts/indicators folder. So what I need to do know is to copy this file to jsut /experts/ directory and run it from there? Because in indicator I cant use Order functions. Then I need to attach my indicator from EA to chart and thats it? Then Order funtions should work without any problems?
sorry for my english language
- 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
I'm new to MQL4 but have been programming C/C++ for years. I am trying to understand a concept regarding the difference between indicators and EAs.
I have written a Custom Indicator that draws a few moving averages and places arrows at appropriate buy and sell locations.
What I want to do now is create an Expert Advisor that buys and sells when the Custom Indicator tells it to, but I don't know how.
First I tried just converting the entire Custom Indicator into an EA, but this doesnt work because apparently you cannot plot data as lines in an EA, so I cannot plot my moving averages in an EA. So my conclusion is that I must have the line drawing logic in the Custom Indicator, and the buy logic in the EA.
I thought of calling iCustom() from my EA but Custom Indicators are state machines that continue to loop forever - so this doesn't make sense.
Am I missing something? My custom indicator algorithm basically looks like this:
When I place an arrow, I want to buy. How do I do this?
Thanks.