title: Crossover function for multiple factors in an oscillator on Trading View
body: <p>I would like to add alerts to the following indicator on Trading View (Open source, oscillator). In brief, multiple conditions have to be met to trigger different types of alerts (long entry, long exit early, long exit late, short entry, short exit early, short exit late). I have three factors, slowMA + fastMA + middle line (midl) based on RSI or moving averages.</p>
  <p>Long entry: slowMA crosses up fastMA + slowMA crosses up midl + fastMA crosses up midl</p>
  <p>Long early exit: fastMA crosses up slowMA + slowMA crosses up midl + fastMA crosses up midl</p>
  <p>Long late exit: fastMA crosses up slowMA + midl crosses up slowMA + midl crosses up fastMA</p>
  <p>Short entry: FastMA crosses up slowMA + midl crosses up slowMA + midl crosses up fastMA</p>
  <p>Short early exit: slowMA crosses up fastMA + midl crosses up slowMA + midl crosses up fastMA</p>
  <p>Short late exit: slowMA crosses up fastMA + slowMA crosses up midl + fastMA crosses up midl</p>
  <p>I have no previous coding experience at all. I am receiving the error below. Many thanks for your help!:</p>
  <p>line 35: Cannot call 'crossover' with 'y'=plot. The argument should be of type: series[float];
  line 36: Cannot call 'crossover' with 'y'=plot. The argument should be of type: series[float];
  line 37: Cannot call 'crossover' with 'x'=plot. The argument should be of type: series[float];
  line 38: Cannot call 'crossover' with 'x'=plot. The argument should be of type: series[float];
  line 39: Cannot call 'crossover' with 'x'=plot. The argument should be of type: series[float];
  line 40: Cannot call 'crossover' with 'y'=plot. The argument should be of type: series[float];
  line 42: Undeclared identifier 'longopen';
  line 43: Undeclared identifier 'longcloseearly';
  line 44: Undeclared identifier 'longcloselate';
  line 45: Undeclared identifier 'shortopen';
  line 46: Undeclared identifier 'shortcloseearly';
  line 47: Undeclared identifier 'shortcloselate'</p>
  <pre><code>//@version=4
  study(&quot;TDI + RSI + BB [Market Makers Method]&quot;, shorttitle=&quot;MMM&quot;)
  
  rsiPeriod = input(21, minval = 1, title = &quot;RSI Period&quot;)
  bandLength = input(34, minval = 1, title = &quot;Band Length&quot;)
  lengthrsipl = input(7, minval = 0, title = &quot;Fast MA on RSI&quot;)
  lengthtradesl = input(2, minval = 1, title = &quot;Slow MA on RSI&quot;)
  
  src = close                                                             // Source of Calculations (Close of Bar)
  r = rsi(src, rsiPeriod)                                                 // RSI of Close
  ma = sma(r, bandLength)                                                 // Moving Average of RSI [current]
  offs = (1.6185 * stdev(r, bandLength))                                  // Offset
  up = ma + offs                                                          // Upper Bands
  dn = ma - offs                                                          // Lower Bands
  mid = (up + dn) / 2                                                     // Average of Upper and Lower Bands
  fastMA = sma(r, lengthrsipl)                                            // Moving Average of RSI 2 bars back
  slowMA = sma(r, lengthtradesl)                                          // Moving Average of RSI 7 bars back
  
  hline(32)                                                               // ExtremelyOversold
  hline(37)                                                               // Oversold
  hline(50)                                                               // Midline
  hline(63)                                                               // Overbought
  hline(68)                                                               // ExtremelyOverbought
  
  upl = plot(up, &quot;Upper Band&quot;, color = #3286c3, linewidth = 2)               // Upper Band
  dnl = plot(dn, &quot;Lower Band&quot;, color = #3286c3, linewidth = 2)               // Lower Band
  midl = plot(mid, &quot;Middle of Bands&quot;, color = #ffff00, linewidth = 2)      // Middle of Bands 
  
  plot(slowMA, &quot;Slow MA&quot;, color = #00AB08, linewidth=2)                       // Plot Slow MA
  plot(fastMA, &quot;Fast MA&quot;, color = #ff0000, linewidth=1)                         // Plot Fast MA
  
  longopen = crossover(slowMA, fastMA) and crossover(fastMA, midl) and crossover(slowMA, midl) 
  longcloseearly = crossover(fastMA, slowMA) and crossover(slowMA, midl) and crossover(fastMA, midl)
  longcloselate = crossover(fastMA, slowMA) and crossover (midl, slowMA) and crossover(midl, fastMA)
  shortopen = crossover(fastMA, slowMA) and crossover(midl, slowMA) and crossover(midl, fastMA)
  shortcloseearly = crossover(slowMA, fastMA) and crossover(midl, slowMA) and crossover(midl, fastMA)
  shortcloselate = crossover(slowMA, fastMA) and crossover(slowMA, midl) and crossover(fastMA, midl)
  
  alertcondition(longopen, title='Long Open', message='Long Open')
  alertcondition(longcloseearly, title='Long Close Early', message='Long Close Early')
  alertcondition(longcloselate, title='Long Close Late', message='Long Close Late')
  alertcondition(shortopen, title='Short Open', message='Short Open')
  alertcondition(shortcloseearly, title='Short Close Early', message='Short Close Early')
  alertcondition(shortcloselate, title='Short Close Late', message='Short Close Late')
  </code></pre>