Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Manipulating CurrentOHLC

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

    Manipulating CurrentOHLC

    I am only just beginning to understand ninjascript so I hope you'll bear with me through the question.

    Is it possible to change the CurrentOHL indicator such that it will give a visual and/or audible alert when price is a certain # of ticks from the high or low? I.e. if price = 6 ticks below current high do something and if price is 6 ticks above current low do something.

    More importantly is it possible to do the same thing but like this: if new high is made and then price moves below this new high by 6 ticks do something and if new low is made and then price moves above that low 6 ticks, do something.

    Again having no experience with scripting, is this a function of manipulating the commands of
    if (ShowHigh)...
    !PlotCurrentValue...
    else for (int idx = 0;...etc etc??

    Where can I find the commands for the functions to tell NT IF a new high is made... THEN do something?

    or IF price makes new high DO something else do NOTHING.

    Sorry for the complicated question I'm struggling to get a handle on C#

    Thanks everyone.
    Last edited by jtradr; 01-11-2011, 09:44 AM.

    #2
    Hello jtradr,

    Yes, this is possible in NinjaScript. You can compare the current price to a an indicator like CurrentDayOHL, and then take actions like alert.

    You can also use it to store values to compare later on, like making new highs.

    If you're new to NinjaScript, our tutorials are a good place to get started writing code right away.


    The branching logic can be done with if statements. You define a condition to look for, and then the code following the if statement is then executed when true. See here for help with branching in NinjaScript.

    To get a feel for what actions are available, the strategy wizard can be useful for you. You can define conditions and actions in a point and click interface and then view code.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan,

      Thank you. I'm starting to get a handle on the idea of "if price is a # of ticks from current high do something" but I'm not understanding how to say "if price makes a new high and then moves a # of ticks do something".

      Any tips on where to find this or how to do it?

      Comment


        #4
        Sure, there's always more than one way to do things in programming. The following example script compares High[0] to a variable, and then updates this variable whenever a new high is made.

        if (High[0] > myDouble)
        {
        myDouble = High[0];
        }

        that can be used to capture new highs, and you can make comparisons with this variable, like if it moves the opposite direction by a # of ticks.

        if (myDouble - Close[0] >= TickSize * 10)
        //do something.

        These are just examples. You'll have to code for the exact sequence you're going for.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Ryan,

          Excellent thank you I will spend some time working on that. In the mean time I have one more conceptual question.

          Is it possible to write a script that interacts with the DOM? For instance something that simply sums orders on either side in real time or something perhaps more intricate like order flows over time. Just curious if such a thing is possible. Can indicators draw data from the DOM?

          Comment


            #6
            You can't work off the visual dom display, but it's possible to work with depth of market programatically. We have a reference sample that walks you through creating your own level II display with NinjaScript.

            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Ryan,

              Am I understanding you properly?

              if (High[0] > myDouble)
              {
              myDouble = High[0];
              }

              Means "if the current high is greater than myDouble (a number I have created to store data) then make myDouble this new high" Is this daily high? Or bar high? I need Current Day High.

              and

              if(myDouble - Close[0] >= TickSize *10)

              means "if my data point minus the current close is greater than 10 ticks"

              is Close[0] the close of the current bar if set to calculate on bar close and is the current tick data if calculate on close is set to false? If it is the close of the bar does the definition of the bar change with the chart you load the strategy on to? Meaning 300 tick or 13 range?

              Here is the crux of this current issue: If this code were used to execute a trade let's say enter short. Won't you also need an && Close[1] >= Close[0] to ensure the market is moving down from the High[0]?

              How would you say this?

              if(myDouble - Close[0] >= TickSize * 10 && Close[0] < Close[1]);
              EnterShort()



              Once a strategy is running and you are in a position does it stop running until your target or stop are hit?

              If you use Close[1] with CalculateOnBarClose = false how will NT calculate your data? Will it use just 1 tick previous?

              Thank you so much for the help.

              Comment


                #8
                Sorry for inundating you with questions, hopefully I'll learn fast.

                Here is another one:

                Does the DOM call on MarketDataType = MarketDataType.Ask or something like that?

                If I use MarketDataType.Ask does that give me last ask price?

                More importantly, if I use MarketDataType.Ask in conjunction OnMarketData(MarketDataEventArgs e) does e.Volume give me the number of ask contracts at a current price

                I would like to use all the asks and bids (volume in contracts) standing at all the prices in view on the DOM. Is this possible? Does each tick on the DOM have an address you can call to get that number of contracts?

                Thank you.

                Comment


                  #9
                  OnMarketData() only gives you the first level (level I) of bid / ask data.

                  OnMarketDepth() is what you need to access level II data.

                  There are example code snippets using these event handlers in the links above. I would look at those examples first and then start tackling the level II order book sample.
                  Yes, you can work with all available levels of market depth data, following with the sample.
                  Ryan M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  648 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  369 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  573 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  575 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X