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.
[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]
[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]
[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