Reference Manual
Introducing the Reference Manual for Strategy Creator on BuddyTrading App
Empower Your Trading with JavaScript Strategy Creation
We are excited to introduce the comprehensive Reference Manual for the Strategy Creator on the BuddyTrading App! This manual is designed to assist you in creating powerful trading strategies using JavaScript. Whether you are a seasoned trader or a beginner, our Reference Manual provides the detailed information you need to build, test, and refine your trading strategies efficiently.
Accessing the Reference Manual
To access the Reference Manual, simply navigate to the Create Strategy page on the BuddyTrading App. You will find a Reference Manual tab on the header, which provides you with a detailed guide for each function available in the strategy creator. This tab is your go-to resource for understanding the various components and functionalities that you can leverage to create robust and effective trading strategies.
Overview of the JavaScript Functions
Our Reference Manual covers various functions you can use in the Strategy Creator. Here’s a sneak peek into what each function does:
define_Indicators
This function allows you to define and initialize any technical indicators your strategy will use.
Example:
define_Indicators: function() { this.rsi = this.indicator("RSI", this.RSI, 14); // 14-period Relative Strength Index this.ma = this.indicator("MA", this.MovingAverage, 50); // 50-period Moving Average }
define_meta
This function allows you to set metadata for your strategy, including its name, version, and a brief description.
Example:
define_meta: function() { this.strategyName = "RSI and MA Strategy"; this.version = "1.0"; this.description = "A trading strategy using RSI and Moving Average."; }
on_Price_Update
This function is triggered whenever there is a new price update. Use this function to process new price data and make trading decisions.
Example:
on_Price_Update: function(price) { let rsiValue = this.rsi.next(price); let maValue = this.ma.next(price); }
on_Enter
This function defines the conditions for entering a trade, whether it be a long or short position.
Example:
on_Enter: function() { let rsiValue = this.rsi.current(); let maValue = this.ma.current(); let price = this.price(); if (rsiValue < 30 && price < maValue) { this.buy(); // Enter long position } else if (rsiValue > 70 && price > maValue) { this.sellShort(); // Enter short position } }
on_Update
This function is called periodically to allow your strategy to update itself based on ongoing market changes.
Example:
on_Update: function() { // Perform periodic updates like logging or re-evaluating conditions }
on_Update_Long
This function manages updates for an ongoing long position.
Example:
on_Update_Long: function(position) { let stopLoss = position.entryPrice * 0.95; if (this.price() <= stopLoss) { this.sell(); // Exit long position } }
on_Update_Short
This function manages updates for an ongoing short position.
Example:
on_Update_Short: function(position) { let stopLoss = position.entryPrice * 1.05; if (this.price() >= stopLoss) { this.buyToCover(); // Exit short position } }
on_Update_Closing
This function handles actions when the market is about to close.
Example:
on_Update_Closing: function() { this.sellAll(); this.buyToCoverAll(); }
on_Position_Open
This function is triggered when a new position is opened, allowing for initial actions or logging.
Example:
on_Position_Open: function(position) { console.log("Position opened:", position); }
on_Position_Update
This function is called periodically to update an open position.
Example:
on_Position_Update: function(position) { // Add logic to update the position }
on_Position_Close
This function is called when a position is closed, useful for logging or performing wrap-up actions.
Example:
on_Position_Close: function(position) { console.log("Position closed:", position); }
Thank you for your continued support. We look forward to helping you achieve your trading goals with our latest features and resources.
Happy Trading!