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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      77 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X