I use the code to output the signal to the strategy
the code
if (Close[0] > Values[1][0] && Open[0] > Values[1][0] && High[0] > Values[1][0] && Low[0] > Values[1][0]) { // Paint the current price bar lime to draw our attention to it BarBrushes[0] = Brushes.Lime; /* This crossover condition is considered bullish so we set the "bullIndication" Series<bool> object to true. We also set the "bearIndication" object to false so it does not take on a null value. */ bullIndication[0] = (true); bearIndication[0] = (false); } else if (Close[0] < Values[1][0] && Open[0] < Values[1][0] && High[0] < Values[1][0] && Low[0] < Values[1][0]) { // Paint the current price bar magenta to draw our attention to it BarBrushes[0] = Brushes.Magenta; /* This crossover condition is considered bearish so we set the "bearIndication" Series<bool> object to true. We also set the "bullIndication" object to false so it does not take on a null value. */ bullIndication[0] = (false); bearIndication[0] = (true); } // Crossover: No cross else { /* Since no crosses occured we are not receiving any bullish or bearish signals so we set our Series<bool> objects both to false. */ bullIndication[0] = (false); bearIndication[0] = (false); } // We set our variable to the close value. exposedVariable = Close[0];
if (Close[0] > Values[1][0] && Open[0] > Values[1][0] && High[0] > Values[1][0] && Low[0] > Values[1][0]) else if (Close[0] < Values[1][0] && Open[0] < Values[1][0] && High[0] < Values[1][0] && Low[0] < Values[1][0])
everything is as i need
The problem is that under these conditions a signal is sent to the strategy at each bar.
I tried to replace condition with Crossover so that the signal comes only once and only when crossing the line
if (CrossAbove(Values[1], 900, 1)) else if (CrossBelow(Values[1], 900, 1))
Comment