script("MA 30/50 Crossover BTCUSD", kind="robot") input fastLength = 30 input slowLength = 50 input timeFrame = 3600 input historyCount = 300 input symbol = "BTCUSD" input volume = 0.01 input dryRun = 1 input maxPositions = 1 input cooldownSeconds = 0 input maxActionsPerEvent = 1 fast = ta.sma(close, fastLength) slow = ta.sma(close, slowLength) onBar { if ta.crossover(fast, slow) and trade.positionsCount(symbol=symbol) == 0 { trade.buy(symbol=symbol, volume=volume) } if ta.crossunder(fast, slow) and trade.positionsCount(symbol=symbol) > 0 { trade.closeAll(symbol=symbol) } }