string goshort;
string golong;
protected override void OnBarUpdate()
{
// if condition to determine short
// if previous bar is green and if current bar has a higher high than previous bar, and a higher low than previous bar, and it's close < open (red bar) mark for short entry
bool sellEntry = Close[1] > Open[1] && Close[0] < Open[0] && High[1] < High[0] && Low[0] < High[1] && Low[0] > Low[1];
if (sellEntry) // && Close[0] < Open[0]
goshort = "short " + CurrentBar.ToString();
//Draw.TextFixed(this, "entrytext", "Enter Short", TextPosition.TopRight, ChartControl.Properties.ChartText,new SimpleFont("Arial", 10),Brushes.Transparent,Brushes.Transparent,0);
Draw.ArrowDown(this, goshort,true, 0, High[0] + TickSize, Brushes.Red);
// if condition to determine long
// if previous bar was red
// if current bar has a lower high than previous bar, and a lower low than previous bar, and it's open < close (green bar) mark for long entry
bool buyEntry = Close[1] < Open[1] && Close[0] > Open[0] && High[1] > High[0] && Low[1] > Low[0] && High[0] < High[1];
if (buyEntry) // && Close[0] > Open[0]
golong = "long " + CurrentBar.ToString();
//Draw.TextFixed(this, "entrytext", "Enter Long", TextPosition.TopRight, ChartControl.Properties.ChartText,new SimpleFont("Arial", 10),Brushes.Transparent,Brushes.Transparent,0);
Draw.ArrowUp(this, golong, true, 0, Low[0] + TickSize, Brushes.Green);
}
A more visual example of what I want to do (where left image is criteria for shorting, and right is criteria for going long):
Update: I found somebody that was able to write nearly the exact same logic for a tradingview indicator, but still no luck on my end for converting their code into ninjascript/C#.
Any tips or guidance?
Comment