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

Multiple time frame price series

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

    Multiple time frame price series

    1. How can I access price for a specific time period in the same code?

    For instance, I want to do calculations with the Close High Low, etc. of the Daily, Weekly and say..Hourly within the same function.. how do I specify a time specific price series?

    2. Is there a way to reload an indicator on a chart if I recompile it, without removing, applying, and readding it?

    Draw.Text(this, "bartype"+CurrentBar, "2", 0, High[0] + 3, Brushes.Green);

    3. How would I add a bold, font size, or alignment to this? I tried the new Font but that gave me errors.

    Off topic: 4. Is there a way to tie an instrument list to a market analyzer? For instance I have a "daily" list and its loaded in my market analyzer. If I want to add a symbol to that list, do I actually have to type it in manually to the market analyzer, then add it to the instrument list, or add it to the instrument list - delete the market analyzer contents, reload the instrument list.. you get my point... is there some way I'm missing to keep lists and market analyzers synced?


    Thank you very much for any assistance.


    #2
    Hi UncleRyan, thanks for your question.

    1. In NinjaScript we have the ability to make multi time frame and instrument scripts. You run the code on your primary series (the one on the chart, BarsArray[0]) then every series added with AddDataSeries will also be available once the script has finished loading. We have a comprehensive guide on multi time frame and instrument scripts here:



    2. If you change code in the OnStateChanged method the script should be removed then re-added to the chart. If you change code anywhere else you can press F5 on your keyboard to reload all attached NinjaScripts.

    3. Use either one of these overloads:

    Code:
    Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, [B]SimpleFont font[/B], [B]TextAlignment alignment[/B], Brush outlineBrush, Brush areaBrush, int areaOpacity)
    Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, DateTime time, double y, int yPixelOffset, Brush textBrush, [B]SimpleFont font[/B], [B]TextAlignment alignment[/B], Brush outlineBrush, Brush areaBrush, int areaOpacity)
    You see a SimpleFont object and a TextAlignment object must be supplied.

    4. If you update your instrument list (add or remove from it) you can go to the market analyzer>right click>Add Instruments>MyList>Select All.

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      This is all very helpful - thanks a lot, Chris. Will probably be back with questions

      Comment


        #4
        Figured out some things on my own
        Last edited by UncleRyan; 05-27-2020, 07:40 PM. Reason: Figured out some things on my own

        Comment


          #5
          Screenshot
          Attached Files

          Comment


            #6
            One other item I can't seem to resolve, why the red/green numbers are so different on differently positioned on the various time frames. I've tried changing the 15 * Ticksize etc. but It just is accurate. Ideally I would want them all like the top middle.

            Code:
            if (High[0] > High[1] && Low[0] > Low[1]){
                            Draw.Text(this, "bartype"+CurrentBar, "2", 0,High[0] + (15 * TickSize), Brushes.Green); // 2 Up
                        }else if (High[0] < High[1] && Low[0] < Low[1]){
                            Draw.Text(this, "bartype"+CurrentBar, "2", 0, Low[0] - (15 * TickSize), Brushes.Red); // 2 Down
                        }

            Comment


              #7
              Hi UncleRyan, thanks for your reply.

              Do you want these two '2's in the middle of the bar? We have a price series called Median that calculates the middle price of every bar:



              If I am not correct here please clarify.

              I look forward to hearing from you.
              Chris L.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              3 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Working...
              X