Getting Started with PyPScript
Your first trading strategy in 10 minutes
This guide will walk you through creating, understanding, and deploying your first PyPScript trading strategy. No prior programming experience required.
What You'll Build
A simple moving average crossover strategy that:
- Buys when fast MA crosses above slow MA
- Sells when fast MA crosses below slow MA
- Uses RSI for confirmation
Prerequisites
- Access to PyP Dashboard (pyp.stanlink.online)
- Basic understanding of trading concepts (moving averages, RSI)
- 10 minutes of your time
Step 1: Create a New Project
-
Login to PyP Dashboard
- Navigate to pyp.stanlink.online
- Sign in with your account
-
Create New Project
- Click "New Project"
- Name: "My First Strategy"
- Description: "Learning PyPScript basics"
- Click "Create"
-
Open the Editor
- Click on your new project
- Navigate to "Editor" tab
- You'll see a blank
.ppcfile
Step 2: Write Your First Strategy
Copy and paste this code into the editor:
#!pyp/1.0 engine: pyp-1.0 // Import the indicators and functions we need import indicators.sma import indicators.rsi import functions.cross import functions.above import functions.below // Define our strategy strategy "ma_crossover_rsi" { // Calculate moving averages fast_ma = sma.evaluate(close, 10) slow_ma = sma.evaluate(close, 20) // Calculate RSI for confirmation momentum = rsi.evaluate(close, 14) // Define our trading patterns patterns { // Buy when fast MA crosses above slow MA and RSI > 50 cross(fast_ma, slow_ma) and above(momentum, 50) -> UP(confidence: 0.80) // Sell when fast MA crosses below slow MA and RSI < 50 cross(slow_ma, fast_ma) and below(momentum, 50) -> DOWN(confidence: 0.80) // Hold in all other cases default -> HOLD(confidence: 0.95) } } // Required metadata meta { author: "Your Name" version: "1.0" description: "Simple MA crossover with RSI confirmation" tags: ["moving-average", "rsi", "crossover", "beginner"] } // Optional configuration config { timeframes: ["1h", "4h"] pairs: ["EURUSD", "GBPUSD", "BTCUSDT"] lookback_period: 100 optimization: "accuracy" }
Step 3: Understand the Code
Let's break down each section:
Header
#!pyp/1.0 engine: pyp-1.0
- Specifies PyPScript version 1.0
- Required at the top of every file
Imports
import indicators.sma import indicators.rsi import functions.cross
- Import the technical indicators and functions you'll use
- Only import what you need for better performance
Strategy Block
strategy "ma_crossover_rsi" { // Your strategy logic goes here }
- Contains all your trading logic
- Strategy name must be unique
Indicator Calculations
fast_ma = sma.evaluate(close, 10) slow_ma = sma.evaluate(close, 20) momentum = rsi.evaluate(close, 14)
- Calculate technical indicators
closeis the closing price (built-in variable)- Numbers are the indicator parameters (periods)
Pattern Matching
patterns { cross(fast_ma, slow_ma) and above(momentum, 50) -> UP(confidence: 0.80) default -> HOLD(confidence: 0.95) }
- Define when to buy, sell, or hold
- Each pattern has a confidence level (0.0 to 1.0)
defaultcatches all other cases
Metadata
meta { author: "Your Name" version: "1.0" description: "Strategy description" }
- Required information about your strategy
- Used in the marketplace and for tracking
Configuration
config { timeframes: ["1h", "4h"] pairs: ["EURUSD", "BTCUSDT"] }
- Optional settings for training and deployment
- Specifies which markets and timeframes to use
Step 4: Validate Your Code
-
Save the File
- Press
Ctrl+S(Windows) orCmd+S(Mac) - Or click the "Save" button
- Press
-
Validate Syntax
- Click "Validate" button
- Check the console panel for any errors
- Green checkmark means success!
-
Common Errors and Fixes
Error: Missing import for 'cross' Fix: Add 'import functions.cross' Error: Invalid confidence value Fix: Use values between 0.0 and 1.0 Error: Missing default pattern Fix: Add 'default -> HOLD(confidence: 0.95)'
Step 5: Train Your Strategy
-
Navigate to Training
- Click "Training" tab in your project
- Click "New Training Run"
-
Configure Training
- Pairs: Select "EURUSD" and "BTCUSDT"
- Timeframes: Select "1h"
- Date Range: Last 3 months
- Sample Size: 50,000 samples
-
Start Training
- Review your settings
- Click "Start Training"
- Watch the live progress
-
Training Process
[1/4] Loading market data... ✓ [2/4] Computing indicators... ✓ [3/4] Generating training samples... ✓ [4/4] Optimizing strategy parameters... ✓ Training complete! Accuracy: 67.3%
Step 6: Test in Paper Trading
-
Navigate to Simulation
- Click "Simulation" tab
- Click "New Simulation"
-
Configure Simulation
- Strategy Version: Select your trained version
- Pairs: EURUSD
- Timeframe: 1h
- Initial Balance: $10,000
- Risk per Trade: 2%
-
Run Simulation
- Click "Start Simulation"
- Watch live trades in the chart
- Monitor portfolio performance
-
Simulation Results
Portfolio Balance: $10,450 Total Trades: 23 Win Rate: 65.2% Max Drawdown: -3.2% Sharpe Ratio: 1.8
Step 7: Deploy for Live Signals
-
Navigate to Deployment
- Click "Deploy" tab
- Select your trained strategy
-
Choose Delivery Channels
- ✓ Telegram Bot
- ✓ Discord Webhook
- ✓ Email Notifications
- ✓ Dashboard Alerts
-
Deploy Strategy
- Click "Deploy to Production"
- Your strategy is now live!
Understanding the Results
What Just Happened?
- You wrote declarative code - Described what you want, not how to do it
- AI optimized parameters - Found the best indicator settings automatically
- AI compilation - Your strategy became a highly optimized AI model
- Fast prediction - Brain Worker uses the trained model for real-time predictions
Why This Works
Traditional Approach:
Code → Rules → If/Then Logic → Decision
PyPScript Approach:
Intent → AI Training → AI Model → Prediction Engine → Decision
The AI found patterns in historical data that match your intent, then encoded them into a model for ultra-fast prediction.
Next Steps
Improve Your Strategy
- Add more indicators - Try MACD, Bollinger Bands, or Fractals
- Multi-timeframe analysis - Combine 1h and 4h signals
- Risk management - Add stop-loss and take-profit patterns
Learn Advanced Features
- Pattern Matching Guide - Complex conditions
- Strategy Validation - Validation methods
- Running Training - Optimization techniques
Join the Community
- Discord Server - Get help and share strategies
- Telegram Group - Latest updates and announcements
Common Questions
Q: Do I need programming experience?
A: No! PyPScript is designed for traders, not programmers. If you understand moving averages and RSI, you can write strategies.
Q: How accurate are the predictions?
A: Accuracy varies by strategy and market conditions. Good strategies achieve 55-70% accuracy with proper risk management.
Q: Can I use custom indicators?
A: Currently, we support built-in indicators. Custom indicators are coming in future updates.
Q: Is my strategy code private?
A: Yes! Your strategies are private by default. You can choose to share them in the marketplace for monetization.
Q: What markets are supported?
A: Forex (all major pairs), Crypto (Bitcoin, Ethereum, major altcoins), with Commodities and Indices coming soon.
Troubleshooting
Strategy Won't Validate
- Check all imports are correct
- Ensure confidence values are between 0.0 and 1.0
- Make sure you have a
defaultpattern - Verify all parentheses are balanced
Training Fails
- Reduce sample size if timeout occurs
- Check date range has sufficient data
- Ensure selected pairs have data for the timeframe
- Try simpler strategies first
Poor Performance
- Add more confirmation indicators
- Increase confidence thresholds
- Test on different timeframes
- Consider market conditions during training period
Success Tips
- Start Simple - Master basic patterns before adding complexity
- Test Thoroughly - Always paper trade before going live
- Understand Markets - PyPScript amplifies your trading knowledge
- Iterate Quickly - Try many variations to find what works
- Join Community - Learn from other successful strategy developers
Congratulations! You've created, trained, and deployed your first PyPScript strategy. You're now ready to explore more advanced features and build profitable trading systems.
Last updated: February 2026