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

Using Risk-Reward drawing tool as input for indicator

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

    Using Risk-Reward drawing tool as input for indicator

    Hello, I am trying to create an indicator where I require as input parameters:

    Risk-Reward drawing tool
    Cash value on the account

    My plan is to use the Risk-Reward drawing tool to measure manually my risk for operation, then use it as parameter input to calculate the # of lots to open an operation based Cash Value on the account and Risk, a plus update Order

    How can I get the data from the Risk-Reward drawing tool (if possible)
    and from where can I get the Cash Value on the account,

    Regards,
    Alejandro

    #2
    Hi Alejandro, thanks for your post.

    The RiskReward object properties are documented here:
    https://ninjatrader.com/support/help...riskreward.htm

    It has three ChartAnchor objects and one "Ratio" integer.

    When you call Draw.RiskReward() this object is returned.

    To get CashValue from an indicator you need to set up an Addon style Account object, we have a full code example of doing this here:
    https://ninjatrader.com/support/help...ount_class.htm

    Specifically, you would use the Account.Get() method.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi ChrisL,

      ̶I̶ ̶t̶r̶i̶e̶d̶ ̶t̶o̶ ̶i̶n̶c̶l̶u̶d̶e̶ ̶t̶h̶e̶ ̶e̶x̶a̶m̶p̶l̶e̶ ̶c̶o̶d̶e̶ ̶t̶o̶ ̶l̶o̶o̶k̶s̶ ̶w̶h̶a̶t̶ ̶h̶a̶p̶p̶e̶n̶:̶
      ̶p̶r̶o̶t̶e̶c̶t̶e̶d̶ ̶o̶v̶e̶r̶r̶i̶d̶e̶ ̶v̶o̶i̶d̶ ̶O̶n̶B̶a̶r̶U̶p̶d̶a̶t̶e̶(̶)̶
      ̶{̶
      ̶/̶/̶ ̶I̶n̶s̶t̶a̶n̶t̶i̶a̶t̶e̶ ̶a̶ ̶R̶i̶s̶k̶R̶e̶w̶a̶r̶d̶ ̶o̶b̶j̶e̶c̶t̶
      ̶R̶i̶s̶k̶R̶e̶w̶a̶r̶d̶ ̶m̶y̶R̶R̶ ̶=̶ ̶D̶r̶a̶w̶.̶R̶i̶s̶k̶R̶e̶w̶a̶r̶d̶(̶t̶h̶i̶s̶,̶ ̶"̶t̶a̶g̶1̶"̶,̶ ̶f̶a̶l̶s̶e̶,̶ ̶0̶,̶ ̶H̶i̶g̶h̶[̶0̶]̶,̶ ̶1̶0̶,̶ ̶L̶o̶w̶[̶0̶]̶,̶ ̶2̶,̶ ̶t̶r̶u̶e̶)̶;̶
      ̶
      ̶/̶/̶ ̶C̶h̶a̶n̶g̶e̶ ̶t̶h̶e̶ ̶o̶b̶j̶e̶c̶t̶'̶s̶ ̶r̶i̶s̶k̶/̶r̶e̶w̶a̶r̶d̶ ̶r̶a̶t̶i̶o̶ ̶t̶o̶ ̶2̶:̶1̶
      ̶m̶y̶R̶R̶.̶R̶a̶t̶i̶o̶ ̶=̶ ̶2̶;̶
      ̶/̶/̶A̶d̶d̶ ̶y̶o̶u̶r̶ ̶c̶u̶s̶t̶o̶m̶ ̶i̶n̶d̶i̶c̶a̶t̶o̶r̶ ̶l̶o̶g̶i̶c̶ ̶h̶e̶r̶e̶.̶
      ̶}̶
      ̶
      ̶b̶u̶t̶ ̶f̶o̶r̶ ̶s̶o̶m̶e̶ ̶r̶e̶a̶s̶o̶n̶ ̶i̶t̶ ̶m̶a̶k̶e̶s̶ ̶m̶y̶ ̶c̶u̶s̶t̶o̶m̶ ̶i̶n̶d̶i̶c̶a̶t̶o̶r̶ ̶w̶o̶n̶'̶t̶ ̶a̶p̶p̶e̶a̶r̶ ̶o̶n̶ ̶t̶h̶e̶ ̶I̶n̶d̶i̶c̶a̶t̶o̶r̶ ̶w̶i̶n̶d̶o̶w̶ ̶o̶n̶ ̶t̶h̶e̶ ̶l̶i̶s̶t̶ ̶o̶f̶ ̶a̶v̶a̶i̶l̶a̶b̶l̶e̶ ̶i̶n̶d̶i̶c̶a̶t̶o̶r̶

      #UPDATE

      ChrisL, I re-read everything again and it is working just fine thanks for your help

      Now the concern I have are:
      I created my new tool as a custom Drawing tool, I would like to distribute it as an "indicator" what should be the procedure to follow?

      Also, could I use and "Custom indicator" to feed this new drawing tool? again how can I distribute it to others if I do it this way?

      Regards,
      Last edited by alejandro888; 06-20-2021, 06:38 PM.

      Comment


        #4
        Hi Alejandro, thanks for your reply.

        A DrawingTool and Indicator object are different from each other. To distribute your work go to Tools>Export>NinjaScript Addon and this will let you package the indicator or drawing tool. From the original post, I assumed you were making an indicator. Indicators can call drawing objects if the drawing objects have public overrides set up that allow for calling from an external source (see any default drawing tool for an example).

        Best regards,
        -ChrisL

        Chris L.NinjaTrader Customer Service

        Comment


          #5
          How do I add to my indicator the risk reward?
          When my indicator prints bar on screen, I want to automatically set the risk to reward to print on screen as well as seen in my screenshot.

          Comment


            #6
            Hi sunfirerv, thanks for posting.

            The RiskReward drawing tool is documented here:


            This can be drawn from your custom indicator. There is an example on the page I linked above.

            Best regards,
            -ChrisL
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thank You for the info.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Tim-c, Today, 03:54 AM
              0 responses
              3 views
              0 likes
              Last Post Tim-c
              by Tim-c
               
              Started by FrancisMorro, Today, 03:24 AM
              0 responses
              3 views
              0 likes
              Last Post FrancisMorro  
              Started by Segwin, 05-07-2018, 02:15 PM
              10 responses
              1,772 views
              0 likes
              Last Post Leafcutter  
              Started by Rapine Heihei, 04-23-2024, 07:51 PM
              2 responses
              31 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by Shansen, 08-30-2019, 10:18 PM
              24 responses
              945 views
              0 likes
              Last Post spwizard  
              Working...
              X