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

 

Hi RaptorUK,

I was able to use the function ObjectsTotal() and ObjectName() to count all objects and be able to pull up a name.

My indicator writes signals in the following way: "[VSA] Name of signal (Bar on which Signal occured)"  e.g. "[VSA] Effort (45)".

Now I'm at the 2nd part of the equation how do I verify last bar for signal.

I need to check basically was there a signal (yes/no), if yes, what was name?

I was able to figure out the color part by using OBJPROP_COLOR.

How do I do this part that you wrote: "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)"

I would basically need to see if a certain word appears on ObjectName(1)? As per my format, "[VSA] name of signal (1)", only the name of signal will change. "[VSA]" and "(1)" will stay the same because I will always be checking bar 1 (on close).

I was playing around with OBJPROP_TIME1 but I'm not sure if that is what I need to look at or if it's the Time[] parameter.

Could you kindly point me into the right direction?

I'm assuming to I would need to use some form of ObjectGet().

Thanks

 
Sageone:


How do I do this part that you wrote: "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)"

I would basically need to see if a certain word appears on ObjectName(1)? As per my format, "[VSA] name of signal (1)", only the name of signal will change. "[VSA]" and "(1)" will stay the same because I will always be checking bar 1 (on close).

I was playing around with OBJPROP_TIME1 but I'm not sure if that is what I need to look at or if it's the Time[] parameter.

Could you kindly point me into the right direction?

I'm assuming to I would need to use some form of ObjectGet().

You have all the correct ideas.  If the Object you are after is an Arrow it will just have one time coordinate,  so yes you ObjectGet()  OBJPROP_TIME1 and compare this value to the Time[] for the bar you are interested in,  if the datetimes match then the Object is at the Bar you are checking.
 
RaptorUK:
You have all the correct ideas.  If the Object you are after is an Arrow it will just have one time coordinate,  so yes you ObjectGet()  OBJPROP_TIME1 and compare this value to the Time[] for the bar you are interested in,  if the datetimes match then the Object is at the Bar you are checking.

My next question is this: if for a custom indicator you use: extern int x for instance, can i do that for an EA?

The reason why I'm asking is I thought of using this: ObjectGet(ObjectName(bar)), where bar is an external int that I can change manually to "scroll" through the bars.

If not, how would I do that, print and comment? I'm asking mainly for testing purposes.

Also, what do I put into Time[], is it Time[Bars-1] for last bar? Then I compare this to ObjectGet(ObjectName("name I want"), OBJPROP_TIME1?

Thanks 

 
Sageone:

1.  My next question is this: if for a custom indicator you use: extern int x for instance, can i do that for an EA?

The reason why I'm asking is I thought of using this: ObjectGet(ObjectName(bar)), where bar is an external int that I can change manually to "scroll" through the bars.

If not, how would I do that, print and comment? I'm asking mainly for testing purposes.

2.  Also, what do I put into Time[], is it Time[Bars-1] for last bar? Then I compare this to ObjectGet(ObjectName("name I want"), OBJPROP_TIME1?

1.  Yes,  you can use externally set variables just like you can with an Indicator or Script. 

2.  The currently forming bar is bar 0,  Time[] gives you the time that the bar started,  so Time[0] is the time that the currently forming bar started,  bar 1 is the bar to it's left,  then 2, 3, 4, etc  bear in mind that you may have Objects on your chart that do not belong to your Indicator,  so you use your loop to loop through all the Objects,  you only need to check the OBJPROP_TIME1 for the objects whose name match the naming convention that the Indicator uses . . .  then you can find the most recent Object drawn by the Indicator.  Once you have it's name it is easy to check it's OBJPROP_TIME1 and see if it lies at the same time as the bar you are interested in.  

 
RaptorUK:

1.  Yes,  you can use externally set variables just like you can with an Indicator or Script. 

2.  The currently forming bar is bar 0,  Time[] gives you the time that the bar started,  so Time[0] is the time that the currently forming bar started,  bar 1 is the bar to it's left,  then 2, 3, 4, etc  bear in mind that you may have Objects on your chart that do not belong to your Indicator,  so you use your loop to loop through all the Objects,  you only need to check the OBJPROP_TIME1 for the objects whose name match the naming convention that the Indicator uses . . .  then you can find the most recent Object drawn by the Indicator.  Once you have it's name it is easy to check it's OBJPROP_TIME1 and see if it lies at the same time as the bar you are interested in.  

For #2, if I use Time[1] that will give me the time when the bar1 started, but my indicator is painted on bar close. There would be a discrepancy in time there.

What I thought of doing was not bothering with time at all, my indicator "arrows", in the naming convention, print the bar # in ()  that means that the bar.

That means "[VSA] Effort (1)" can be nowhere else other than on bar1. I can write all the names of possible signals, "[VSA] Effort (1)", "[VSA] No Demand (1)", etc. There are 16 in total. 8 for long and 8 for short.

Then I can search all bars if any of those appear. That would mean that automatically there is a signal and it is on the last bar. Hence, Time[] and OBJPROP_TIME1 are not needed. 

For testing purposes, I can make an extern int bar (for example) and do something like this:

ObjectName("[VSA] Effort ("+bar+")")

I can do that for each of the 16 signals and verify the color with with OBJPROP_COLOR.

Then I will search using ObjectsTotal(), any thoughts on this? 

 
Sageone:

1.  For #2, if I use Time[1] that will give me the time when the bar1 started, but my indicator is painted on bar close. There would be a discrepancy in time there.

What I thought of doing was not bothering with time at all, my indicator "arrows", in the naming convention, print the bar # in ()  that means that the bar.

That means "[VSA] Effort (1)" can be nowhere else other than on bar1. I can write all the names of possible signals, "[VSA] Effort (1)", "[VSA] No Demand (1)", etc. There are 16 in total. 8 for long and 8 for short.

Then I can search all bars if any of those appear. That would mean that automatically there is a signal and it is on the last bar. Hence, Time[] and OBJPROP_TIME1 are not needed. 

For testing purposes, I can make an extern int bar (for example) and do something like this:

I can do that for each of the 16 signals and verify the color with with OBJPROP_COLOR.

Then I will search using ObjectsTotal(), any thoughts on this? 

 

1.  that is not possible.  Your Indicator cannot know when a Bar has closed only when a new bar has opened.  Show your code and I'll tell you when your Indicator draws the Objects.

The bars numbers are not persistent,  the current bar 0 will be bar 1 when it has completed and then bar 2 when the next bar is completed. Are you saying that the Objects only exist for the duration of a Bar ? or do they have their names changed when a new bar forms,  if  "[VSA] Effort (1)" is drawn on Bar 1 what happens when that bar becomes bar 2 ?

 
RaptorUK:

1.  that is not possible.  Your Indicator cannot know when a Bar has closed only when a new bar has opened.  Show your code and I'll tell you when your Indicator draws the Objects.

The bars numbers are not persistent,  the current bar 0 will be bar 1 when it has completed and then bar 2 when the next bar is completed. Are you saying that the Objects only exist for the duration of a Bar ? or do they have their names changed when a new bar forms,  if  "[VSA] Effort (1)" is drawn on Bar 1 what happens when that bar becomes bar 2 ?

Hi RaptorUK, when the bar1 becomes bar2, the "[VSA] Effort (1)" becomes "[VSA] Effort (2)" . So it will rename the object on new bar.

That way I think it can be done. In terms of when the bar is painted, when a new bar opens(e.g. bar0), the indicator is painted on bar1.

So yes u are right it is on the open of the next bar.

Thoughts? 

 
Sageone:


Thoughts? 

Without seeing the Indicator I would do what I originally suggested,  code it properly once,  don't cut corners and end up having to code it properly tomorrow or the day after or the day after that . . . 
 
RaptorUK:
Without seeing the Indicator I would do what I originally suggested,  code it properly once,  don't cut corners and end up having to code it properly tomorrow or the day after or the day after that . . . 
I'm at work now so don't have a copy ready. I will try both methods and see what happens. I will stay in touch.
 
Sageone:
I'm at work now so don't have a copy ready. I will try both methods and see what happens. I will stay in touch.
OK  :-)
Reason: