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

Cannot convert a returning list from Indicator in Strategy

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

    Cannot convert a returning list from Indicator in Strategy

    Hi !
    I am struggling with the following problem:

    An indicator-method is returning a List of a locally defined structure.
    That works well inside the indicator.

    When calling the same from a strategy, which has exactly the same locally defined structure, it fails saying it cannot convert from one list to another.

    Can you, please, advise what the reason may be for this?
    Does the complier not allow this (IEnumeral casting required?)?
    How to do this best alternatively, if strategy and indicator shall use the same list & structure definitions?

    Hope the description makes sense.
    Thank you for your support !
    Matthias


    Strategy:
    public struct CalcResultStruc {
    public double lv_myAdditionalTime1_sma;
    public int lv_Total_Points; };


    private List<CalcResultStruc> mycalcResultList = new List<CalcResultStruc>();

    // Calling indicator method
    mycalcResultList = my_ACH.Calculate_ACH(mycalcResultList);



    Indicator:

    public struct CalcResultStruc {
    public double lv_myAdditionalTime1_sma;
    public int lv_Total_Points; };


    // local method
    private List<CalcResultStruc> Calculate_ACH(List<CalcResultStruc> calcResultList) {

    // do something

    return calcResultList;

    #2
    Hello Matthias,

    Thank you for your note.

    Within your indicator, you set your list to private, which you are trying to call from your strategy.
    Changing,

    private List<CalcResultStruc> Calculate_ACH(List<CalcResultStruc> calcResultList)

    to,

    public List<CalcResultStruc> Calculate_ACH(List<CalcResultStruc> calcResultList)

    You should be able to call the list from the strategy.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi Alan. I changed it to public, error remains. The list is coming back via return in a method, so I dont try to access the list directly from the strategy.
      I do pass the last into the indicator method, have it modified there and return it to the strategy.

      Am I calling it in a wrong way?
      When adding the indicator with Add(myIndicator) , then I can access the methods therein with myIndicator().myMethod();
      This is in order I assume?
      When adding the indicator with Add(), immediately the method 'initialize' of the indicator is executed I assume? And every time there is a bar update on the strategies data series, the barupdate on the indicator is executed, too?


      Ty
      Last edited by kuchen; 01-12-2017, 03:18 PM.

      Comment


        #4
        Hello Matthias,

        Without the code I'm unable to test on my end.

        Please send an email to [email protected] with Attn: Alan P in the Subject line. Also within the email please include a link to this thread, as well as the indicator and strategy.

        I look forward to receiving the files.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by frankthearm, Today, 09:08 AM
        3 responses
        7 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by yertle, Today, 08:38 AM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by adeelshahzad, Today, 03:54 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by bill2023, Yesterday, 08:51 AM
        6 responses
        27 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by NinjaTrader_ChelseaB, 01-08-2017, 06:59 PM
        80 responses
        19,667 views
        5 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X