• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

loading data from a text file and updating indicator

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

    loading data from a text file and updating indicator

    I have an issue that when I load my data in a text file. The information exists and it will will load to the parameters needed for drawing.


    I have a draw button, when you click the button it calls a subroutine and it will draw on the screen.

    When I load the data i run the same subroutine during OnStartup it will not draw. I have to press the draw button to trigger the method in order for it to draw.

    The question is how do I force it to draw?

    I even tried this

    btnDraw_Click(new object(), new EventArgs());
    Update();

    and still it won't work.



    private void btnDraw_Click(object sender, EventArgs e)
    {
    if (btnDraw.Text == "Draw")
    {
    //button parameters
    btnDraw.Text = "Complete";
    btnDraw.Font = boldFont;
    btnDraw.ForeColor = Color.Black;
    btnDraw.BackColor = Color.Gray;


    DrawMyLines();

    bShowMarkerLine = false;
    RemoveDrawObject("VLine");
    RemoveDrawObject("EndLine");

    }
    else if (btnDraw.Text == "Complete")
    {
    btnDraw.Text = "Draw";
    btnDraw.Font = regularFont;
    btnDraw.ForeColor = Color.Black;
    btnDraw.BackColor = Color.Lavender;
    bShowMarkerLine = true;//
    }

    btnDraw.Enabled = true;
    bUpdate = true;
    Update();
    }
    Last edited by ballboy11; 11-15-2017, 03:02 PM.

    #2
    Hello,

    Thank you for the post.

    Out of context, it would be hard to say what may be happening, have you checked if the objects are being placed at the beginning of the chart in historical data?

    Also, Are you currently using a DateTime to place the objects or a BarsAgo? A DateTime would be required if you are using OnStartUp as the BarsAgo would not be helpful in that state. Can you confirm this for me?

    The last item which may be related is that I see you tried to call the button click handler. Did you add a print to make sure that worked? If it had not you may instead try to just contain this code in its own method. Basically the logic you have posted, but inside of its own method.

    Code:
    private void myButtonLogic()
    {
        if (btnDraw.Text == "Draw") ......\\ existing code from button event handler
    }
    
    
    private void btnDraw_Click(object sender, EventArgs e)
    {
        myButtonLogic();
    }
    
    protected override void OnStartUp()
    {
        myButtonLogic();
    }


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

    Comment


      #3
      -1,2017-11-15 9:26:00 AM,2017-11-15 10:59:00 AM,0,0,True

      I made a cvs and loaded my data

      int
      DateTime
      DateTime
      int
      int
      bool

      I parsed the information from my cvs AND it is working when I print out the information on the output screen

      //************************************************** ************************************************** ****
      public void parseString(string sInformation )
      {

      string[] separatingChars = { "," };
      string text = sInformation;
      string[] words = text.Split(separatingChars, System.StringSplitOptions.RemoveEmptyEntries);

      int nCounting = 0;

      tTime1 = Convert.ToDateTime (words[1]);
      tTime2 = Convert.ToDateTime(words[2]);
      nResTime = Convert.ToInt16(words[3]);
      nBarRange = Convert.ToInt16(words[4]);
      bReversePolarity = Convert.ToBoolean(words[5]);
      Print("Time 1 is " + tTime1);
      Print("Time 2 is " + tTime2);
      Print("nResTime is " + nResTime);
      Print("nBarRange is " +nBarRange);
      Print("bReversePolarity is " + bReversePolarity);
      }

      when I print all my data is correct and these variables are global

      i even tried this


      in onBarUpdate

      if (CurrentBar == 2)
      {

      if(bLoadedFromDatabase == true)
      {

      LoadTradingTemplate(sFileName);
      Print("In Here");
      }
      }
      Last edited by ballboy11; 11-15-2017, 03:41 PM.

      Comment


        #4
        wierd algo works live but not loaded

        SOLVED!!!

        FOR some reason Time[0] timestamp when loading is still the first bar on the loaded chart

        I had to use DateTime.Now;

        Thanks for your help
        Last edited by ballboy11; 11-15-2017, 04:37 PM.

        Comment


          #5
          Hello,

          Thank you for the reply.

          If you are using NinjaScript properties in an out of sync method like a buttons event handler, you may need to use TriggerCustomEvent to sync the NinjaScript inherited values to avoid using DateTime.Now. I would also not suggest using DateTime.Now in the platform as this has no relation to the bars times.

          https://ninjatrader.com/support/help...ghtsub=trigger

          you would likely need to change the method you use to have an object overload like shown in the help guide. Once you do that, you can call trigger custom event like the following:

          Code:
          private void btnDraw_Click(object sender, EventArgs e)
          {
              TriggerCustomEvent(MyCustomHandler, null);
          }
          private void MyCustomHandler(object state)
          {
              Print("Time[0] should now work: " + Time[0].ToString());			
          }
          Could you try this as well to see if this can be used instead of DateTime.Now in your use case?

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

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Bluebeep, Today, 12:26 PM
          0 responses
          3 views
          0 likes
          Last Post Bluebeep  
          Started by Johnny90, Today, 12:12 PM
          0 responses
          1 view
          0 likes
          Last Post Johnny90  
          Started by login_dejavu, Today, 10:55 AM
          0 responses
          5 views
          0 likes
          Last Post login_dejavu  
          Started by learningnt, Today, 08:47 AM
          0 responses
          205 views
          0 likes
          Last Post learningnt  
          Started by alikair, 12-08-2016, 07:28 AM
          4 responses
          1,555 views
          0 likes
          Last Post vjsworld  
          Working...
          X