ewoDgtrd

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "ewo_dgtrd"

Variables

This section is empty.

Functions

This section is empty.

Types

type CCISTOCH

type CCISTOCH struct {
	// contains filtered or unexported fields
}

Refer: https://tw.tradingview.com/script/XZyG5SOx-CCI-Stochastic-and-a-quick-lesson-on-Scalping-Trading-Systems/

func NewCCISTOCH

func NewCCISTOCH(i types.Interval, filterHigh, filterLow float64) *CCISTOCH

func (*CCISTOCH) BuySignal

func (inc *CCISTOCH) BuySignal() bool

func (*CCISTOCH) SellSignal

func (inc *CCISTOCH) SellSignal() bool

func (*CCISTOCH) Update

func (inc *CCISTOCH) Update(cloze float64)

type HeikinAshi

type HeikinAshi struct {
	Close  *types.Queue
	Open   *types.Queue
	High   *types.Queue
	Low    *types.Queue
	Volume *types.Queue
}

func NewHeikinAshi

func NewHeikinAshi(size int) *HeikinAshi

func (*HeikinAshi) Print

func (s *HeikinAshi) Print() string

func (*HeikinAshi) Update

func (inc *HeikinAshi) Update(kline types.KLine)

type Strategy

type Strategy struct {
	// Embedded components
	// ===================
	*bbgo.Environment
	bbgo.StrategyController

	// Market of the symbol
	Market types.Market

	// Session is the trading session of this strategy
	Session *bbgo.ExchangeSession

	// Persistence fields
	// ====================
	// Position
	Position *types.Position `json:"position,omitempty" persistence:"position"`

	// ProfitStats
	ProfitStats *types.ProfitStats `json:"profitStats,omitempty" persistence:"profit_stats"`

	// Settings fields
	// =========================
	UseHeikinAshi       bool             `json:"useHeikinAshi"` // use heikinashi kline
	StopLoss            fixedpoint.Value `json:"stoploss"`
	Symbol              string           `json:"symbol"`
	Interval            types.Interval   `json:"interval"`
	UseEma              bool             `json:"useEma"`              // use exponential ma or not
	UseSma              bool             `json:"useSma"`              // if UseEma == false, use simple ma or not
	SignalWindow        int              `json:"sigWin"`              // signal window
	DisableShortStop    bool             `json:"disableShortStop"`    // disable SL on short
	DisableLongStop     bool             `json:"disableLongStop"`     // disable SL on long
	FilterHigh          float64          `json:"cciStochFilterHigh"`  // high filter for CCI Stochastic indicator
	FilterLow           float64          `json:"cciStochFilterLow"`   // low filter for CCI Stochastic indicator
	EwoChangeFilterHigh float64          `json:"ewoChangeFilterHigh"` // high filter for ewo histogram
	EwoChangeFilterLow  float64          `json:"ewoChangeFilterLow"`  // low filter for ewo histogram

	Record bool `json:"record"` // print record messages on position exit point

	KLineStartTime types.Time
	KLineEndTime   types.Time
	// contains filtered or unexported fields
}

func (*Strategy) CancelAll

func (s *Strategy) CancelAll(ctx context.Context)

func (*Strategy) ClosePosition

func (s *Strategy) ClosePosition(ctx context.Context) (*types.Order, bool)

ClosePosition(context.Context) -> (closeOrder *types.Order, ok bool) this will decorate the generated order from NewMarketCloseOrder add do necessary checks if available quantity is zero, will return (nil, true) if any of the checks failed, will return (nil, false) otherwise, return the created close order and true

func (*Strategy) GetLastPrice

func (s *Strategy) GetLastPrice() fixedpoint.Value

func (*Strategy) ID

func (s *Strategy) ID() string

func (*Strategy) Initialize

func (s *Strategy) Initialize() error

func (*Strategy) InstanceID

func (s *Strategy) InstanceID() string

func (*Strategy) PlaceBuyOrder

func (s *Strategy) PlaceBuyOrder(ctx context.Context, price fixedpoint.Value) (*types.Order, *types.Order)

func (*Strategy) PlaceSellOrder

func (s *Strategy) PlaceSellOrder(ctx context.Context, price fixedpoint.Value) (*types.Order, *types.Order)

func (*Strategy) Run

func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error

Trading Rules: - buy / sell the whole asset - SL by atr (lastprice < buyprice - atr) || (lastprice > sellprice + atr) - TP by detecting if there's a ewo pivotHigh(1,1) -> close long, or pivotLow(1,1) -> close short - TP by ma34 +- atr * 2 - TP by (lastprice < peak price - atr) || (lastprice > bottom price + atr) - SL by s.StopLoss (Abs(price_diff / price) > s.StopLoss) - entry condition on ewo(Elliott wave oscillator) Crosses ewoSignal(ma on ewo, signalWindow)

  • buy signal on (crossover on previous K bar and no crossunder on latest K bar)
  • sell signal on (crossunder on previous K bar and no crossunder on latest K bar)

- and filtered by the following rules:

  • buy: buy signal ON, kline Close > Open, Close > ma5, Close > ma34, CCI Stochastic Buy signal
  • sell: sell signal ON, kline Close < Open, Close < ma5, Close < ma34, CCI Stochastic Sell signal

- or entry when ma34 +- atr * 3 gets touched - entry price: latestPrice +- atr / 2 (short,long), close at market price Cancel non-fully filled orders on new signal (either in same direction or not)

ps: kline might refer to heikinashi or normal ohlc

func (*Strategy) SetupIndicators

func (s *Strategy) SetupIndicators(store *bbgo.MarketDataStore)

Setup the Indicators going to be used

func (*Strategy) Subscribe

func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)

type VWEMA

type VWEMA struct {
	PV types.UpdatableSeries
	V  types.UpdatableSeries
}

func (*VWEMA) Index

func (inc *VWEMA) Index(i int) float64

func (*VWEMA) Last

func (inc *VWEMA) Last(i int) float64

func (*VWEMA) Length

func (inc *VWEMA) Length() int

func (*VWEMA) Update

func (inc *VWEMA) Update(kline types.KLine)

func (*VWEMA) UpdateVal

func (inc *VWEMA) UpdateVal(price float64, vol float64)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL