Custom indicator code to open my .ex4 customer indicator - page 2

 
adub206: I'm sorry. I have no idea what you mean by outputting it? 

In that case just show us the proper code because I suspect that there are many steps that you are just skipping.

 
Fernando Carreiro:

In that case just show us the proper code because I suspect that there are many steps that you are just skipping.

Do you mean the source code for the Buy/Sell signal indicator I'm trying to use? If so, I do not have the source code. 

Thank you for your reply!

 
adub206: Do you mean the source code for the Buy/Sell signal indicator I'm trying to use? If so, I do not have the source code.
No, not the indicator source code! The code you are currently writing to call the indicator via the iCustom() function! The code you have been discussing here on this thread.
 
Fernando Carreiro:
No, not the indicator source code! The code you are currently writing to call the indicator via the iCustom() function! The code you have been discussing here on this thread.

From the information I've gathered, all I would need is this code placed into my new *.mq4 file and then ran as a normal indicator:

double  iCustom(
   string       NULL,           // symbol
   int          PERIOD_CURRENT=0,        // timeframe
   string       "BuySell",             // path/name of the custom indicator compiled program
   ...                            // custom indicator input parameters (if necessary)
   int          1,             // line index
   int          0             // shift
   );

Here are the inputs that I want for the indicator:
.

That's as far as I've gotten, unfortunately.


Thank you so much for your help!

 
adub206:

I'm sorry. I have no idea what you mean by outputting it? 

I mean "How are you checking the result of the iCustom call?"

or What are you doing with the result?

To check that you are getting the correct valuse a simple Print() will telly you that.

 
adub206:

From the information I've gathered, all I would need is this code placed into my new *.mq4 file and then ran as a normal indicator:

Here are the inputs that I want for the indicator:

That's as far as I've gotten, unfortunately.


Thank you so much for your help!

What are you expecting to happen?

Does that code compile?

You don't put 3 dots in instead of parameters.

double value =  iCustom(NULL,PERIOD_CURRENT,"BuySell",1,0);
 
Keith Watford:

I mean "How are you checking the result of the iCustom call?"

or What are you doing with the result?

To check that you are getting the correct valuse a simple Print() will telly you that.

Ohhhhhh, I see now. I am just dragging the made custom indicator onto a chart to see if the buy/sell signal pops up like it would with the .ex4 file. 

I will put the Print() in and see what happens.


Thank you!

 

adub206: From the information I've gathered, all I would need is this code placed into my new *.mq4 file and then ran as a normal indicator:

Here are the inputs that I want for the indicator:

That's as far as I've gotten, unfortunately.

NO! That is NOT ALL you will need! That is only a definition of a line of code that you can use in an EA which can easily consist of several tens if not hundreds of lines of code, so it will be easier for us to help you if you show ALL those lines of code and not just the iCustom() definition. There has to be at least a OnTick() handler and there has be some verification of the conditions based on the iCustom() values you collect and some lines to handle the placement of the orders, and many other things that you have not mentioned.

If all you have is a single line calling iCustom() then I am afraid you are very far from being able to code an EA with your Indicator. You will have to learn more about EA's by having a look at the many examples available in the CodeBase and by consulting the documentation about all of the functionality that is required.

 
Fernando Carreiro:

NO! That is NOT ALL you will need! That is only a definition of a line of code that you can use in an EA which can easily consist of several tens if not hundreds of lines of code, so it will be easier for us to help you if you show ALL those lines of code and not just the iCustom() definition. There has to be at least a OnTick() handler and there has be some verification of the conditions based on the iCustom() values you collect and some lines to handle the placement of the orders, and many other things that you have not mentioned.

If all you have is a single line calling iCustom() then I am afraid are very far from being able to code an EA with your Indicator. You will have to learn more about EA's by having a look at the many examples available in the CodeBase and by consulting the documentation about all of the functionality that is required.

I'm sorry, all I'm wanting right now is for the iCustom indicator to properly open my .ex4 file under a .m4 source file. After I've completed that step, I will then move onto producing my EA with that. 

At this time, I'm halted by having only the .ex4 file to work with, and since an EA cannot use the .ex4 file, I'm having to use the iCustom indicator as a mediator. 

The straight to the point end goal is... have my buysell signal indicator (that is currently in .ex4) to open with the iCustom indicator in .mq4

 

adub206: I'm sorry, all I'm wanting right now is for the iCustom indicator to properly open my .ex4 file under a .m4 source file. After I've completed that step, I will then move onto producing my EA with that.

At this time, I'm halted by having only the .ex4 file to work with, and since an EA cannot use the .ex4 file, I'm having to use the iCustom indicator as a mediator. 

The straight to the point end goal is... have my buysell signal indicator (that is currently in .ex4) to open with the iCustom indicator in .mq4

Unfortunately, that is not how things work.

You cannot just create an Expert Advisor (.mq4) file consisting of only the iCustom() function call. You have to create the bare minimum of an EA skeleton with the OnTick() event handler and maybe also a new bar detection and also output a few debug lines of text on the values returned by the iCustom() function call (see example below).

How else do you expect to verify that you are using the iCustom() correctly?

Irrespective of whether an indicator is a "ex4" file or a "mq4" files, you will always need to use the iCustom() in an EA in order to retrieve data from it. Also, you don't even need to place the indicator on the Chart in order for iCustom() to work.

Example:

// Attention: Untested and uncompiled code to serve only as an example

void OnTick()
{
   // Check for New Bar (Compatible with both MQL4 and MQL5)
   static datetime dtBarCurrent = WRONG_VALUE;
   datetime dtBarPrevious = dtBarCurrent;
   dtBarCurrent = (datetime) SeriesInfoInteger( _Symbol, _Period, SERIES_LASTBAR_DATE );
   boolNewBarFlag = ( dtBarCurrent != dtBarPrevious );

   if( boolNewBarFlag )
   {
      double
         dblValIdx0 =  iCustom( NULL, PERIOD_CURRENT, "BuySell", 0, 1 ),
         dblValIdx1 =  iCustom( NULL, PERIOD_CURRENT, "BuySell", 1, 1 );

      Print( "Value of Index 0 of Previous Bar: ", dblValIdx0 );
      Print( "Value of Index 1 of Previous Bar: ", dblValIdx1 );
   }
}