Write your first strategy
What you need
- An Oathra account. Creating one is free.
- Price history for one symbol, exported from MetaTrader. Oathra ships no sample prices. Bring your price history
- A first test on your own price history needs storage, and the free plan includes none. Storage starts at 40 credits a month. Credit packs are coming soon.
- Credits for the data check and the test. Both are charged by the minute, and Forge shows the cost of a test before it starts. A standard test uses about 13 credits an hour.
- The numbers of a test are on both plans. The verdict is on the paid plan, $29 a month.
Write the strategy
A strategy is one Python file with one fg.Strategy class. Its compute method gets the price arrays as d and returns the signals for every bar at once.
import forge as fg
from forge import param, ta
FORGE_API = 1
class RsiCross(fg.Strategy):
bars = fg.bars.Time("H1")
direction = "long"
period = param.Int(14, min=2, max=50, group="RSI")
buy_level = param.Int(30, min=10, max=45, step=5, group="RSI")
exit_level = param.Int(60, min=50, max=80, step=5, group="RSI")
def compute(self, d) -> fg.Signals:
rsi = ta.rsi(d.close, self.period)
return fg.Signals(
long_entry=ta.crossover(rsi, self.buy_level),
long_exit=rsi > self.exit_level,
)The entry fires on the bar where the RSI crosses up through buy_level, not on every bar it stays above. The exit fires when it reaches exit_level.
bars = fg.bars.Time("H1") decides on one-hour bars. compute is pure: it reads d and the settings and nothing else, so it cannot look at the clock, the account or a random number.
Take it to Forge
Download the file. Testing is in Forge on oathra.app, on price history you upload.
Opens oathra.app in a new tab. You need an Oathra account. A test needs price history, storage and credits, and the verdict is on the paid plan.
You now have
A strategy file, ready to take to Forge.