freqtrade / freqtrade-strategies

Free trading strategies for Freqtrade bot
GNU General Public License v3.0
3.44k stars 1.13k forks source link

can I use the following method to write strategy?? #272

Closed gitscamI closed 2 years ago

gitscamI commented 2 years ago
  1. first , caclulate all indicator in populate_indicators(), just like the following:

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:   
     here,caculte all indicator ,get long and short indicator to      longCondition_series and    shortCondition_series 
    dataframe["longCondition"]   = longCondition_series
    dataframe["shortCondition"] = shortCondition_series
    return dataframe**

    2.setup entry_trend:

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                (dataframe['longCondition'] == True)  
            ), ['enter_long', 'enter_tag']] = (1, 'buy_according_longCondition')
    
        dataframe.loc[
            (
                (dataframe['shortCondition'] ==True)  # Make sure Volume is not 0
            ), ['enter_short','enter_tag']] = (1, 'Sell_according_shortCondition')       
        return dataframe
    1. setup exit_trend:
      
      def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
      dataframe.loc[((dataframe['shortCondition'] ==True)),['exit_long', 'exit_tag']] = (1, 'change_to_short')   # exit long when short. signal appreance
      dataframe.loc[((dataframe['longCondition'] ==True)),['exit_short', 'exit_tag']] = (1, 'change_to_long')   # exit short when long signal apprence
      return dataframe

just like the above code , I backtesting ,the strategy trades is not correct, so I want to know if the code logic is correct, thank your reply..
xmatthias commented 2 years ago

return dataframe** seems wrong - but might be a copy/paste typo.

In theory - it'll work - there's however a lot of "what if's" in your very limited sample excerpts.

using dataframe['shortCondition'] ==True assumes this is a boolean. There's no information on the content of this column - so it might just as well be a number between 0 and 1.

Your labels also suggest that you're trying to swap the trade (from long to short within the same candle) - which freqtrade does currently not support.