Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

can I "execute" a string?

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

    can I "execute" a string?

    is there a way to convert a string to an executable function (probably wrong terminology)

    what I want to do is read in a string from an external file, like

    string indicatorLookup = "tdMAs().SMA50UpDown[0]";

    then "execute" that code in the a function like

    plotBlock(x, indicatorLookup); and have it replace indicatorLookup with tdMAs().SMA50UpDown[0],but as a function, not a string

    I basically need "execute a string"

    is this possible?


    here is the code where I use it.
    ================================================== =====

    protected override void OnBarUpdate()
    {
    int x = 0;

    plotBlock(x, tdMAs().SMA50UpDown[0]); x++;
    plotBlock(x, tdHA().HADirection[0]); x++;
    plotBlock(x, tdHA().HADirection[0]); x++;
    plotBlock(x, tdLRC().insideLRC[0]); x++;
    plotBlock(x, tdCycle().KUpDown[0]); x++;
    plotBlock(x, tdCycle().DUpDown[0]); x++;
    plotBlock(x, tdCycle().SFUpDown[0]); x++;
    plotBlock(x, tdCycle().DHighLow[0]); x++;
    plotBlock(x, tdCycle().KHighLow[0]); x++;
    plotBlock(x, tdMOM().MOMUpDown[0]); x++;
    plotBlock(x, tdMOM().MOMUpDown[0]); x++;
    plotBlock(x, tdOBVM().OBVUpDown[0]); x++;
    plotBlock(x, tdCMF().CMFUpDown[0]); x++;
    plotBlock(x, tdOBVM().OBVAboveSignal[0]); x++;

    }

    private void plotBlock(int x, int status)
    {
    if(Convert.ToInt16(scoreArray[Convert.ToInt16(chartPeriod),x]) > 0)
    {
    Values[x][0] = arrayLength - x;
    GetDotColor(x, status);
    }
    }



    #2
    Anything is possible ... but with this particular request
    you'll find very little builtin support in NinjaScript.

    I suspect you'll need to write the code to parse and
    execute the string yourself ...

    Comment


      #3
      Hello crea8able,

      Thank you for your post.

      You could consider using a StreamReader to read the strings from a file, however, parsing the retrieved string to have it execute a function would be outside the scope of what we would be able to support, bltdavid is correct there.



      I'll leave this open in case one of our users has some guidance they can share.

      Please let us know if we may be of further assistance to you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      54 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      72 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      38 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      99 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      60 views
      0 likes
      Last Post PaulMohn  
      Working...
      X