← All scripts
Trading robotOpen sourceVersion 1

MA 30/50 Crossover BTCUSD

MA 30/50 Crossover BTCUSD

STSCRIPT / TRADING ROBOTMIT
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
Explore the source code ↓

About this script

MA 30/50 Crossover BTCUSD

Source code

Read and review the complete source before using it in your account.

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)
  }
}

Version history

  1. Version 1
    View this version →