Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Windows Form, load .pdf

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

    Windows Form, load .pdf

    Hello ,

    I would like to implement the indicator to draw Option Levels based on bulletins from the market.

    To do this I have to load, parse .pdf file, do some formula calculations with data & then draw levels , as I see this scope for me.

    And , according to this, have some questions for more experienced guys (especially I'm very impressed of koganam's answers)

    1) Visual part:
    * wish to make a button to show "load .pdf file form"
    * press "Ok" to accept bulletin and start Logic part.
    (how it should look like I described in attached file)

    2) Logic part:
    * need some tips/examples how to parse .pdf file/files or at least how to work with I/O files in NT.
    * if it needs to include .dll , some tips how to work with dll in NT would be great

    Maybe some one knows simillar indicators - it will be the best!
    Thank you in advance , any help will be appreciated!!!!!
    Attached Files

    #2
    Hello akushyn,

    Thank you for your post.

    You can find an example of using a custom button and form at the following link: http://www.ninjatrader.com/support/f...d=4&linkid=475

    A reference sample for reading and writing files can be found at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3477

    Comment


      #3
      Thank you Patrick. It was helpful.

      Comment


        #4
        Originally posted by NinjaTrader_PatrickH View Post
        Hello akushyn,

        Thank you for your post.

        You can find an example of using a custom button and form at the following link: http://www.ninjatrader.com/support/f...d=4&linkid=475

        A reference sample for reading and writing files can be found at the following link: http://www.ninjatrader.com/support/f...ead.php?t=3477
        Hello,

        Have another few questions.

        When I finish load bulletin files I press "OK" button on the window form and would like to call OnBarUpdate() mehtod . How to do this? Or may be, you have another advise what is better way how to draw levels according to filter rules.

        Also, I am very interested how is possible to define properties dynamically to avoid copy/paste a lot of code? I think, better is to use list of properties...

        When I draw horizontal lines , should I remove objects ?
        If yes, how to loop a circle and check by the object by tag name?

        Forget to attach the .cs file and sample levels file.
        Attached Files
        Last edited by akushyn; 09-22-2014, 12:31 AM.

        Comment


          #5
          Have one more question...

          How to declare a root folder to load a file(s) as a property?
          I would like to make root folder avaliable to change by user.
          Now I use hard code, that is not good and not flexible.

          Code:
          			try
          			{
          				bulletin = ReadBulletin("[B]C:\\Users\\ProfitMaster\\Desktop\\Empty folder\\GOLD_DailyBulletin_pdf_20140904170.txt[/B]");
          				if (bulletin == null)
          					throw new Exception("Error reading bulletin files.");
          
          			}
          			catch (Exception exception)
          			{
          				Print(exception.ToString());
          				throw new Exception(exception.ToString());
          			}

          Comment


            #6
            Hello akushyn,

            Thank you for your posts.
            When I finish load bulletin files I press "OK" button on the window form and would like to call OnBarUpdate() mehtod . How to do this? Or may be, you have another advise what is better way how to draw levels according to filter rules.
            OnBarUpdate() would only be called when an update occurs for a bar. You may wish to call a custom method of you own depending on what you are trying to do here.
            Also, I am very interested how is possible to define properties dynamically to avoid copy/paste a lot of code? I think, better is to use list of properties...
            I am not sure I understand what you mean by defining the properties dynamically versus directly coding the properties.
            When I draw horizontal lines , should I remove objects ?
            If yes, how to loop a circle and check by the object by tag name?
            What do you mean by removing the objects? Why do you want to remove the objects if you want to draw them?
            How to declare a root folder to load a file(s) as a property?
            I have not seen this done before, I have only seen strings used as the property but the user must type out the file name. For example, from the LineAlert indicator on the Support Forum File Sharing Section:
            Code:
            		[Description("The name of the sound file. NT will look for this file in \\Program Files\\NinjaTrader\\sounds")]
                    [GridCategory("Parameters")]
                    public string SoundFile
                    {
                        get { return soundFile; }
                        set { soundFile = value; }
                    }

            Comment


              #7
              Hello akushyn:

              Indicators are running in the "sandbox" -- meaning they have security restrictions; and that includes file system access. You can't use the typical environment variables to find folders. You are limited to either hard-coded paths; or, you CAN actually use the Isolated Storage API; which "conceals" your files behind the isolated backing store. (Which lives in an abstruse location in Local/Low or somewhere like that -- not a place the user will be browsing at.)

              Comment


                #8
                OnBarUpdate() would only be called when an update occurs for a bar. You may wish to call a custom method of you own depending on what you are trying to do here.
                So, can I draw horizontal lines when I Press OK button ?
                As I understand correctly, no logic will be inside OnBarUpdate method

                I am not sure I understand what you mean by defining the properties dynamically versus directly coding the properties.
                As well as we can define class, visual components etc.

                What do you mean by removing the objects? Why do you want to remove the objects if you want to draw them?
                I mean, when I remove indicator from the chart, should i clear created by indicator objects?

                Comment


                  #9
                  Originally posted by steevcoco View Post
                  Hello akushyn:

                  Indicators are running in the "sandbox" -- meaning they have security restrictions; and that includes file system access. You can't use the typical environment variables to find folders. You are limited to either hard-coded paths; or, you CAN actually use the Isolated Storage API; which "conceals" your files behind the isolated backing store. (Which lives in an abstruse location in Local/Low or somewhere like that -- not a place the user will be browsing at.)
                  Thank you for the reply.

                  If you look inside code, I created window form, where you can choose the folder to load .txt files, then parse them as needed and use.
                  It works fine, but I want to use smth like default folder to load bulletin files when indicator starts.

                  Comment


                    #10
                    Could someone advise how to read from file only once, not every bar update, because data will be all the time the same?

                    Comment


                      #11
                      Originally posted by NinjaTrader_PatrickH View Post
                      Hello akushyn,
                      I have not seen this done before, I have only seen strings used as the property but the user must type out the file name. For example, from the LineAlert indicator on the Support Forum File Sharing Section:
                      Lets say I want to use Bulletin.txt file to load.
                      Where that file should be to see from the program?

                      Comment


                        #12
                        Yes, I see:

                        I Actually meant only that I didn't believe it would be possible to find the user's home folder on your own -- you can ask the user to provide a folder; but one API will throw exceptions if you try to get paths on your own. But now I have found it is possible with:

                        Code:
                        Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
                        There is another C# API that uses some environment variables like that; and those methods have thrown security exceptions for me. I can't remember the API at this point -- you can use an enumeration with values I think like APPDATA_LOCAL.

                        But the above is working for me! I did not find this API until just now!

                        Comment


                          #13
                          Hello akushyn,

                          Thank you for your response.
                          So, can I draw horizontal lines when I Press OK button ?
                          As I understand correctly, no logic will be inside OnBarUpdate method
                          In that case you would not need the OnBarUpdate().
                          As well as we can define class, visual components etc.
                          Still not sure in what context you are referring to this. Can you provide an example?
                          I mean, when I remove indicator from the chart, should i clear created by indicator objects?
                          Correct, the indicator when removed should also remove it's drawing objects/
                          Could someone advise how to read from file only once, not every bar update, because data will be all the time the same?
                          Lets say I want to use Bulletin.txt file to load.
                          Where that file should be to see from the program?
                          Unfortunately, I am not sure how to do this without just typing the directory directly into a field as a string.

                          Comment


                            #14
                            Originally posted by steevcoco View Post
                            Yes, I see:

                            I Actually meant only that I didn't believe it would be possible to find the user's home folder on your own -- you can ask the user to provide a folder; but one API will throw exceptions if you try to get paths on your own. But now I have found it is possible with:

                            Code:
                            Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
                            There is another C# API that uses some environment variables like that; and those methods have thrown security exceptions for me. I can't remember the API at this point -- you can use an enumeration with values I think like APPDATA_LOCAL.

                            But the above is working for me! I did not find this API until just now!
                            I use that GetFolderPath without issues. Win32 vista and XP and win7 64bit.

                            Comment


                              #15
                              Originally posted by akushyn View Post
                              Could someone advise how to read from file only once, not every bar update, because data will be all the time the same?
                              You could add a flag to say that you have loaded this file and check that flag.

                              Reset the flag on the next day in a window of 7am to 730am or something... then after that load the bulletin.txt and set the flag to say it was loaded.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by lightsun47, Today, 03:51 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post lightsun47  
                              Started by 00nevest, Today, 02:27 PM
                              1 response
                              10 views
                              0 likes
                              Last Post 00nevest  
                              Started by futtrader, 04-21-2024, 01:50 AM
                              4 responses
                              46 views
                              0 likes
                              Last Post futtrader  
                              Started by Option Whisperer, Today, 09:55 AM
                              1 response
                              14 views
                              0 likes
                              Last Post bltdavid  
                              Started by port119, Today, 02:43 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post port119
                              by port119
                               
                              Working...
                              X