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

DrawLine Help

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

    #16
    Originally posted by sburtt View Post
    Yes, it looks correct.
    Yes the only plot i would like to see is the Entry Level ( for only 5 bars)
    I deliberately refrained from asking about further refinements, such as if a new trigger was allowed when one was already in effect, et.c.,

    I included the dots, only as a visual aid to see that the initial trigger condition is met: I did not bother to remove the line afterwards, but you can always do so if you do not want to see the dots.

    Here is a skeleton of what you asked for. I trust that you can modify it for any other niceties.
    Code:
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]#region[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] Variables[/FONT] 
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]private [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] triggerCount = [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]private [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] triggerBar = -[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]private [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]int[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] entryKillBar = -[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]private [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]bool[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] mayEnterLong = [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]false[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]private [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]double[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] plotValue = [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]#endregion[/COLOR][/FONT]
    [/COLOR][/FONT]
    Code:
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]protected [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]override [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] Initialize()[/FONT]
    [FONT=Courier New]{[/FONT]
    [FONT=Courier New]Add([/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]new[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, [/FONT][FONT=Courier New][COLOR=#800000][FONT=Courier New][COLOR=#800000]"Plot0"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]));[/FONT]
    [FONT=Courier New]Overlay = [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New]}[/FONT]
    Code:
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]protected [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]override [/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]void[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] OnBarUpdate()[/FONT]
    [FONT=Courier New]{[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (CurrentBar < [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]) [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]return[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
     
    [FONT=Courier New][COLOR=#008000][FONT=Courier New][COLOR=#008000]//check Trigger condition[/COLOR][/FONT]
    [/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount = (Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]] < Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]]) ? [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount + [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] : [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] ([/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount >= [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]) [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].mayEnterLong = [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
     
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] ([/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount == [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New])[/FONT]
    [FONT=Courier New]{[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerBar = CurrentBar;[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].entryKillBar = CurrentBar + [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]5[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].plotValue = High[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]];[/FONT]
    [FONT=Courier New]DrawDot([/FONT][FONT=Courier New][COLOR=#800000][FONT=Courier New][COLOR=#800000]"triggerBar"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] + CurrentBar.ToString(), [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]false[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New], [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New], Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]] - [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] * TickSize, Color.Green);[/FONT]
    [FONT=Courier New]}[/FONT]
     
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (CurrentBar == [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].entryKillBar + [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New])[/FONT]
    [FONT=Courier New]{[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerBar = -[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].entryKillBar = -[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].mayEnterLong = [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]false[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
    [FONT=Courier New]}[/FONT]
     
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] (CurrentBar >= [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerBar && CurrentBar <= [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].entryKillBar)[/FONT]
    [FONT=Courier New]{[/FONT]
    [FONT=Courier New]Plot0.Set([/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].plotValue);[/FONT]
    [FONT=Courier New]}[/FONT]
    [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]else[/COLOR][/FONT]
    [/COLOR][/FONT][FONT=Courier New]{[/FONT]
    [FONT=Courier New]Plot0.Reset();[/FONT]
    [FONT=Courier New]}[/FONT]
    [FONT=Courier New]}[/FONT]

    Comment


      #17
      I seriously appreciate the effort. we are getting close, but not there yet, I've overlapped to your indicator the one I am trying to plot. I've attached a pic and tried to highlight the different steps, let me know if it looks clear now

      looking at the work you've sent me, it looks to me that your using the wrong trigger, it appears as if the trigger is the high[0] rather than high[2], and also this should forward start, basically the plot should start in the bar following bar0
      Attached Files

      Comment


        #18
        please refer to the chart on my last reply. i've amended a few things, and this should make the trick:

        protected override void OnBarUpdate()
        {
        if (CurrentBar < 2) return;

        //check Trigger condition
        this.triggerCount = (Low[0] < Low[1]) ? this.triggerCount + 1 : 0;
        if (this.triggerCount >= 2) this.mayEnterLong = true;

        if (this.triggerCount == 2)
        {
        this.triggerBar = CurrentBar + 1;
        this.entryKillBar = CurrentBar + 5;
        this.plotValue = High[2];
        DrawDot("triggerBar" + CurrentBar.ToString(), false, 0, Low[0] - 2 * TickSize, Color.Green);
        }

        if (CurrentBar == this.entryKillBar + 1)
        {
        this.triggerBar = -1;
        this.entryKillBar = -1;
        this.mayEnterLong = false;
        }

        if (CurrentBar >= this.triggerBar && CurrentBar <= this.entryKillBar)
        {
        Plot0.Set(this.plotValue);
        }
        else
        {
        Plot0.Reset();
        }
        }

        However, there is still something missing, I see that not all orange lines on your indicator are long 5 bars. is there a specific reason for this?

        and also,

        new trigger was allowed when one was already in effect, i would say yes to this.

        Comment


          #19
          Originally posted by sburtt View Post
          please refer to the chart on my last reply. i've amended a few things, and this should make the trick:

          protected override void OnBarUpdate()
          {
          if (CurrentBar < 2) return;

          //check Trigger condition
          this.triggerCount = (Low[0] < Low[1]) ? this.triggerCount + 1 : 0;
          if (this.triggerCount >= 2) this.mayEnterLong = true;

          if (this.triggerCount == 2)
          {
          this.triggerBar = CurrentBar + 1;
          this.entryKillBar = CurrentBar + 5;
          this.plotValue = High[2];
          DrawDot("triggerBar" + CurrentBar.ToString(), false, 0, Low[0] - 2 * TickSize, Color.Green);
          }

          if (CurrentBar == this.entryKillBar + 1)
          {
          this.triggerBar = -1;
          this.entryKillBar = -1;
          this.mayEnterLong = false;
          }

          if (CurrentBar >= this.triggerBar && CurrentBar <= this.entryKillBar)
          {
          Plot0.Set(this.plotValue);
          }
          else
          {
          Plot0.Reset();
          }
          }
          For what you describe, you should leave the triggerBar identifier as CurrentBar and change the Plot to:
          Code:
          if (CurrentBar > this.triggerBar && CurrentBar <= this.entryKillBar)
          {
          Plot0.Set(this.plotValue);
          }
          else
          {
          Plot0.Reset();
          }
          However, there is still something missing, I see that not all orange lines on your indicator are long 5 bars. is there a specific reason for this?

          and also,

          new trigger was allowed when one was already in effect, i would say yes to this.
          Your second paragraph is the reason for the first paragraph phenomenon. If a new trigger can be generated inside an existing setup, it will change the line to effectively restart at the new value.

          Yes, you are right, you did say that the triggerLevel is High[2]. Sorry, my mistake in using High[0].

          Comment


            #20
            Originally posted by koganam View Post
            For what you describe, you should leave the triggerBar identifier as CurrentBar and change the Plot to:
            Code:
            if (CurrentBar > this.triggerBar && CurrentBar <= this.entryKillBar)
            {
            Plot0.Set(this.plotValue);
            }
            else
            {
            Plot0.Reset();
            }
            Your second paragraph is the reason for the first paragraph phenomenon. If a new trigger can be generated inside an existing setup, it will change the line to effectively restart at the new value.

            Yes, you are right, you did say that the triggerLevel is High[2]. Sorry, my mistake in using High[0].
            koganam, thanks for dedicating me all this time, I really appreciate. I owe you a drink, or maybe something more like a dinner. last think I would like to ask you is how to change the line to effectively restart at the new value. So basically what code do I need to include to make sure a new trigger can be generated inside an existing setup. Thanks

            Comment


              #21
              Originally posted by sburtt View Post
              koganam, thanks for dedicating me all this time, I really appreciate. I owe you a drink, or maybe something more like a dinner. last think I would like to ask you is how to change the line to effectively restart at the new value. So basically what code do I need to include to make sure a new trigger can be generated inside an existing setup. Thanks
              That is what it does right now. Am I misunderstanding something again?
              Attached Files

              Comment


                #22
                I've attached a chart with exactly the same price action as the one you've posted. As you can notice I've highlighted an area of the chart were I see multiple setups forming on lower lows (1-2-3, a-b-c, i-ii-iii) that generate more than one trigger level, ideally I would like to be able to capture those trigger levels, as in case of break-out this would get me at an earlier stage in a long position. the reason i am so keen on getting these green lines plotted on the chart is that they workas resistance/resistance.

                further on, I've notice that in certain occasions on your chart the green line doesn't last for 5bars, would it be possible to change this and have trigger levels last always 5 bars?

                I hope I've been clear enough, Thanks for your help
                Attached Files

                Comment


                  #23
                  Originally posted by sburtt View Post
                  I've attached a chart with exactly the same price action as the one you've posted. As you can notice I've highlighted an area of the chart were I see multiple setups forming on lower lows (1-2-3, a-b-c, i-ii-iii) that generate more than one trigger level, ideally I would like to be able to capture those trigger levels, as in case of break-out this would get me at an earlier stage in a long position. the reason i am so keen on getting these green lines plotted on the chart is that they workas resistance/resistance.

                  further on, I've notice that in certain occasions on your chart the green line doesn't last for 5bars, would it be possible to change this and have trigger levels last always 5 bars?

                  I hope I've been clear enough, Thanks for your help
                  Not as a Plot. You asked for a Plot: you got a Plot. There is only one Plot, so there can be only one line drawn: the most current, as now, or the first in progress, if that is what you prefer. I have explained verbally, and by the notes on the chart that I posted, that if you are restarting the setup, then the (Plot) line restarts, necessarily terminating the previous line, in effect meaning that your lines will be a maximum of 5 bars, and can be less. A single Plot cannot overlap itself: it is a physical impossibility in an absolute sense.

                  If you want to do what you are now describing, you will have to draw lines instead of a Plot. In which case you merely have to draw a line 5 bars long, at the requisite level whenever your triggerCount is greater than 1.
                  Last edited by koganam; 02-18-2013, 10:04 AM.

                  Comment


                    #24
                    I hear you now. You must excuse me, I wasn't aware that there could be only 1 plot. It's all clear now. thanks for the clarification.

                    There is only one Plot, so there can be only one line drawn: the most current, as now, or the first in progress, if that is what you prefer.
                    Can you please indicate what to switch in the code to change from most current to first in progress?

                    If you want to do what you are now describing, you will have to draw lines instead of a Plot. In which case you merely have to draw a line 5 bars long, at the requisite level whenever your triggerCount is greater than 1.
                    Finally, am I right saying that if I set up this indicator to draw lines, rather than as a plot, I can't then use these lines as trigger levels to enter long in to a position?

                    Comment


                      #25
                      Originally posted by sburtt View Post
                      I hear you now. You must excuse me, I wasn't aware that there could be only 1 plot. It's all clear now. thanks for the clarification.
                      I must not have been clear about it. There can be any number of Plots: there is only one plot in this code. If you want to use multiple Plots, that is feasible. You will just have to declare a large number of Plots for use before hand, then implement the code as a cascade to determine which Plot to use for which setup, so that separate Plots are used for each setup.
                      Can you please indicate what to switch in the code to change from most current to first in progress?
                      To use "first in progress" just means that you will not process a new setup when one is already in progress. You simply need a unique variable whose state is known and definitive when a setup is in progress. You check that variable's value, and use it as a gate on processing. In this case, the one that makes the most sense would be: "when mayEnterLong is already true, do not start a setup." To do that you will have to change a section of the code, from:
                      Code:
                      [FONT=Courier New][COLOR=#008000][FONT=Courier New][COLOR=#008000]//check Trigger condition[/COLOR][/FONT]
                      [/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount = (Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]] < Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]]) ? [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount + [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] : [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] ([/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount >= [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]) [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].mayEnterLong = [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
                       
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] ([/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount == [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New])[/FONT]
                      [FONT=Courier New]{[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].mayEnterLong = [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerBar = CurrentBar;[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].entryKillBar = CurrentBar + [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]5[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].plotValue = High[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]];[/FONT]
                      [FONT=Courier New]DrawDot([/FONT][FONT=Courier New][COLOR=#800000][FONT=Courier New][COLOR=#800000]"triggerBar"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] + CurrentBar.ToString(), [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]false[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New], [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New], Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]] - [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] * TickSize, Color.Green);[/FONT]
                      [FONT=Courier New]}[/FONT]
                      to:
                      Code:
                      [FONT=Courier New][COLOR=#008000][FONT=Courier New][COLOR=#008000]//check Trigger condition[/COLOR][/FONT]
                      [/COLOR][/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount = (Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]] < Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]]) ? [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount + [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]1[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] : [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
                       
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]if[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] ([/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerCount == [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] && ![/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].mayEnterLong)[/FONT]
                      [FONT=Courier New]{[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].mayEnterLong = [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]true[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].triggerBar = CurrentBar;[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].entryKillBar = CurrentBar + [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]5[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New];[/FONT]
                      [FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]this[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New].plotValue = High[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]];[/FONT]
                      [FONT=Courier New]DrawDot([/FONT][FONT=Courier New][COLOR=#800000][FONT=Courier New][COLOR=#800000]"triggerBar"[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] + CurrentBar.ToString(), [/FONT][FONT=Courier New][COLOR=#0000ff][FONT=Courier New][COLOR=#0000ff]false[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New], [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New], Low[[/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]0[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New]] - [/FONT][FONT=Courier New][COLOR=#800080][FONT=Courier New][COLOR=#800080]2[/COLOR][/FONT][/COLOR][/FONT][FONT=Courier New] * TickSize, Color.Green);[/FONT]
                      [FONT=Courier New]}[/FONT]
                      Albeit, every line will then be exactly 5 bars long, that does not sound like what you are describing, unless I am again misunderstanding.
                      Finally, am I right saying that if I set up this indicator to draw lines, rather than as a plot, I can't then use these lines as trigger levels to enter long in to a position?
                      Not directly, as you would not be able to reference them. However, they are just data points, with specific values. You can always store any values in a structure, and then read them back for whatever purpose. In this case, you would probably want to store those values in an ArrayList (or Queue), which you can then pass and read for levels. You would of course, have to remove each ArrayList entry when the setup that it represents is invalidated.

                      Comment


                        #26
                        Code:
                        Quote:
                        Finally, am I right saying that if I set up this indicator to draw lines, rather than as a plot, I can't then use these lines as trigger levels to enter long in to a position?
                        
                        Not directly, as you would not be able to reference them. However, they are just data points, with specific values. You can always store any values in a structure, and then read them back for whatever purpose. In this case, you would probably want to store those values in an ArrayList (or Queue), which you can then pass and read for levels. You would of course, have to remove each ArrayList entry when the setup that it represents is invalidated.
                        Wouldn't it have been easier to simply store the High[2] value in an ArrayList (for 5 consecutive bars) each time the following condition occurs Low[0] < Low[1] && Low[1] < Low[2] and at the same time leave the DrawLine() I had originally posted in order to mantain the visual effect on the chart.

                        Wouldn't the end effect be the same if used in a strategy to go long on the breach of the trigger line ( in this case the Closest High[2] stored in ArrayList)?

                        Comment


                          #27
                          koganam, I spent some time reading again all this thread, thanks for your time. however i must say that in reality i still haven't got what i am looking for, probably we are misunderstanding each other. have a look at the chart attached, its a comparison of your chart (right) and my chart (left). Forget about how many plots we need, what I am trying to accomplish is simply have all those green segments on the chart as trigger levels that a strategy could enter on breakout. do you think the suggestion reported in my last reply could make the trick? Again thanks for your consideration
                          Attached Files

                          Comment


                            #28
                            Originally posted by sburtt View Post
                            Code:
                            Quote:
                            Finally, am I right saying that if I set up this indicator to draw lines, rather than as a plot, I can't then use these lines as trigger levels to enter long in to a position?
                             
                            Not directly, as you would not be able to reference them. However, they are just data points, with specific values. You can always store any values in a structure, and then read them back for whatever purpose. In this case, you would probably want to store those values in an ArrayList (or Queue), which you can then pass and read for levels. You would of course, have to remove each ArrayList entry when the setup that it represents is invalidated.
                            Wouldn't it have been easier to simply store the High[2] value in an ArrayList (for 5 consecutive bars) each time the following condition occurs Low[0] < Low[1] && Low[1] < Low[2] and at the same time leave the DrawLine() I had originally posted in order to mantain the visual effect on the chart.

                            Wouldn't the end effect be the same if used in a strategy to go long on the breach of the trigger line ( in this case the Closest High[2] stored in ArrayList)?
                            Sorry. I must again be misunderstanding the question. I simply pointed out that you will need to store the levels. How you present them visually is not really the issue.

                            However, if you do as you say, how then do you handle your overlapping setups?
                            Last edited by koganam; 02-18-2013, 08:03 PM.

                            Comment


                              #29
                              Originally posted by sburtt View Post
                              koganam, I spent some time reading again all this thread, thanks for your time. however i must say that in reality i still haven't got what i am looking for, probably we are misunderstanding each other. have a look at the chart attached, its a comparison of your chart (right) and my chart (left). Forget about how many plots we need, what I am trying to accomplish is simply have all those green segments on the chart as trigger levels that a strategy could enter on breakout. do you think the suggestion reported in my last reply could make the trick? Again thanks for your consideration
                              The only relevant issues are how you want to process your levels and how you want to present them. The minutiae is a matter of preference and style. I simply explained how I would go about it, given the constraints that you had specified. As with most programming, there are multiple other approaches, some less structured, some probably more structured.

                              You need to somehow store and retrieve the levels that are of interest to you. How you present them visually is also up to you.

                              I simply answered your questions specifically as you presented them. You can always change the question after you get the answers, but it does not mean that the question that you posed was not answered: each answer was simply tailored to the question.
                              Last edited by koganam; 02-18-2013, 07:59 PM.

                              Comment


                                #30
                                Code:
                                However, if you do as you say, how then do you handle your overlapping setups?
                                Wouldn't this be possible by simply checking the market position before going long, and ignoring the trigger levels when the position is already long, by handling only single entries? Something like this:

                                Code:
                                if (Position.MarketPosition == MarketPosition.Flat)

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Belfortbucks, Today, 09:29 PM
                                0 responses
                                3 views
                                0 likes
                                Last Post Belfortbucks  
                                Started by zstheorist, Today, 07:52 PM
                                0 responses
                                7 views
                                0 likes
                                Last Post zstheorist  
                                Started by pmachiraju, 11-01-2023, 04:46 AM
                                8 responses
                                150 views
                                0 likes
                                Last Post rehmans
                                by rehmans
                                 
                                Started by mattbsea, Today, 05:44 PM
                                0 responses
                                6 views
                                0 likes
                                Last Post mattbsea  
                                Started by RideMe, 04-07-2024, 04:54 PM
                                6 responses
                                33 views
                                0 likes
                                Last Post RideMe
                                by RideMe
                                 
                                Working...
                                X