Firetron’s PlaceSpreadOrder

2 757 Views No Comments 3 years ago
  • Creates a spread of orders.

    Custom Command Dependencies:
    None

    Test Script:

    if not Load('done', false) then
    
      local currentPrice = CurrentPrice()[1]
    
      -- Test Long Spread
    
      Log('==================================================')
      Log('Testing Long Spread, CurrentPrice: '..currentPrice)
      Log('==================================================')
    
      local p = {
        amountList   = {1, 2, 3},
        direction    = 'GoLong',
        orderOptions = {
          market = PriceMarket(),
          type   = NoTimeOutOrderType,
          note   = 'Long Spread',
        },
        priceList    = {currentPrice, SubPercentage(currentPrice, 1), SubPercentage(currentPrice, 1)},
      }
    
      local longOrders = CC_PlaceSpreadOrder(p)
    
      for i = 1, #longOrders do
    
        Log('Long Order ID: '..longOrders[i])
    
      end
    
      -- Test Short Spread
    
      Log('==================================================')
      Log('Testing Short Spread, CurrentPrice: '..currentPrice)
      Log('==================================================')
    
      p.direction         = 'GoShort'
      p.orderOptions.note = 'Short Spread'
      p.priceList         = {currentPrice, AddPercentage(currentPrice, 1), AddPercentage(currentPrice, 1)}
    
      local shortOrders = CC_PlaceSpreadOrder(p)
    
      for i = 1, #shortOrders do
    
        Log('Short Order ID: '..shortOrders[i])
    
      end
    
      Save('done', true)
    
    end
    • This topic was modified 3 years, 4 months ago by Firetron. Reason: Added fibonacci spread type
    • This topic was modified 3 years, 4 months ago by Firetron. Reason: Updated dependency list
    • This topic was modified 3 years, 4 months ago by Firetron. Reason: Added hyperlink to command
    • This topic was modified 3 years, 3 months ago by Firetron. Reason: Renamed SpreadOrder to PlaceSpreadOrder
    • This topic was modified 3 years, 3 months ago by Firetron. Reason: Refactored to outsource creation of amount list and price list
    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