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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      331 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X