Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Object of type "XXX" cannot be converted to object of type "XXX"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Object of type "XXX" cannot be converted to object of type "XXX"

    I try to use an object in the Parameters section. I create a Property based on my custom object.

    If all is Ok, I can set fields of the object and get the next output:

    [8] TestObjectProperties create outputs True
    [8] TestObjectProperties VALUES NUM 2
    [8] Set Settings2 Line_02 False True
    [8] Set Settings1 Line_01 True False
    [8] TestObjectProperties===========================
    [8] TestObjectProperties========Settings===========
    [8] TestObjectProperties===========================
    [8] TestObjectProperties Line_01 True False
    [8] TestObjectProperties Line_02 False True
    [8] TestObjectProperties===========================
    [8] TestObjectProperties
    [8] TestObjectProperties===========================
    As you can see bool properties are chnaged from default False value.

    But when I recompile the indicator and press F5 on the chart window I get the next

    Failed to set property 'Settings1' for indicator 'TestObjectProperties': Object of type "My_Settings.LongsShortsSettings" cannot be converted to object of type "My_Settings.LongsShortsSettings".
    Failed to set property 'Settings2' for indicator 'TestObjectProperties': Object of type "My_Settings.LongsShortsSettings" cannot be converted to object of type "My_Settings.LongsShortsSettings".
    Failed to set property 'Settings1' for indicator 'TestObjectProperties': call destination has created an exception.
    Failed to set property 'Settings2' for indicator 'TestObjectProperties': call destination has created an exception.
    [1] TestObjectProperties create outputs True
    [1] TestObjectProperties VALUES NUM 2
    [1] TestObjectProperties===========================
    [1] TestObjectProperties========Settings===========
    [1] TestObjectProperties===========================
    [1] TestObjectProperties Line_01 False False
    [1] TestObjectProperties Line_02 False False
    [1] TestObjectProperties===========================
    [1] TestObjectProperties
    [1] TestObjectProperties===========================
    And As you can see bool properties are not chnaged from default False value and I get the errors.

    I tried to use Reflection but it was unsuccessfull. This variant are commented in the code of indicator.

    It is, in fact, the setter that is the problem.
    The recommendation is to use
    [DesignerSerializationVisiblity(DesignerSerializati onVisiblity.Hidden)]
    attribute

    ... which will prevent the Visual Designer from trying to assign a serialized version of ObjectX to your control at design time, which is really what was going on ...

    But I had no result with it.

    Also, I tried to use this indicator in the 3rd party software and I got the same error. As the result of it that software can't save previously set values by user.

    What I should to to fix this error?
    Attached Files
    Last edited by fut_practic; 12-01-2017, 05:48 AM.

    #2
    Hello,

    Thank you for the post.

    I just wanted to let you know that I am currently reviewing this item, once I have further details on my findings I will reply back here.

    I look forwad to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I've also tried the attached version and get the same error

      [3] TestObjectProperties2 create outputs True
      [3] TestObjectProperties2 VALUES NUM 2
      Failed to set property 'Settings1_Long' for indicator 'TestObjectProperties2': call destination has created an exception.
      Failed to set property 'Settings1_Short' for indicator 'TestObjectProperties2': call destination has created an exception.
      Failed to set property 'Settings2_Long' for indicator 'TestObjectProperties2': call destination has created an exception.
      Failed to set property 'Settings2_Short' for indicator 'TestObjectProperties2': call destination has created an exception.
      [3] TestObjectProperties2===========================
      [3] TestObjectProperties2========Settings===========
      [3] TestObjectProperties2===========================
      [3] TestObjectProperties2 Line_01 False False
      [3] TestObjectProperties2 Line_02 False False
      [3] TestObjectProperties2===========================
      [3] TestObjectProperties2
      [3] TestObjectProperties2===========================
      Attached Files

      Comment


        #4
        Hello fut_practic,

        While we offer a TypeConverter example for NinjaTrader 8, we don't have the same resources to support its usage in NinjaTrader 7. This also goes for using reflection. These sorts of implementations have been made possible, but as they work with undocumented parts of the platform there is little direction we can provide. (Our "scope of support" only extends to what we have documented in our help guide and the resources we provide to you.)

        There are some indicators on this forum that use reflection and could be referenced to modify property grid behavior. I'll provide a link to one I looked at recently.

        Advanced Risk Reward Indicator - https://ninjatrader.com/support/foru...tid=-1&lpage=1

        If this doesn't lead you toward a resolution, could you provide a clear description of what you are trying to accomplish with the property grid specifically?

        We look forward to assisting you further.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by frankthearm, Yesterday, 09:08 AM
        13 responses
        45 views
        0 likes
        Last Post frankthearm  
        Started by PaulMohn, Today, 12:36 PM
        2 responses
        16 views
        0 likes
        Last Post PaulMohn  
        Started by Conceptzx, 10-11-2022, 06:38 AM
        2 responses
        53 views
        0 likes
        Last Post PhillT
        by PhillT
         
        Started by Kaledus, Today, 01:29 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by yertle, Yesterday, 08:38 AM
        8 responses
        37 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Working...
        X