• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Continue Drawing Line Until Indicator Crosses Above

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

    #31
    Originally posted by 2fr33d0m View Post
    I understand. Now I see a ray of hope.
    I'll check back from time to time.
    Thanks.
    It would certainly be easier if I just posted a complete indicator. However, due to the returns (insults or lack of requested feedback), that I have received from at least 3 ingrates on this forum, I decided and published, on this very forum, my decision that I would never provide any complete indicator to anybody ever again for free. That means that while, I may post the entire code for an indicator, that code will be posted as text, not as a complete importable indicator, ready for use. While that may violate the spirit of my decision, it certainly holds to the text of it.

    What that means is that I will provide the code that you want for the Long side; the Short side will follow the same ideas. You will have to copy and paste the code into the correct places in a new indicator that you write (or modify your current one, as required).

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    using System.Collections; //must be added
    #endregion
    Code:
            #region Variables
            private int        RayCount = 0;
            private ArrayList    RaysToBeDeleted = new ArrayList();
            private ArrayList    RaysToBeDeletedTags = new ArrayList();
            #endregion
    Code:
            protected override void Initialize()
            {
                Overlay                = true;
                DrawOnPricePanel    = false;
            }
    Code:
            protected override void OnBarUpdate()
            {
                if (CurrentBar < 2) return;
                
                bool LongSetup = false;
                LongSetup = High[0] <= Low[2] && Low[1] < Low[2];
                if (LongSetup) 
                {
                    RayCount++; //increase count, to use in creating unique ID
                    DrawRay("ray"+RayCount.ToString(), false, 2, Low[2], 0, Low[2], Color.Lime, DashStyle.Solid, 2);
                }
                
                //find rays to be handled
                foreach (IDrawObject draw in DrawObjects)
                {
                    if (draw.UserDrawn) continue;
                    if (draw is IRay && draw.Tag.StartsWith("ray")) //most likely one that the script drew
                    {
                        IRay tempRay = (IRay)draw;
                        if (High[0] > tempRay.Anchor1Y) //ray to be converted by overwriting and deletion
                        {
                            this.RaysToBeDeleted.Add(tempRay); //add ray to list of rays to be deleted
                            this.RaysToBeDeletedTags.Add(tempRay.Tag); //add tag to list of rays to be deleted
                        }
                    }
                
                }
                
                //process rays - draw line where there was a ray. Stop one bar ahead of CurrentBar.
                foreach (IRay tempRay in this.RaysToBeDeleted)
                {
                    string rayNumber = tempRay.Tag.Substring(3); //extract ray number
                    int startBarsAgo = tempRay.Anchor1BarsAgo;
                    int endBarsAgo = 1;
                    double lineLevel = tempRay.Anchor1Y;
                    DrawLine("line"+rayNumber, false, startBarsAgo, lineLevel, endBarsAgo, lineLevel, Color. Cyan, DashStyle.Solid, 2);
                }
                
                
                //delete rays
                foreach (string str in this.RaysToBeDeletedTags)
                {
                    RemoveDrawObject(str);
                }
                
                this.RaysToBeDeleted.Clear(); //reset the ArrayList
                this.RaysToBeDeletedTags.Clear(); //reset the ArrayList
                
            }
        }
    Last edited by koganam; 12-14-2013, 03:55 PM.

    Comment


      #32
      Originally posted by koganam View Post
      It would certainly be easier if I just posted a complete indicator. However, due to the returns (insults or lack of requested feedback), that I have received from at least 3 ingrates on this forum, I decided and published, on this very forum, my decision that I would never provide any complete indicator to anybody ever again for free. That means that while, I may post the entire code for an indicator, that code will be posted as text, not as a complete importable indicator, ready for use. While that may violate the spirit of my decision, it certainly holds to the text of it.

      What that means is that I will provide the code that you want for the Long side; the Short side will follow the same ideas. You will have to copy and paste the code into the correct places in a new indicator that you write (or modify your current one, as required).
      Wow!
      The Long side works just as I asked.
      Thank you so much for this. I could never have come up with this by myself
      copying and pasting. You saved me so much time.
      You are the best!

      Comment


        #33
        "It would certainly be easier if I just posted a complete indicator. However, due to the returns (insults or lack of requested feedback), that I have received from at least 3 ingrates on this forum, I decided and published, on this very forum, my decision that I would never provide any complete indicator to anybody ever again for free. That means that while, I may post the entire code for an indicator, that code will be posted as text, not as a complete importable indicator, ready for use. While that may violate the spirit of my decision, it certainly holds to the text of it.

        What that means is that I will provide the code that you want for the Long side; the Short side will follow the same ideas. You will have to copy and paste the code into the correct places in a new indicator that you write (or modify your current one, as required)."


        You are going to ask them to think and learn rather than hand it to them. What an awesome idea.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by profitabletrader306, Today, 12:00 AM
        0 responses
        2 views
        0 likes
        Last Post profitabletrader306  
        Started by marcelodelta, Yesterday, 08:28 PM
        2 responses
        11 views
        0 likes
        Last Post marcelodelta  
        Started by junkone, Yesterday, 09:06 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by ferenc., Yesterday, 04:54 PM
        2 responses
        17 views
        0 likes
        Last Post ferenc.
        by ferenc.
         
        Started by rwilliam, Yesterday, 03:51 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Working...
        X