This guide will help you understand how the Strategy Editor works in Buddy Trading. Think of it as a tool that lets you create automated trading strategies without needing to write complex code. Here’s a breakdown of how it works:


1. What Are Handlers?

Handlers are like "event listeners" that respond to specific moments in your trading strategy. For example, when a new price update happens or when a trade position is opened or closed. Here’s a list of the main handlers:

Each handler is like a small program that decides what to do when something happens in the market.


2. How Do Handlers Work?

Every handler receives two pieces of information:

  1. State: This is like a memory box that stores all the important details about your strategy, such as open trades, historical data, and custom settings.
  2. Update: This is the new information coming in, like the latest price or candle data.

Here’s an example of what happens inside a handler:

async (state = {}, update = {}) => {
  const { mts, price, candle } = update; // Get the latest data
  return state; // Update the state if needed
}