Need help with iCustom, trying to create an EA that will run from this code

 

Hi guys,

This is a code I found and slightly modified as a VSA indicator.

The code is supposed to draw a windings symbol above or below a bar (on close).

I use this on an hourly time frame (only). The indicator works well and does what it's supposed to. After trading it manually, I want to make it into an EA,

I tried writing an iCustom function but it always gives me an EMPTY_VALUE number.

Can someone show me how to make a working iCustom function?

The indicator deals with objects and not buffers.

Any help will be greatly appreciated

 
Sageone:


I tried writing an iCustom function but it always gives me an EMPTY_VALUE number.

Can someone show me how to make a working iCustom function?


*please note the file that is attached has a slightly modified name as it was changed during the upload. Original name is: VSA Signals v1.060


The indicator draws objects on your chart

there is no line like

#property indicator_buffers xx    //xx number of buffers

 inside your indicator telling there are buffers to read.  In this case you can't find values with iCustom

you have to search for the last placed object  

The code is supposed to draw a windings symbol above or below a bar (on close). "  Check your Objects on your chart and look to the names it get

 
deVries:

The indicator draws objects on your chart

there is no line like

 inside your indicator telling there are buffers to read.  In this case you can't find values with iCustom

you have to search for the last placed object  

The code is supposed to draw a windings symbol above or below a bar (on close). "  Check your Objects on your chart and look to the names it get


Hi deVries,

You are right about that and I was considering it. Each object drawn starts like so: "[VSA]" and then there is the name of the signal e.g. "Effort", followed by the bar on which it appears in parentheses e.g. "(2)". Full example: "[VSA] Effort (2)".

How would I be able to write a function that will search for most recent "object"? Any help would be appreciated.

Also, some objects are colored black and others blue and red. I need to only search for red or blue objects not black ones (false signals, if you wish to know what they are). Is it possible to not only search for most recent object but also search for objects by color code (I guess this would be a nested if statement).

Thanks again for your timely reply.

 
Sageone:

Hi deVries,

You are right about that and I was considering it. Each object drawn starts like so: "[VSA]" and then there is the name of the signal e.g. "Effort", followed by the bar on which it appears in parentheses e.g. "(2)". Full example: "[VSA] Effort (2)".

How would I be able to write a function that will search for most recent "object"? Any help would be appreciated.

Also, some objects are colored black and others blue and red. I need to only search for red or blue objects not black ones (false signals, if you wish to know what they are). Is it possible to not only search for most recent object but also search for objects by color code (I guess this would be a nested if statement).

Thanks again for your timely reply.

Loop through the list of Objects using a loop from ObjectsTotaal() - 1 to 0 and select them and their name using ObjectName(int index)  look for Objects that match the name you are interested in, and check each, one by one, for it's position on the chart,  finding the one with the most recent OBJPROP_TIME1  should yield the most recent.
 
RaptorUK:
Loop through the list of Objects using a loop from ObjectsTotaal() - 1 to 0 and select them and their name using ObjectName(int index)  look for Objects that match the name you are interested in, and check each, one by one, for it's position on the chart,  finding the one with the most recent OBJPROP_TIME1  should yield the most recent.

Hi RaptorUK,

Thank you for your input.

Just a small clarification, the loop should be done in my EA correct?

Secondly, I do not wish to look for a particular object, I just want to find the most recent object. I want the last bar (on close) to be verified if there are any objects on it. Preferably then, I need it to return (in comment or print - I can do this part), the name of the object. It would be nice if I could scroll throught the bars one by one (for testing purposes). E.g. in the last 3 bars there were 2 objects (bar 1 and 3), for the purpose of the EA, I just need to verify the name of the object on the last bar. Also, the color is very important to me. Can I check object color?

 So my questions in simple terms:

1) How do I check last bar for Object (any object)?

2) How do I check Object color (presuming that last bar has an object)?

Thanks, you guys are awesome. 

 
Sageone:

Hi RaptorUK,

Thank you for your input.

1.  Just a small clarification, the loop should be done in my EA correct?

2.  Secondly, I do not wish to look for a particular object, I just want to find the most recent object. I want the last bar (on close) to be verified if there are any objects on it. Preferably then, I need it to return (in comment or print - I can do this part), the name of the object. It would be nice if I could scroll throught the bars one by one (for testing purposes). E.g. in the last 3 bars there were 2 objects (bar 1 and 3), for the purpose of the EA, I just need to verify the name of the object on the last bar. Also, the color is very important to me. Can I check object color?

 So my questions in simple terms:

1) How do I check last bar for Object (any object)?

2) How do I check Object color (presuming that last bar has an object)?

Thanks, you guys are awesome. 

1.  Yes coded in your EA.

2.  yes you do, you aren't looking for lines or Fibs or  boxes,  you are probably looking for an Arrow Object.

1) you don't,  you check the time value of the Objects of the type and name you are interested in and establish if one of them is on the same time as Bar 1 (last closed bar)

2)   ObjectGet() using OBJPROP_COLOR but you need the Object name first . . . see 2. 

 
RaptorUK:

1.  Yes coded in your EA.

2.  yes you do, you aren't looking for lines or Fibs or  boxes,  you are probably looking for an Arrow Object.

1) you don't,  you check the time value of the Objects of the type and name you are interested in and establish if one of them is on the same time as Bar 1 (last closed bar)

2)   ObjectGet() using OBJPROP_COLOR but you need the Object name first . . . see 2. 

 

Hi RaptorUK,

Thanks again for the prompt reply. You, my man, are a wealth of knowledge. I'm glad I asked this question.

int    obj_total=ObjectsTotal();
  string name;
  for(int i=0;i<obj_total;i++)
    {
     name=ObjectName(i);
     Print(i,"Object name for object #",i," is " + name);
    }

I looked over this code. I will tweak it to my needs. I understand now fully what must be done. I will jump on this once I get home. I'm at work now.

Thanks for helping me, I will update this thread if I can do what I was aiming to. 

 
Sageone:


Thanks for helping me, I will update this thread if I can do what I was aiming to. 

You are welcome,  you can do it, it just needs a little peace and quiet and a little clear thinking.  If you get stuck, just shout. :-)
 
Sageone:
I tried writing an iCustom function but it always gives me an EMPTY_VALUE number.
Can someone show me how to make a working iCustom function?
  1. Detailed explanation of iCustom - MQL4 forum
  2. This
    iCustom(NULL, 0, "VSA Signals v1.060",30,30 ...
    Doesn't Match
     VSAfSignalsgv1.060.mq4



 

1.  it sounds like the Indicator uses Objects not Indicator buffers so iCustom is no help.

2.  if a file is uploaded with blanks in the filename  the blanks are filled in . . .  VSA Signals v1.060.mq4  --->    VSAfSignalsgv1.060.mq4