Strategy vault / Tools & templates
Buy then Sell ping pong strategy
As the title suggests, you can set a buy price, and after successful purchase, automatically set a sell price to sell, The plug-in can be started with one click on the trading terminal, free of charge, and convenient…
As the title suggests, you can set a buy price, and after successful purchase, automatically set a sell price to sell, The plug-in can be started with one click on the trading terminal, free of charge, and convenient for manual trading. Detailed introduction:https://www.fmz.com/digest-topic/5051
Parameters
| Name | Default | What it controls |
|---|---|---|
| BUYPRICE | 6200 | buy price |
| BUYAMOUNT | 0.1 | buy amount |
| SELLPRICE | 6400 | sell price after buying |
| Intervel | 6 | sleep time (second) |
Source JavaScript
function CancelPendingOrders() {
var orders = _C(exchange.GetOrders);
for (var j = 0; j < orders.length; j++) {
exchange.CancelOrder(orders[j].Id, orders[j]);
}
}
function main() {
Log('robot starts to run')
if(BUYPRICE >= SELLPRICE){
throw 'check buy and sell price'
}
CancelPendingOrders()
var account = _C(exchange.GetAccount)
var init_account = account
Log('account: ', account.Balance);
if(account.Balance > BUYPRICE*BUYAMOUNT){
exchange.Buy(BUYPRICE, BUYAMOUNT);
}else{
throw 'account balances is not enough'
}
while(true){
account = _C(exchange.GetAccount)
if(account.Stocks >= init_account.Stocks + 0.01){
exchange.Sell(SELLPRICE, account.Stocks - init_account.Stocks)
}
Sleep(Intervel*1000)
}
}
Published by 小草 on the FMZ strategy square · last modified 2020-03-24. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a tested, production-ready module from strategies/Buy-then-Sell-ping-pong-strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Binance Account Cross Transfer Small ToolJavaScript · Tools & templates
- Get cryptocurrency current and max supplyJavaScript · Tools & templates
- Interaction TemplateJavaScript · Tools & templates
- KuCoin Fund Transfer PluginJavaScript · Tools & templates
- Moving Average Bot 30 linesJavaScript · Tools & templates · 1d
- OKEx V5 Candlestick Data Paginated Query ExampleJavaScript · Tools & templates