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

Draw.Dot from Indicator (Owner Problem)

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

    Draw.Dot from Indicator (Owner Problem)

    Hello,

    i am trying to draw a dot using Draw.Dot which will be set to userDrawn after creation.
    Background is, that i would like these Dots to stay on the Chart even if the indicator is reloaded or removed.

    Is there any way or workaround to accomplish this?

    Thank you and Best regards,
    Mike

    #2
    Hi Mike,

    Its possible.

    First, drawing objects are already saved in the workspace. If you draw an object on a chart, save the workspace, and restart it will still be there.

    Any drawing objects that are drawn based on calculations from historical data, will also be drawn every time the indicator loads. So these would still be there as well.

    But lets say you were capturing the mouse click and drawing the items.
    You would need to store the price and time of each dot in some kind of file that can be read when the indicator is enabled.

    Below are links to examples of writing to file and reading from file.
    StreamWriter - http://www.ninjatrader.com/support/f...ead.php?t=3475
    StreamReader - http://www.ninjatrader.com/support/f...ead.php?t=3476

    Attached is an example of capturing the mouse click. (file removed, see post #3 below)
    Last edited by NinjaTrader_ChelseaB; 07-20-2020, 10:12 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Community,

      I realize MouseXYtoTimePriceExample is a bad name for a script that doesn't actual convert the x and y values to time and price.

      I've created two scripts to replace. I've renamed MouseXYtoTimePriceExample ClickDrawExample which is a better name. And I've actually coverted the x and y to price and time in MouseXYtoBarTimePriceExample.

      (edit 9/26/17)
      Small change. The IInputElement for the e.GetPosition() call is the ChartPanel which does not include the price margin. I've changed this to the ChartControl which does include the price margin and corrects the conversion when there is an indicator that is left justified.
      Attached Files
      Last edited by NinjaTrader_ChelseaB; 09-26-2017, 07:33 AM.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hello ,

        I would like some help to use the scripts above to place a limit order according to the position of my mouse. It's possible?

        However I would need a step by step to import it to my NT8 platform.

        Could you guys help me with this?

        Since I thank you.

        Comment


          #5
          Hello EvergreenGain,

          That would be possible, you could use the existing sample in this thread along with the addon Account methods to submit orders. If you get stuck somewhere or have follow up questions please use the support forums to make a new thread. I would suggest opening a new thread for your personal script so that we can keep this thread short and answer any questions you have without adding to this thread further. You can include a link to this thread in a new post to link the topics.

          The general steps that would be needed to submit an order from the sample are:
          Import the MouseXYtoBarTimePriceExample_NT8.zip
          You will need to access an account, there is a sample of gathering an account here: https://ninjatrader.com/support/help...ount_class.htm
          After adding the code to find the account you will have the myAccount variable. That variable can now be used to submit orders from the buttons click event method.
          In the existing MouseXY sample it shows how to gather the price so that price could be fed into the Submit method from the account.
          There is a sample of submitting an order to the account variable in the following page: https://ninjatrader.com/support/help...nt8/submit.htm

          If you need further assistance here I would suggest to open a new forum thread and attach a sample of what you tried. We could then work with you to help your understanding of the code being used.

          Please let me know if I may be of additional assistance.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          14 views
          0 likes
          Last Post Pattontje  
          Started by flybuzz, 04-21-2024, 04:07 PM
          17 responses
          229 views
          0 likes
          Last Post TradingLoss  
          Started by agclub, 04-21-2024, 08:57 PM
          3 responses
          17 views
          0 likes
          Last Post TradingLoss  
          Started by TradingLoss, 04-21-2024, 04:32 PM
          4 responses
          43 views
          2 likes
          Last Post TradingLoss  
          Started by cre8able, 04-17-2024, 04:16 PM
          6 responses
          56 views
          0 likes
          Last Post cre8able  
          Working...
          X