Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaScript and Drawing RiskReward - implementation question

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

    NinjaScript and Drawing RiskReward - implementation question

    When using the drawing tool (pencil) on the chart and selecting the RiskReward menu item, a user begins the drawing specifying the ENTRY point, and then specifying the STOP LOSS point. The TARGET point is automatically calculated using the Ratio property of the object.

    However, when using Ninjascript and programmatically applying a RiskReward drawing to the chart as per:


    developers are provided parameters such as entryY, endY, ratio, etc. to specify positions. However, there appears to be some inconsistency here (or a lack of understanding on my part) as to what value goes where when it comes to the 'endY' parameter.

    As far as entryY, that's fairly obvious.
    As for as endY, it appears to be what I would put in as Price Target (rather than Stop Loss), as one would enter using the drawing tool.

    Perhaps you can provide some further clarification as to what values should go where since the documentation provided in the reference manual at this page:


    has an example which refers neither to Entry, StopLoss, Target, and I could use some additional insight to implement my indicator correctly.

    -- Gregory

    #2
    Hello wildwex,

    The endY parameter would be what the second click on the drawing tool sets. When coding the syntax you would use the start anchor price as entryY and the end anchor price as endY. As long as the rest of the parameters match what you manually drew then it should match. You would need to make sure isStop is set to true on both objects and also the same ratio is being used

    Code:
    Draw.RiskReward(NinjaScriptBase owner, string tag, bool isAutoScale, DateTime entryTime, double entryY, DateTime endTime, double endY, double ratio, bool isStop)
    I look forward to being of further assistance.

    Comment


      #3
      I would have thought much the same but the reverse appears to be true in that the endY is the parameter for the target, not the stop loss.

      Comment


        #4
        Hello wildwex,

        Right, when manually drawing the tool the reward is automatically calculated. You can adjust the start and end anchors which then is used for the calculation.

        Please let me know if I may be of further assistance.

        Comment


          #5
          I'm not sure I understand your post and if you're agreeing with my assessment. I'll boil down my statement and then reflect.

          1. The NinjaTrader RiskReward drawing tool has users specify ENTRY and STOPLOSS. The Target is calculated from the Ratio specified.
          2. The NinjaTrader DRAW.RiskReward ninjascript function has users specify ENTRY and TARGET. The STOPLOSS is calculated from the Ratio specified.

          My point is that there's no congruence why the drawing tool functions one way and the Draw.RiskReward function operates a different way.
          Further, such should be added to the documentation for claritifcation for users. AND perhaps an additional example for those that use
          the risk reward specifiying ENTRY/TARGET/STOPLOSS and how they should be applied in the Ninjascript function.

          Comment


            #6
            Notice the *attachment* displaying the properties of the Draw Object which shows that there is an ENTRY anchor and a RISK anchor. The RISK anchor represents a StopLoss. However, when leveraging the Ninjascript function, while the entryY parameter matches the ENTRY anchor, the endY parameter isn't the RISK anchor, but the TARGET anchor.

            They Draw Object for RiskReward and the Ninjascript function Draw.RiskReward should be consistent with one another, and they are not. As such, the documentation should note it and I'd recommend additional overlays so labeled ENTRY, RISK, TARGET or whatever your Developers suggest makes more sense.
            Attached Files

            Comment


              #7
              Hello wildwex,



              1. The NinjaTrader RiskReward drawing tool has users specify ENTRY and STOPLOSS. The Target is calculated from the Ratio specified.
              That depends on the bool isStop, if we use the actual names of the anchors here it is easier to see what is happening.
              We have the Entry anchor, Risk anchor and then the Reward extension.
              The "reward" is calculated by the Entry and Risk anchors along with the ratio when using isStop true.
              To see the same object between manual and programatic you could test this by manually entering the values for both the manual object and programatic:

              Code:
              Draw.RiskReward(this, "test", true, 10, 4158, 0, 4017, 1.2, true);
              Then on the chart just draw a risk reward and manually set its data to the same values, you should see identical objects showing that they work the same. The manually drawn object used two anchors to calculate the reward, the code version also used the same two anchors and ratio to calculate the reward when isStop is true.


              2. The NinjaTrader DRAW.RiskReward ninjascript function has users specify ENTRY and TARGET. The STOPLOSS is calculated from the Ratio specified.
              The code version has you specify the entry and endY, endY being the Risk anchor when isStop true.If you look in the code for the object you can see the properties copied to the risk anchor:
              Code:
              stopAnchor.CopyDataValues(riskReward.RiskAnchor);
              That is the way the manual tool also works however the manual tool has you manually control the risk anchor as the second anchor.


              My point is that there's no congruence why the drawing tool functions one way and the Draw.RiskReward function operates a different way.
              Further, such should be added to the documentation for claritifcation for users. AND perhaps an additional example for those that use
              the risk reward specifiying ENTRY/TARGET/STOPLOSS and how they should be applied in the Ninjascript function.
              The manual tool and code version work the same the reward is calculated based on the entry and endY anchors. The code version has an additional way it can be used by using isStop false. If you want it to work the same you can use isStop true.


              Please let me know if I may be of further assistance.


              Comment


                #8
                AHHH... yes, you are correct Jesse - missed that. I stand corrected.

                and I see that on a separate but associated HTML page ENTRY/TARGET/STOPLOSS is referred to here:
                https://ninjatrader.com/support/help...riskreward.htm

                However, the properties aren't mapped to the example. I'd have to assume that they are in some relative order to how they are applied in the function, I guess.

                A tad more insight might be added to the documentation for clarity.

                Thank you, sir.
                Last edited by wildwex; 07-02-2021, 09:28 AM.

                Comment


                  #9
                  Hello wildwex,

                  Thanks for providing that link i do see where it says stoploss. i will forward that off for further review.

                  I look forward to being of further assistance.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  628 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  359 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  562 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  568 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X