0

I dont know what it wants from me, can somebody help me?

import("sma")

enter image description here

enter image description here

Here is the rest of the code


// © Gittiwilo

//@version=5
import("sma")

//define the variables for the EMA periods, stop loss, and take profit levels:
emaShortPeriod = 10
emaLongPeriod = 20
stopLoss = 0.5
takeProfit = 1.5

//define the EMA series using the 'sma()' function and the defined period variables:
emaShort = sma(close, emaShortPeriod)
emaLong = sma(close, emaLongPeriod)

//define the long and short entry signals using the EMA series and the 'cross()' function:
longEntry = cross(emaShort, emaLong)
shortEntry = cross(emaLong, emaShort)

//plot the long and short entry signals on the chart using the 'plotchar()' function:
plotchar(longEntry, "Long Entry", "▲", location.top, color = green, transp = 0)
plotchar(shortEntry, "Short Entry", "▼", location.top, color = red, transp = 0)

//function to generate market orders when the entry signals are triggered:
strategy.entry("Long", strategy.long, stop = strategy.position_avg_price * (1 - stopLoss), limit = strategy.position_avg_price * (1 + takeProfit))
strategy.entry("Short", strategy.short, stop = strategy.position_avg_price * (1 + stopLoss), limit = strategy.position_avg_price * (1 - takeProfit))
vitruvius
  • 15,740
  • 3
  • 16
  • 26
Gittiwilo
  • 11
  • 2

1 Answers1

0

import is used to include libraries. What you meant to have is strategy("sma").

Also, this code is written in v3, so you need to fix that too //@version=3.

// © Gittiwilo

//@version=3
strategy("sma")

//define the variables for the EMA periods, stop loss, and take profit levels:
emaShortPeriod = 10
emaLongPeriod = 20
stopLoss = 0.5
takeProfit = 1.5

//define the EMA series using the 'sma()' function and the defined period variables:
emaShort = sma(close, emaShortPeriod)
emaLong = sma(close, emaLongPeriod)

//define the long and short entry signals using the EMA series and the 'cross()' function:
longEntry = cross(emaShort, emaLong)
shortEntry = cross(emaLong, emaShort)

//plot the long and short entry signals on the chart using the 'plotchar()' function:
plotchar(longEntry, "Long Entry", "▲", location.top, color = green, transp = 0)
plotchar(shortEntry, "Short Entry", "▼", location.top, color = red, transp = 0)

//function to generate market orders when the entry signals are triggered:
strategy.entry("Long", strategy.long, stop = strategy.position_avg_price * (1 - stopLoss), limit = strategy.position_avg_price * (1 + takeProfit))
strategy.entry("Short", strategy.short, stop = strategy.position_avg_price * (1 + stopLoss), limit = strategy.position_avg_price * (1 - takeProfit))
vitruvius
  • 15,740
  • 3
  • 16
  • 26