PineScript → PocketOption bot bridge. Give it a PineScript, it transpiles the strategy to Python, runs it against live PocketOption data, and trades automatically via BinaryOptionsToolsV2.
your_strategy.pine → PineTranspiler → Python Strategy
↓
PocketOption candles ←── bo2 API ──→ Engine (indicators + signals) → Trade execution
- You provide a
.pinefile with your TradingView strategy - PocketPine transpiles it to a Python strategy class (with numpy-based indicators)
- The engine loads historical candles, warms up indicators, then streams live data
- When buy/sell conditions fire, trades are executed on PocketOption
pip install -r requirements.txt
# Transpile a PineScript and run it as a bot
python main.py --pine strategy.pine --ssid "YOUR_SSID"
# Or run a pre-built Python strategy directly
python main.py --strategy strategies.candlestick_pattern.CandlestickPatternStrategy --ssid "YOUR_SSID"
# Just transpile (no trading) to inspect the generated Python
python main.py --transpile-only strategy.pineTranspile and run a .pine file directly. The generated Python strategy is saved as *_strategy.py so you can review and tweak it.
python main.py --pine my_strategy.pine --ssid "$SSID" --asset EURUSD_otc --timeframe 60Run a hand-written or previously generated Python strategy class.
python main.py --strategy strategies.candlestick_pattern.CandlestickPatternStrategy --ssid "$SSID"Convert PineScript to Python without trading — useful for reviewing and customizing.
python main.py --transpile-only my_strategy.pine > my_strategy.pyReceive TradingView webhook alerts instead of running the strategy locally.
python main.py --webhook --ssid "$SSID" --port 8080| Flag | Default | Description |
|---|---|---|
--pine |
Path to .pine file to transpile and run |
|
--strategy |
Python strategy class (module.ClassName) |
|
--transpile-only |
Transpile .pine to Python and print |
|
--webhook |
Run as webhook server | |
--ssid |
env POCKETPINE_SSID |
PocketOption session ID |
--asset |
EURUSD_otc |
Trading asset |
--amount |
1.0 |
Trade amount |
--duration |
60 |
Trade duration (seconds) |
--timeframe |
60 |
Candle timeframe (seconds) |
--history |
200 |
Historical bars to load for warmup |
--no-check-win |
false |
Skip waiting for trade results |
import numpy as np
from pocketpine import indicators as ta
from pocketpine.strategy import Strategy
from pocketpine.signal_parser import Signal, Action
class MyStrategy(Strategy):
def setup(self):
self.p = {"fast": 10, "slow": 30}
def compute(self):
close = self.bars.close
self._fast = ta.sma(close, self.p["fast"])
self._slow = ta.sma(close, self.p["slow"])
self._cross_up = ta.crossover(self._fast, self._slow)
self._cross_down = ta.crossunder(self._fast, self._slow)
def get_signal(self):
if len(self.bars) < 3:
return None
if self._cross_up[-1]:
return Signal(Action.BUY, self.asset, self.amount, self.duration)
if self._cross_down[-1]:
return Signal(Action.SELL, self.asset, self.amount, self.duration)
return None| PineScript | Python |
|---|---|
ta.sma, ta.ema, ta.rsi, ta.atr |
indicators.sma, .ema, .rsi, .atr |
ta.crossover, ta.crossunder |
indicators.crossover, .crossunder |
ta.highest, ta.lowest, ta.stdev |
indicators.highest, .lowest, .stdev |
math.abs, math.max, math.min |
np.abs, np.maximum, np.minimum |
close[1] (history operator) |
ta.shift(close, 1) |
input.int, input.float, input.bool |
self.p dict |
and / or / not |
& / | / ~ (numpy) |
alertcondition(buySignal, ...) |
→ identified as signal in get_signal() |
- Never expose your SSID in code — use environment variables
- In webhook mode, use
--secretto validate incoming requests