Blueprint of Trading Bot
stableDescription
Hi, guys and gals,
I like to share a blue print of a general trading bot.
You can change any function in the blueprint to adjust your needs.
Please tell me what you think about this blueprint in the comments.
Cheers!
HaasScript
-- Bot: Bot Blueprint #002
-- Author: romdisc
-- Date: 07/20/2022
-- Update: 07/22/2022
-- still experimenting
EnableHighSpeedUpdates(true)
local bot_name = 'Bot' -- edit this if you have several position algos
local chart_id = 5 -- default chart id from which you can calculate your plots
-- bot functions
-- put all you need into the signal and the exit_condition function
local strategy = function(name, chart_id)
InputGroupHeader(name .. ' - Settings')
-- Input Parameters
-- variables
-- helper functions
-- plot function
local plot = function()
end
-- signal function
-- return: SignalType
local signal = function()
local signal = SignalNone
return signal
end
-- exit condition function
-- return: Boolean
local exit_condition = function()
return true
end
-- safety function
-- return: Boolean
local safety = function()
return false
end
-- bot function
local bot = function(name)
InputGroupHeader(name .. ' - Global')
local wallet_perc = Input('Wallet Amount %', 25)
local poid_save = 'poid - ' .. name
local poid = Load(poid_save, '')
if poid == '' then
poid = CC_market_price_enter(poid, signal(), wallet_perc)
else
if safety()
or exit_condition()
then
poid = CC_market_price_exit(poid, wallet_perc)
end
end
plot()
Save(poid_save, poid)
end
bot(name)
end
strategy(bot_name, chart_id)
3 Comments
Sign in to leave a comment.
The CC_market_price_enter/exit take the poid as the first parameter and return it, if, and only if, this function/command has side effects, hence places an order with a new poid.
This practice guaranties that you will have only one position running with this specific poid.
Therefore, the enter statement might set the poid and the exit statement might reset the poid.
Hi have you put anything like this together in visual editor, would be great for a novice like me to have a blueprint like this as a guide.
For VE it's not really that useful to create any blueprints as every bot you make with it might be very different from the others. I mean, for a single script file, it's not easy to do, but if you split it into multiple scripts where you have the main script and CC's, then its possible, as you can re-use the CC's.
So it is not really a blueprint; you just create yourself a bunch of re-usable CC's and the main script file is the one that changes depending of the bot.