Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

variables values - drawing - time

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

    variables values - drawing - time

    Hello,

    I try to resolve an issue in my script strat with reading from files long time but cant get it.

    I want to read from a csv file at a certain time when enabling the strategy and plotting SR-lines with the values from CSV file. Then after market open I want to read it again and plot the new SR lines. But this 2nd read and draw doesnt work. The lines from the premkt session persists. I have

    if(readlevelspm == true && readlevelsmkt == false && ToTime(Time[0]) > 60000)
    {
    foreach(LineInfo item in _mySRvalues)
    {
    readlevelspm = false;
    readlevelsmkt = true;
    if(item.LevelTextSort == "L1" && item.LevelValue > 0)
    {L1L = item.LevelValue; DrawHorizontalLine("L1L", false, item.LevelValue, Color.SaddleBrown, DashStyle.Dash,2);}}
    if(item.LevelTextSort == "L2" && item.LevelValue > 0)
    {L2L = item.LevelValue; DrawHorizontalLine("L2L", false, item.LevelValue, Color.SaddleBrown, DashStyle.Dash,2);}
    }

    if(readlevelsmkt == true && ToTime(Time[0]) > 93100 && ToTime(Time[0]) < 93500 && L3L == 0) // the SR level 3 appears only at 930, so I thought this additional condition
    {
    foreach(LineInfo item in _mySRvalues)
    { readlevelsmkt = false;
    if(item.LevelTextSort == "L1" && item.LevelValue > 0)
    {L1L = item.LevelValue; DrawHorizontalLine("L1L", false, item.LevelValue, Color.SaddleBrown, DashStyle.Dash,2);}}
    if(item.LevelTextSort == "L2" && item.LevelValue > 0)
    {L2L = item.LevelValue; DrawHorizontalLine("L2L", false, item.LevelValue, Color.SaddleBrown, DashStyle.Dash,2);}
    if(item.LevelTextSort == "L2" && item.LevelValue > 0)
    {L3L = item.LevelValue; DrawHorizontalLine("L3L", false, item.LevelValue, Color.SaddleBrown, DashStyle.Dash,2);}
    }

    But it doesnt plot the new values for level1 and 2 and doesnt plot level3. The SR levels from time 60000 persits. I have to disable and enable the strategy, only then the correct levels L1, L2 and also L3 is there with the values after 93000

    What am I doing wrong here with plottting referring time and flag?

    Thank you
    Tony

    #2
    Hello tonynt,

    Is the issue that the condition is not triggering?

    What prints have you added to your code to debug the logic?
    Can we see the prints and the output you have added?

    Is this second condition being triggered at the proper time?
    Is the foreach loop looping with the proper values?

    Is the file being opened a second time and being read in or does it use the values from the first time it was opened?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      thank you for your reply!

      There are no conditons beside what I have posted.
      The horizontal lines are the "prints" to debug. I use the values of the csv in my script, the horizontal lines are to control if read (I could also have asked in my post that the values - I have with drawtextfixed in the chart - are 0 after the reading at 93000. Before, at 60000 the variables and values and debug drawing lines are OK every day)
      Sorry with my english, I dont understand what you mean with ".... triggered at the proper time" there are different times (and the the first read condition at time o >60000 is added with a bool flag that is set to false then, no? So the second "reading" should be the only that time (if this is the question, sorry)

      And sorry again, I dont know what you mean with "looping with the proper values?" If I understand correctly, then "no, the SR values in csv files are different after 93000

      No, the file is not being opened a second time - ups, could this be the issue?? How to resolve this please if it is.

      Thank you
      Tony
      Last edited by tonynt; 05-13-2016, 10:11 AM. Reason: typing error

      Comment


        #4
        Hello Tony,

        If there are no other conditions in your script then the issue is that this script is not reading from a file at all.
        There is no posted code that shows a file is being read, and I had made the assumption that this was not included with the code in your post.

        Below is a link to an example that shows how to read from a file.
        http://www.ninjatrader.com/support/f...ead.php?t=3476

        Use prints to debug your code. Below is a link to a video that demonstrates how to use prints to understand the behavior of your script.
        https://www.youtube.com/watch?v=K8v_...tu.be&t=48m45s

        Add a print that prints the time and the values of every variable used in the condition. Then add the output and the code used to print the output to your post.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea,

          it does read from the file. At the time and condition posted.
          (referrinig your reply " its not reading from a file at all"). I wrote it does. You dont want me to post all the code from textreader here.

          But it does not read 2nd time with the time and conditon posted.


          I have in the code to read (as it does correctly at time 60000)
          #region List

          private static Dictionary<string, Color> _colorDictionary =
          typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static)
          .Where(prop => prop.PropertyType == typeof(Color))
          .ToDictionary(prop => prop.Name, prop => (Color) prop.GetValue(null, null), StringComparer.OrdinalIgnoreCase);

          List<LineInfo> _mySRvalues;
          #endregion

          and the text reader code....


          Could it be that the file need to opened a 2nd time at 93000 to be read?


          Thanks
          Tony
          Last edited by tonynt; 05-13-2016, 02:41 PM.

          Comment


            #6
            Hello Tony,

            I'm not able to see the code that does this, so I cannot tell you if the code is incorrect or correct.

            Instead, I am asking you if you have added prints to ensure it is being read when you expect it to be read.

            If the file is being read in a second time at the correct time, you should be able to print all of the new file contents to the output window and see that it has changed.

            Use prints to debug your code. Below is a link to a video that demonstrates how to use prints to understand the behavior of your script.
            https://www.youtube.com/watch?v=K8v_...tu.be&t=48m45s

            If you are reading from a file, print the file contents. Make sure its what you expect.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea,

              the reason was that I had it in Initialize, so no new reading with my times. I moved the code to OnOrderUpdate the both times I want it.

              Thank you for your support!

              Tony

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by SantoshXX, Today, 03:09 AM
              0 responses
              11 views
              0 likes
              Last Post SantoshXX  
              Started by DanielTynera, Today, 01:14 AM
              0 responses
              2 views
              0 likes
              Last Post DanielTynera  
              Started by yertle, 04-18-2024, 08:38 AM
              9 responses
              41 views
              0 likes
              Last Post yertle
              by yertle
               
              Started by techgetgame, Yesterday, 11:42 PM
              0 responses
              12 views
              0 likes
              Last Post techgetgame  
              Started by sephichapdson, Yesterday, 11:36 PM
              0 responses
              2 views
              0 likes
              Last Post sephichapdson  
              Working...
              X