title: TradingView Pine Script Multiple crossover strategy
body: <p>I am desperately looking for help with writing a strategy in trading view where I'm trying to create a crossover buy and sell signals on 3 different MA's , specifically a 9 ema , 21 ema, and 33 simple moving average. What I'm trying to do is have a long condition present itself when the 9 ema crosses above the 21 ema and also having the same long condition happen when the 21 ema crosses above the 33 simple moving average. I want this to work for both Long's and shorts - using the 9 &amp; 21 as a &quot;Small Signal&quot; while using the 21 and 33 as a &quot;Large Signal&quot; and I can't figure it out... this is the closest I have below and it wont work correctly</p>
  <pre><code>//@version=3
  //study(title=&quot;MA Crossover Strategy&quot;, overlay = true)
  strategy(&quot;EMA Crossover Strategy&quot;, overlay=true)
  src = input(close, title=&quot;Source&quot;)
  
  price = security(tickerid, period, src)
  ema1 = input(9, title=&quot;1st EMA Length&quot;)
  type1 = input(&quot;EMA&quot;, &quot;1st EMA Type&quot;, options=[&quot;SMA&quot;, &quot;EMA&quot;])
  
  ema2 = input(21, title=&quot;2nd EMA Length&quot;)
  type2 = input(&quot;EMA&quot;, &quot;2nd EMA Type&quot;, options=[&quot;SMA&quot;, &quot;EMA&quot;])
  
  sma3 = input(33, title=&quot;1st MA Length&quot;)
  type3 = input(&quot;SMA&quot;, &quot;2nd SMA type&quot;, options=[&quot;SMA&quot;, &quot;EMA&quot;])
  
  price1 = if (type1 == &quot;EMA&quot;)
  ema(price, ema1)
  else
  sma(price, ema1)
  
  price2 = if (type2 == &quot;EMA&quot;)
  sma(price, ema2)
  else
  ema(price, ema2)
  
  price3 = if (type3 == &quot;SMA&quot;)
  sma(price, sma3)
  else
  ema(price, sma3)
  
  //plot(series=price, style=line,  title=&quot;Price&quot;, color=black, linewidth=1, transp=0)
  plot(series=price1, style=line,  title=&quot;1st EMA&quot;, color=blue, linewidth=2, transp=0)
  plot(series=price2, style=line, title=&quot;2nd EMA&quot;, color=yellow, linewidth=2, transp=0)
  plot(series=price3, style=line, title=&quot;1st MA&quot;, color=orange, linewidth=2, transp=0)
  
  longCondition = crossover(price1, price2) and crossover(price2, price3)
  if (longCondition)
  strategy.entry(&quot;Long&quot;, strategy.long)
  
  shortCondition = crossunder(price1, price2) and crossover(price2, price3)
  if (shortCondition)
  strategy.entry(&quot;Short&quot;, strategy.short)
  </code></pre>
  <p>The signals wont show up but If you delete the last &quot;and crossover&quot; part of both conditions it will work only for the 9 ema and 21 ema but I want to incorporate the 21 ema and 33 simple cross.</p>
  <p>These are the signals I am trying to replicate for a strategy, the code was used to create the indicator but I'm having a hard time translating it to a strategy. You see the initial signal is given when the 9ema crosses the 21ema and the larger signal is given when the 21ema crosses the 33 simple ma...</p>
  <p><a href="https://i.stack.imgur.com/1CWcd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1CWcd.png" alt="image" /></a></p>