OnParamsChange is called many times

How to create strategies and indicators
Message
Author
Robopip
Posts: 26
Joined: Thu Jun 21, 2012 12:03 am

OnParamsChange is called many times

#1 Postby Robopip » Mon Oct 08, 2012 2:57 pm

Hi,

I do not understand why OnParamsChange is called at least two times at startup for each indicator.
I can either create objects during the calls, neither can I find textobjects I have created earlier.

Is there any text I can read about the OnParamsChange behaviour?

The attached code, gives the following log print:
...
.2012.10.08 21:35:42 Indicator CCI.dll loaded
.2012.10.08 21:35:42 no timecurrent
.2012.10.08 21:35:42 Timeframe: 1

.2012.10.08 21:35:42 Indicator DemoIndicator.dll loaded
...
.2012.10.08 21:35:43 Indicator zigzag.dll loaded
.2012.10.08 21:35:43 timecurrent 40574.999306
.2012.10.08 21:35:43 Timeframe: 5
.2012.10.08 21:35:43 1.USDJPY OnParamsChange: object markettype not found. (ObjectsTotal: 0)
.2012.10.08 21:35:43 1.USDJPY OnParamsChange: object not created. (ObjectsTotal: 0)
.2012.10.08 21:35:43 timecurrent 41182.999306
.2012.10.08 21:35:43 Timeframe: 15
.2012.10.08 21:35:43 1.EURUSD OnParamsChange: object markettype not found. (ObjectsTotal: 0)
.2012.10.08 21:35:43 1.EURUSD OnParamsChange: object not created. (ObjectsTotal: 0)
.2012.10.08 21:35:43 timecurrent 41182.999306
.2012.10.08 21:35:43 Timeframe: 1440
.2012.10.08 21:35:43 1.EURUSD OnParamsChange: object markettype not found. (ObjectsTotal: 0)
.2012.10.08 21:35:43 1.EURUSD OnParamsChange: object not created. (ObjectsTotal: 0)


All help is appreciated.
Attachments
forextester.zip
(898 Bytes) Downloaded 934 times
Last edited by Robopip on Wed Oct 10, 2012 3:08 pm, edited 1 time in total.

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#2 Postby FT Support » Tue Oct 09, 2012 11:50 am

Hello,

This function is called several times because you placed the indicator on several timeframes so the program will actually create several separate instances of this indicator (the same indicator on different timeframes is treated like separate indicators)
Check our other product here:
http://www.forexcopier.com

Robopip
Posts: 26
Joined: Thu Jun 21, 2012 12:03 am

#3 Postby Robopip » Wed Oct 10, 2012 3:39 pm

Hi,

Thanks for your reply.
Why can't I create text objects during those OnParamsChange calls above?
Is there any variable I can test to determine if object creation will fail?

For example I have found that during the really first call, TimeCurrent() will return zero.

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#4 Postby FT Support » Fri Oct 12, 2012 8:25 am

Probably the indicator is not initialized the access to the chart yet.
What errors do you get when you are trying to create objects from OnParamsChange?
Check our other product here:
http://www.forexcopier.com

Robopip
Posts: 26
Joined: Thu Jun 21, 2012 12:03 am

#5 Postby Robopip » Fri Oct 12, 2012 6:03 pm

FT Support wrote:Probably the indicator is not initialized the access to the chart yet.
What errors do you get when you are trying to create objects from OnParamsChange?


My belif is also that the indicator is not initialized yet. Is there a way to find out that?

I do not know what errors I get. The way I determine if object is created is by watching the return code of ObjectCreate.
If the return code is "true", then object is created otherwise it is not.

Maybe that is the only way to know? i e if ObjectCreate returns "false", it is because the indicator is not yet initialized...

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#6 Postby FT Support » Sun Oct 14, 2012 7:48 am

Do you have troubles with creating objects when the indicator is attached to the chart or at the moment when you change parameters of existing indicator? I'm not sure but maybe OnParamsChange will work in second case...
Check our other product here:
http://www.forexcopier.com

Robopip
Posts: 26
Joined: Thu Jun 21, 2012 12:03 am

#7 Postby Robopip » Sun Oct 14, 2012 2:42 pm

I have (so far) difficulties to create objects when Forextester2 is starting up.

I have also noticed that Forextester2 can not create objects during change/install of the indicator. I e if I have changed the source code and want to install the changed indicator, I do get into these situations where the indicator can not create text objects.

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#8 Postby FT Support » Tue Oct 16, 2012 1:00 am

This happens becuase the indicator do not have the access to the chart yet. Please try drawing objects when the indicator is initialized, for example you can draw indicators in "Calculate" procedure, in this case you may need the variable which will tell if the objects were drawn, you can reset this variable in "OnParamsChange".
Check our other product here:
http://www.forexcopier.com

KelvinHand
Posts: 103
Joined: Sun Jan 02, 2011 6:05 pm

#9 Postby KelvinHand » Tue Oct 16, 2012 1:00 am

Robopip wrote:I have (so far) difficulties to create objects when Forextester2 is starting up.

I have also noticed that Forextester2 can not create objects during change/install of the indicator. I e if I have changed the source code and want to install the changed indicator, I do get into these situations where the indicator can not create text objects.


You are right, OnParamsChange() can only process once during startup and cannot create object.

But you can set flag during startup in OnParamsChange() and ask the Calculate() to process your request to create the object.

Robopip
Posts: 26
Joined: Thu Jun 21, 2012 12:03 am

#10 Postby Robopip » Tue Oct 16, 2012 2:43 am

Well, I have come to the conclusion to avoid use onParamsChange().
It is better to try solve all object placement during calculate().
At this point I can do that.

Thanks all for helping me with my question.


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 24 guests