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

How to reference anchored price of the nearest drawing tool inside the indicator?

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

    How to reference anchored price of the nearest drawing tool inside the indicator?

    Hi,
    I've found a very usefull indicator from you guys and I'm trying to figure out how to reference name of the drawing tool inside the script for the indicator to know which drawing tool I want the anchored price to be referenced to?
    Could you please add the comment inside the script of where to replace the code with the filename (or some other reference) of the drawing tool as a default e.g. to get anchored price from the nearest horizontal line?

    Here is link to the indicator.

    Hi, I would like to know if it's possible to convert a drawing object (e.g. a line) into an indicator and be able to attach an order to that line since is only possible to do it whit indicators Also, I considered to create an alert for that line but it's not fine for me because don't allow add a Limit order (under actions in

    Thank you

    #2
    Hello Ludwik,

    The drawing objects use the Tag for the name, if you wanted to know a specific objects name you would need to use the Tag property.

    With the linked sample that would look similar to: if (draw.Tag == "MyTag")

    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for that Jesse,

      In regards to this tool: https://ninjatrader.com/support/foru...o-an-indicator

      I'm actually testing it now and don't know how to pass the captured value to the strategy.
      Normally when there is an indicator value like EMA etc. I'm able to get a most recent price with the use of these ones:
      Code:
       Values[0][0] = anchor.Price;
      Values[0][1] = anchor.Price;
      I've also added another code to this indicator otherwise strategy which uses it crashes with only single AddPlot
      Code:
       AddPlot(Brushes.Blue, "Long");
      AddPlot(Brushes.Orange, "Short");
      What I nornally do when want to capture and pass to the strategy Long or Short price values
      With these ones:
      Code:
       Values[0][0] = ExamplePriceLong;
      Values[1][0] = ExamplePriceShort;
      This time I'm getting an error message from the custom strategy with following messsage:
      Trade ignored becauseProfit Target CaptureDrawObjectsPlot had no value for CaptureDrawObjectsPlot
      QUESTION
      Could you please tell me what am I missing here AND how can I have strategy to read the price levels from this indicator?

      As an EXAMPLE
      Here is super simple code which works for me when capturing the price.
      Code:
       IsSuspendedWhileInactive = true;
      BarsBack = 2;
      AddPlot(Brushes.Orange, "StopPlotLong");//This is Values[0][0]
      AddPlot(Brushes.Blue, "StopPlotShort");//This is Values[1][0]
      }
      else if (State == State.Configure)
      {
      }
      }
      
      protected override void OnBarUpdate()
      {
      //Add your custom indicator logic here.
      
      //THIS IS THE PART YOU WRITE YOURSELF
      if (CurrentBars[0] <= BarsRequiredToPlot)//This just makes sure there are enough bars on the chart. Learn this stff by hitting F1 in NT8 and read help file.
      return;
      
      if (Low[0] < Low[1])
      Values[0][0] = Low[0];
      else
      Values[0][0] = Low[1];
      
      if (High[0] > High[1])
      Values[1][0] = High[0];
      else
      Values[1][0] = High[1];
      
      }
      Last edited by Ludwik; 03-17-2022, 02:55 PM.

      Comment


        #4
        Hello Ludwik,

        To pass the value to a strategy would require using a Plot like you have shown however because the draw object collection is not present in historical that would only work in realtime as long as the plot is consistently set.

        Is there a reason why the draw object search code is not just within the strategy its self? That would eliminate making signals in the indicator, you could just have the strategy directly controlled by that logic. If you wanted to visualize this from the indicator this would be a good situation to reverse the roles and have the strategy do the drawing object search logic and have a dummy indicator that simply reads a value that you want plotted from the strategy.

        JesseNinjaTrader Customer Service

        Comment


          #5
          Thank you for your reply Jesse,

          My issue is that I'm using a BlackBird which is a NT8 strategy from SharkIndicators.
          After your post I've been trying to develop a native NT8 strategy in order to have a code within the strategy itsefl with similar features as those from SharkIndicators. However I think it is too advanced to me at this time.

          Could you possibly explain to me what do you mean here as I'm not sure I understand (I'm new to NT8 Script):
          draw object collection is not present in historical that would only work in realtime as long as the plot is consistently set.
          And maybe give me some clues of what I should do to have it working without having the code within the strategy itself?


          Comment


            #6
            Hello Ludwik,

            draw object collection is not present in historical that would only work in realtime
            The drawing objects are not available to the script in historical bars so the script is only going to work going forward after the first realtime bar close.

            as long as the plot is consistently set.
            Generally for strategy signals you need to make a consistent plot, for example a plot where a price is plotted on every bar. That would allow the strategy to determine a difference in value or the plot can be used with the other features like CrossAbove/Below.

            The item you linked only sets a plot when the mouse is clicked so that wouldn't work for a signal, that does however show the logic to find drawing objects. That logic could be used from OnBarUpdate to find objects in realtime on each bar to set a plot.

            To get that working depends on how blackbird works or what signal it is looking for. The indicator would need to be made to produce the signal that blackbird looks for. The sample you linked to is plotting a price so you would have to make some type of price condition in blackbird to use the drawing object price. In your indicator you would need to move the finding the drawing object logic to OnBarUpdate so that price can be plotted for each bar where the object is found.






            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ghoul, Today, 06:02 PM
            2 responses
            13 views
            0 likes
            Last Post ghoul
            by ghoul
             
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            44 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            180 views
            0 likes
            Last Post jeronymite  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Working...
            X