[pshaiBot] Bot Blueprint (ALPHA TEST)

1 142 Views 1 Comment 2 months ago
HTS CLOUDALPHA
  • Here is my take on bot blueprint!!

    It has quite a lot of inner works and I intend on adding more later on. Unfortunately I cannot upload screenshots of the bot… Will add them later!

    Read the full script file carefully to understand what happens and why, I have written lots of comments to help with that.

    Features:

    1. Ease-of-Use – All trade commands have default values so no matter what skill-level you are, you can easily start using this blueprint! If you want to skip/use default input values of any trading commands, simply give it a nil as input.
    2. Customizable “events” – Whether an order is open, filled, partially filled of cancelled, there is a built-in “even” function that fires accordingly. These functions are empty at the moment and be customized to update custom stats or to run any other actions you need.
    3. Chart Plots – Depending if you are running a backtest in the editor or a live bot, the plots done by bot are not forgotten; they are transformed into log messages when running a live bot and plotted normally in editor backtests!
    4. “You cannot exit more than you have” – The exit functions will check your position size before putting through the exit orders. Consider it as “automatic reduce-only”.

    Missing features:

    1. Built-in inputs
    2. Wallet checks
    3. TP and SL systems
    4. Proper custom reports and useful stats

    Example of use (also included at the end of the script):

    
    -- init/load our 'testBot'
    local testBot = bot('testBot')
    
    -- prices and simple moving average with plotting
    local c = ClosePrices()
    local sma = SMA(c, 50)
    testBot.PlotLine(0, 'sma', sma)
    
    -- some simple strategy to control how bot trades
    if CrossOver(c, sma) then
        -- enable long and disable short entries
        testBot.EnableLongs()
        testBot.DisableShorts()
        
        -- exit open short position
        testBot.ExitShort()
    elseif CrossUnder(c, sma) then
        -- enable short and disable long entries
        testBot.DisableLongs()
        testBot.EnableShorts()
    
        -- exit open long position
        testBot.ExitLong()
    end
    
    -- run the inner works of the bot
    testBot.Run()
    
    -- just endlessly entry longs and shorts when allowed
    testBot.GoLong()
    testBot.GoShort()
    
    -- save bot info for next update
    testBot.SaveBot()
    

    Another example:

    
    -- init/load our 'testBot'
    local testBot = bot('testBot')
    
    -- prices and simple moving average with plotting
    local c = ClosePrices()
    local sma = SMA(c, 50)
    testBot.PlotLine(0, 'sma', sma)
    
    -- some simple strategy to control how bot trades
    if CrossOver(c, sma) then
        -- entry long
        testBot.GoLong()
    
        -- exit open short position
        testBot.ExitShort()
    elseif CrossUnder(c, sma) then
        -- entry short
        testBot.GoShort()
    
        -- exit open long position
        testBot.ExitLong()
    end
    
    -- run the inner works of the bot
    testBot.Run()
    
    -- save bot info for next update
    testBot.SaveBot()
    

    Inspired by romdisc’s Blueprint of Trading Bot.

    • This topic was modified 1 month, 2 weeks ago by pshai.
    • This topic was modified 1 month, 2 weeks ago by pshai.
    • This topic was modified 1 month, 2 weeks ago by pshai.
    • This topic was modified 1 month, 2 weeks ago by pshai.
    • This topic was modified 1 month, 2 weeks ago by pshai. Reason: added exit commands
    HaasScript Code
    Sign in or Register to download for free
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free