Coding a custom indicator without the mq4 file?

 

Hey everyone, I'd like to ask a question that I don't think has been answered.

If I've got an ex4 of a custom indicator, but not the .mq4 file, how might I code it into an EA? For example, I've got the DRI, but I'd like to automate it. It's this thing.

trade-profit [[dot]] com/dri-1.jpg

Any tips? Appreciate your time.

-Alex

 
alexboyd:
Hey everyone, I'd like to ask a question that I don't think has been answered.

If I've got an ex4 of a custom indicator, but not the .mq4 file, how might I code it into an EA? For example, I've got the DRI, but I'd like to automate it. It's this thing.

trade-profit [[dot]] com/dri-1.jpg

Any tips? Appreciate your time.

-Alex

you dont need the mq4 file to read an indicator IF that indicator prestent the data correctly (a broard statement but- inotation indicator would be almost impossible to do)

 
Perky:
you dont need the mq4 file to read an indicator IF that indicator prestent the data correctly

Right, yeah, but this indicator just places red/blue arrows when it gives short/long signals, which seems tricky to code without knowing how it calculates those objects. Certainly, it's possible, just very difficult... or am I wrong?

 

Check The Data Window For Indicator Buffers

alexboyd:
Hey everyone, I'd like to ask a question that I don't think has been answered.

If I've got an ex4 of a custom indicator, but not the .mq4 file, how might I code it into an EA? For example, I've got the DRI, but I'd like to automate it.

Any tips? Appreciate your time. Alex

Hi Alex,

Check the Data Window to see the buffers for any indicator.

In the attached MACD example, Buffer 0 = MACD value and Buffer 1 = Signal value.

Use the buffers to place them in your iCustom statements.

Hope this helps,

Robert

Files:
 

robert,

thanks for the reply. however, those fields are blank in the data window! in the macd example, both the base line and signal line are defined values at any given point... however this indicator shows up blank in the data window. no values shown for it. here's what i see in the window:

EURUSD,M1

Date 2010.12.03

Time 16:54

Open 1.33700

High 1.33764

Low 1.33678

Close 1.33764

Volume 40

DynamicRangeIndicator

Value 2

those last two lines would normally show the buffers and their values, but this indicator doesn't plot any values on the chart, it just gives signals. any ideas?

 

DRI Values Are There - Scroll Mouse To Find Them

alexboyd:
robert,

thanks for the reply. however, those fields are blank in the data window! in the macd example, both the base line and signal line are defined values at any given point... however this indicator shows up blank in the data window. no values shown for it. here's what i see in the window:

EURUSD,M1

Date 2010.12.03

Time 16:54

Open 1.33700

High 1.33764

Low 1.33678

Close 1.33764

Volume 40

DynamicRangeIndicator

Value 2

those last two lines would normally show the buffers and their values, but this indicator doesn't plot any values on the chart, it just gives signals. any ideas?

Hi Alex,

The values are there...

One value or the other will appear, not both...and they only appear when the event happens...then they blank out until the next event.

Scroll your mouse around your chart and you will see the values come up.

These buffers should be available for your iCustom statements.

See the attached screen shots for the sample values.

Hope this helps,

Robert

 

Robert,

Thanks for your help, I probably should have scrolled to those points on the chart O_O

Unfortunately, I have little programming knowledge and have been using the Expert Advisor Builder tool to create EAs...

I ended up with this:

double Buy1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 1, Current + 0);

double Buy1_2 = 1;

double Buy2_1 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Buy2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Buy3_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 10);

double Sell1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 2, Current + 0);

double Sell1_2 = 1;

double Sell2_1 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Sell2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Sell3_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 10);

which isn't right, because all the EA does is load the indicator over and over... though my intention was for it to trade according to the dynamic range indicator, while ignoring all counter-trend signals.

i attached the .mq4 file. I'm certain that this is a noob question; if there's an easy answer/fix, then I hope you can point it out to me. Otherwise, I'll probably have to embark on a course in programming so I can start to know what I'm talking about.

My thanks to this forum for your continued help...

Files:
dri_trading.mq4  10 kb
 

Check the iCustom Inputs

alexboyd:
Robert,

Thanks for your help, I probably should have scrolled to those points on the chart O_O

Unfortunately, I have little programming knowledge and have been using the Expert Advisor Builder tool to create EAs...

I ended up with this:

double Buy1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 1, Current + 0);

double Buy1_2 = 1;

double Buy2_1 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Buy2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Buy3_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 10);

double Sell1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 2, Current + 0);

double Sell1_2 = 1;

double Sell2_1 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Sell2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Sell3_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 10);

which isn't right, because all the EA does is load the indicator over and over... though my intention was for it to trade according to the dynamic range indicator, while ignoring all counter-trend signals.

i attached the .mq4 file. I'm certain that this is a noob question; if there's an easy answer/fix, then I hope you can point it out to me. Otherwise, I'll probably have to embark on a course in programming so I can start to know what I'm talking about.

My thanks to this forum for your continued help...

Morning Alex,

Some quick observations -

I am curious if you are getting the correct DRI iCustom values?

It looks like you are using Buffers 1 and 2? That presumes a Buffer 0?

double Buy1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40,1, Current + 0);

double Sell1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40,2, Current + 0);

The DRI indicator I used only has Buffers 0 and 1 (as you saw in my screen examples).

One way to confirm is to display or print the DRI buffer values to your screen or logs.

Secondly, the DRI indi that I was using has multiple user inputs, including string descriptions and True/False alerts - they ALL have to be included in the DRI iCustom statements (or removed from the indicator).

Your example only shows 1 variable (40)...and no strings or T/F alerts...??

Whatever the User Inputs are for the indicator, including the strings and alerts, add them ALL in your iCustom statements.

As far as the indicator re-loading over and over, it depends where the code is placed.

Good luck...and keep trying and learning!

Hope this helps,

Robert

 

second draft...

okay, thanks for correcting me. i know these are obvious questions, but like i said, i'm blindly feeling my way through this code.

i removed the t/f lines that give alerts and the extraneous strings, and recompiled the indicator... the only variable now is

extern int Indicator.Period = 40;[/CODE]

and the iCustom section from my EA is as follows... all i did was correct the buffers:

[CODE]double Buy1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 0, Current + 0);

double Buy1_2 = 1;

double Buy2_1 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Buy2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Buy3_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 10);

double Sell1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 1, Current + 0);

double Sell1_2 = 1;

double Sell2_1 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Sell2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Sell3_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 10);

does this seem right? i think it's working now... but it's taking about an incredulous amount of time for the strategy tester to load the thing and make trades...

thanks for your help, i'm almost there!

 

DRI Buffers Look OK

alexboyd:
okay, thanks for correcting me. i know these are obvious questions, but like i said, i'm blindly feeling my way through this code.

i removed the t/f lines that give alerts and the extraneous strings, and recompiled the indicator... the only variable now is

extern int Indicator.Period = 40;[/CODE]

and the iCustom section from my EA is as follows... all i did was correct the buffers:

[CODE]double Buy1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 0, Current + 0);

double Buy1_2 = 1;

double Buy2_1 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Buy2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Buy3_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 10);

double Sell1_1 = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 1, Current + 0);

double Sell1_2 = 1;

double Sell2_1 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 0);

double Sell2_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 1);

double Sell3_2 = iMA(NULL, 0, 200, 0, MODE_EMA, PRICE_CLOSE, Current + 10);

does this seem right? i think it's working now... but it's taking about an incredulous amount of time for the strategy tester to load the thing and make trades...

thanks for your help, i'm almost there!

Hi Alex,

If you have removed the other inputs as you said, the code looks good and should work fine.

You still sound a little unsure (you said "it's working I think"). You can display the DRI values or print them to the log to be confident you are getting the right values.

As far as the strategy tester taking so long...not really sure...

Your EA is calling 2 indicators for a total of 8 times each cycle. This may be one of many possible causes for the slowness.

Some other members may have other suggestions...

Hopefully at least you are now getting the right DRI values and you can now work on refining your EA.

Hope this helps,

Robert

 

Dynamic Range EA

So, I took a break from working on this EA for quite a while -- I have some time, so I've decided to revisit it. For some reason, I can't manage to get it working properly!

Here are my variables:

double Zero = 0;

double DRIBuy = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 0, Current + 0);

double DRISell = iCustom(NULL, 0, "DynamicRangeIndicator", 40, 1, Current + 0);[/CODE]

The indicator prints a positive value in the first buffer when a buy signal is given, and the same in the second buffer for a sell signal. As such, here is my entry signal:

[CODE]if (DRIBuy > Zero) Order = SIGNAL_BUY;

if (DRISell > Zero) Order = SIGNAL_SELL;

Right now, the EA is just opening a buy order immediately, whether or not the indicator gives a signal. Anyone have any suggestions?

Again, I apologize for the clunky code I have/will be posting. I'm a beginner, trying to learn as I go. Thanks for the help!

Reason: