technical icon indicating copy to clipboard operation
technical copied to clipboard

Using method from Candles, no trades made

Open eveli909 opened this issue 2 years ago • 1 comments

I am trying to calculate the body of the candle and to compare it with the bodies of previous 10 candles. Backtesting results with no trades whatever the number of previous candles is set. Any suggestion why?

`import numpy as np # noqa import pandas as pd # noqa from pandas import DataFrame

from freqtrade.strategy import IStrategy from freqtrade.strategy import CategoricalParameter, DecimalParameter, IntParameter

import talib.abstract as ta import freqtrade.vendor.qtpylib.indicators as qtpylib from technical import candles as candles

class vvv(IStrategy):

INTERFACE_VERSION = 2
minimal_roi = {
#    "60": 0.02,
#    "30": 0.03,
    "0": 0.012
}

stoploss = -0.02

trailing_stop = True
trailing_only_offset_is_reached = True
trailing_stop_positive = 0.001
trailing_stop_positive_offset = 0.005  # Disabled / not configured

buy_rsi = IntParameter(low=1, high=50, default=30, space='buy', optimize=True, load=True)
sell_rsi = IntParameter(low=50, high=100, default=70, space='sell', optimize=True, load=True)

timeframe = '5m'
process_only_new_candles = False
use_sell_signal = False
sell_profit_only = False
ignore_roi_if_buy_signal = False
startup_candle_count: int = 22

order_types = {
    'buy': 'limit',
    'sell': 'limit',
    'stoploss': 'market',
    'stoploss_on_exchange': False
}

order_time_in_force = {
    'buy': 'gtc',
    'sell': 'gtc'
}

plot_config = {
    'main_plot': {
        'tema': {},
        'sar': {'color': 'white'},
    },
    'subplots': {
        "MACD": {
            'macd': {'color': 'blue'},
            'macdsignal': {'color': 'orange'},
        },
        "RSI": {
            'rsi': {'color': 'red'},
        }
    }
}

def informative_pairs(self):
   
    return []

def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
    
    dataframe['real_body'] = candles._body_size(dataframe['open'], dataframe['close'])
   
    return dataframe

def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:

    dataframe.loc[
        (
            (dataframe['real_body'] > dataframe['real_body'].rolling(10).max().shift(1) * 2) &
            (dataframe['volume'] > 0)  # Make sure Volume is not 0
        ),
        'buy'] = 1

    return dataframe

def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
   
    dataframe.loc[
        (
        ),
        'sell'] = 1
    return dataframe

`

eveli909 avatar Oct 05 '21 10:10 eveli909

Your best bet is (as usual) to simply plot both lines and see where they might intersect.

You also require the maximum of 10 previous candles to be twice as high (*2) than the current value - which would suggest a pretty steep decline (which is possible i guess - but still quite limiting).

xmatthias avatar Oct 05 '21 15:10 xmatthias

Closing this as i think your question has been answered.

Feel free to comment below if it's still unclear.

xmatthias avatar Aug 22 '23 05:08 xmatthias