Firetron’s Spot DCA

1 120 Views No Comments 2 months ago
  • Basic dollar cost averaging strategy.
    Buys on Main Interval and sells on Profit Trigger.

    HaasScript Code
    --  ============================================================================
    --    Firetron's Spot DCA
    --
    --    Basic dollar cost averaging strategy.
    --    Buys on Main Interval and sells on Profit Trigger.
    --
    --    Discord:  @FiretronP75
    --    BTC Tips: 14WLDZsrhshcP6qvBarKW8ABACv3iUXEro
    --    ETH Tips: 0xfaaac99fbf11f8f4abc4b3bf079cb2c7a43b5f87
    --  ============================================================================
    
    --  ========================================================
    --    Configuration
    --  ========================================================
    
    EnableHighSpeedUpdates()
    
    --  ========================================================
    --    Variables
    --  ========================================================
    
    local logHRule = '------------------------------------------------------------';
    
    --  ========================================================
    --    Inputs
    --  ========================================================
    
    local group   = 'Script Settings'
    local label   = 'Profit Trigger'
    local tooltip = 'Percent profit that will trigger a sell.'
    
    local profitTrigger = Input(label, 10, tooltip, group)
    
    --  ========================================================
    --    Functions
    --  ========================================================
    
    function Buy ()
    
      Log(logHRule)
      PlaceBuyOrder(CurrentPrice(), TradeAmount())
    
    end
    
    --  ----------------
    
    function Sell ()
    
      if TakeProfit(profitTrigger) then
        Log(logHRule)
        LogWarning('Selling.')
        PlaceSellOrder(CurrentPrice(), GetPositionAmount())
      end
    
    end
    
    --  ========================================================
    --    Execution
    --  ========================================================
    
    Sell()
    OptimizedForInterval(0, Buy)
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free