Help with creating a very simple EA

 

Hi everyone,


I am very bad at programming, probably so bad, it's easier for me to learn a Khoisan language - that's one of those weird African languages that use clicks. Anyways, back to the subject at hand.

I have this indicator, which colours the ticks on a chart in two colours, red and green. What I would like to automate now, after having had to manually execute trades is the following.

I start up the EA and from this point forward it enters/buys - for starters let's say 0.1 lots - as soon as a green bar appears for the first time. Then it holds that trade until the moment a red bar appears, then exits/sells the lot immediately. After that we're back to square 1: wait 'til a green bar appears etc. etc.

It's quite linear, but I want to KISS! ... Little bun there :):)

I hope this is enough information and that this topic hasn't been addressed before and escaped my tedious search for the past half hour on this forum.


Thanx a million for any replies

Cheers, zambalek80

 

What's your question? To get information from a custom indicator (yours sounds oddly like P&F) use the iCustom function. Google "MQL4 iCustom" to find the doc for it. You want to look at your custom indicator source code, too, since the iCustom function needs an index.

If your indicator doesn't put lines on the chart and instead puts objects (like Xs and arrows and whatnot), use something like below to find objects (untested). Then you can check the properties of the object in question.

int t = ObjectsTotal();
for (int i = 0; i < t; i++) {
    if (ObjectType(ObjectName(i))==OBJ_ARROW) {
        Alert("Hullo arrow man");
        //Do stuff since it's an arrow!
    }
}

Obviously that has no use whatsoever; it's just to show you how to use stuff like ObjectsTotal, ObjectType, and ObjectName. Good luck!

Reason: