#!/usr/bin/env python3.8
#import logging
#logging.basicConfig(filename='test.log',level=logging.DEBUG)

import sys, os
from sys import exit
sys.path.append(r'backtest_packages')
sys.path.append(r'../backtest_packages')
sys.path.append(r'../')
sys.path.append(r'quotes_statistic')
sys.path.append(r'../quotes_statistic')
#sys.path.append(r'setups')
#sys.path.append(r'../setups')
import numpy as np
#import talib as ta
#import TailRiskEngine
from backtest_packages.TailRiskEngine import *
#from backtest_packages.backtest_functions import *
#import gc
#from backtest_packages.Benchmark import *

from Benchmark import *
from Ratio import *
from PairSymbol import *
from Filter import *
from CandleStick import *
from ExternalData import *
from ExternalDataSource import *
#from Strategy_all import *
#from Strategy_scanner import *
#from Strategy_development_as import *
from Signals import *
import pandas_ta as pta
from regression_methods import regression_stats_rolling
from plotly_charts import *

#DEFINITIONs of EntrySignals
calc_on = 'Close'
######################################################################################
Setup001
def Setup001():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])
        direction = int(xyz['Direction'])

        df_EntrySignal["Entry1"] = np.where((
            (direction*df_sel_Index[calc_on]         > direction*ta.SMA(df_sel_Index[calc_on], timeperiod = timeperiod))         # close > sma
            & (direction*df_sel_Index[calc_on].shift(1) < direction*ta.SMA(df_sel_Index[calc_on], timeperiod = timeperiod).shift(1))# close_last < sma
        ), 1, 0)

        #benchmark = Benchmark(config, df_sel_Index, 'i_SPX')
        #df_sel_Index = benchmark.get_df_sel_Index()
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['i_SPX_i_abst_sma_percent_200'] > 0,df_EntrySignal["Entry1"],0)
        #print(df_sel_Index.columns.values)
        #print(df_sel_Index['Date'])
        #print(df_sel_Index[['Date']].info())
        #print(df_sel_Index['Date'].describe())
        #exit()
        #print("Anzahl Entry1", df_EntrySignal[(df_EntrySignal['Entry1'] == 1)].shape[0])
        #print(df_EntrySignal[(df_EntrySignal['Entry1'] == 1)])
        # Filter sma200
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-Radius'] <= 5, df_EntrySignal["Entry1"], 0)
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-NewCenterX_50'] <= 100, df_EntrySignal["Entry1"], 0)
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-NewRadius_50'] <= 3, df_EntrySignal["Entry1"], 0)

        #df_EntrySignal["Exit1"] = np.where(
        #        direction * ta.MIN(df_sel_Index['Low'],timeperiod=donchian) < direction * ta.MIN(df_sel_Index['Low'],timeperiod=donchian).shift(1), 1, 0)

        #df_EntrySignal["Exit1"] = np.where((
        #        (direction * df_sel_Index[calc_on] < direction * ta.SMA(df_sel_Index[calc_on],timeperiod=timeperiod)) &                             # close < sma
        #        (direction * df_sel_Index[calc_on].shift(1) > direction * ta.SMA(df_sel_Index[calc_on],timeperiod=timeperiod).shift(1))             # close_last > sma
        #), 1, 0)

        #df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        # pruefen ob Exit in abhängigkeit von Trade Dauer und % gew/verlust geschlossen werden kann
        #df_EntrySignal["Exit1"] = np.where(df_EntrySignal["Entry1"].shift(5), 1, df_EntrySignal["Exit1"])
        #print(df_EntrySignal[(df_EntrySignal['Entry1'] == 1) | (df_EntrySignal['Exit1'] == 1)].tail(30))
        #print(df_sel_Index[['Close','pctChange1d']])
        #exit()

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(int(xyz['Timestop'])) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    # setup_parameter
    xyz = {
        #"Ticker": ['add_WQDV', 'add_IWMO', 'add_IWQU', 'add_IWSZ', 'add_IWVL', 'add_MVOL'],
        # #"Ticker": ['MXWO_O', 'IWSZ.L', 'MVOL.L', 'IWQU.L', 'IWVL.L', 'IWMO.L'],
        #"Type_Strategy": "relativeStrength",
        "Strategy_Code": "L_ST_CA_200",             # Code to have short name and fist information
        "Strategy_Name": "Cross above 200 MOV",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 50,                             # stop the trade afer periods
        "Timestop_delta": [50,75,100],
        "donchian": 20,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Initialstop": -50,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-1,-2, -20, -50],
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 200,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        #"Takeprofit_delta": [30,60],                         # forward optimization: intervals Takeprofit
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 200,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [180, 200,220],                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 1,     # geht ab 1 los #TODO ?
        "number_open_trades_allowed": 1000, # geht ab 1 los #TODO ?
        "days_between_signals": 0,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_200",
        #"Indicator_101": "RS-Ratio",
        #"Indicator_102": "RS-Momentum",
        #"Indicator_101": "i_RSI_5",
        #"Indicator_102": "RS-Radius",
        "Indicator_101": "RSI_14",                     # TODO: ?

    }
    return xyz, Signaler

#Setup II
Setup002
def Setup002():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        threshold = float(xyz['threshold'])
        timeperiod1 = int(xyz['timeperiod1'])
        timeperiod2 = int(xyz['timeperiod2'])
        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_NEWHINYA.csv', 'Close')
        df_sel_Index = externaldata.get_df_sel_Index()
        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_NEWLONYA.csv', 'Close')
        df_sel_Index = externaldata.get_df_sel_Index()
        #print("anzahl Tage:", df_sel_Index.shape[0], "anzahl Tage mit Werten aus external file:", df_sel_Index[~df_sel_Index['add_NEWHINYA'].isna()].shape[0])
        df_sel_Index['Ratio'] = df_sel_Index['add_NEWHINYA'] / df_sel_Index['add_NEWLONYA']
        df_sel_Index['Ratio_sma10'] = df_sel_Index['Ratio'].rolling(timeperiod1).mean()
        df_sel_Index['Ratio_sma40'] = df_sel_Index['Ratio'].rolling(timeperiod2).mean()
        #print(df_sel_Index[['Close', 'add_NEWHINYA', 'add_NEWLONYA', 'Ratio','Ratio_sma10']].head(20))

        df_EntrySignal["Entry1"] = np.where((
             (df_sel_Index['Ratio'].rolling(timeperiod1).mean() >= df_sel_Index['Ratio'].rolling(timeperiod2).mean()) &
             (df_sel_Index['Ratio'].rolling(timeperiod1).mean().shift(1) < df_sel_Index['Ratio'].rolling(timeperiod2).mean().shift(1))
        ), 1, 0)
        df_EntrySignal["Exit1"] = np.where((
                (df_sel_Index['Ratio'].rolling(timeperiod1).mean() < df_sel_Index['Ratio'].rolling(timeperiod2).mean()) &
                (df_sel_Index['Ratio'].rolling(timeperiod1).mean().shift(1) >= df_sel_Index['Ratio'].rolling(timeperiod2).mean().shift(1))
        ), 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "L_ST_CA_50",
        "Strategy_Name": "Cross above 50 MOV",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "FA", # TA = Technical Analysis
        "Strategy_Style": "Trend", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "ST", # ST, MT, LT
        "max_time": 200,
        "donchian": 20, # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Timestop": 100, # nach soviel Tagen wird trade beendet
        "Timestop_delta": [10,20,50,100], # delta wird für forward verwendet
        "threshold": 60,
        "threshold_delta": [2,2.5, 3,4],
        "timeperiod1": 20,
        "timeperiod1_delta": [10, 20, 30, 40, 50],
        "timeperiod2": 200,
        "timeperiod2_delta": [50, 100, 200],
        "Initialstop": -5,
        "Initialstop_delta": 0.5, # delta wird für forward verwendet
        "Takeprofit": 10,
        "Takeprofit_delta": 0.5, # delta wird für forward verwendet
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "first_possible_trade": 20,
        "timeperiod": 20,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1000,
        "days_between_signals": 1, #
        "Indicator_1": "SMA_200", # Indikatoren
        #"Indicator_103": "Ratio",
        "Indicator_101": "Ratio_sma10",
        "Indicator_102": "Ratio_sma40",
        #"Indicator_103": "const_60",
        # "Indicator_103": "5_MOM",

    }
    return xyz, Signaler

Setup_L_MR_2_2
def Setup_L_MR_2_2():
    #mini description:
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        direction = xyz['Direction']
        timeperiod = xyz['timeperiod']
        df_EntrySignal["Entry1"] = np.where((
            (direction * ta.SMA(df_sel_Index[calc_on], timeperiod=timeperiod) < direction * ta.LINEARREG(df_sel_Index[calc_on], timeperiod = timeperiod)) &
            (direction * ta.SMA(df_sel_Index[calc_on], timeperiod=timeperiod).shift(1) >= direction * ta.LINEARREG(df_sel_Index[calc_on],timeperiod = timeperiod).shift(1))
        ), 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        # Developer AS
        "Strategy_Code": "L_ST_LREG_40",
        "Strategy_Name": "Close under LinRegr",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Meanreversion",
        "Timeframe": "ST",
        "max_time": 65,
        "Timestop": 40,
        #"Timestop_delta": 5,
        "donchian": 20,
        #"donchian_delta": 4,
        "Initialstop": -5,
        "Initialstop_delta": [-4,-5],
        "Takeprofit": 15,
        "Takeprofit_delta": [10,15,20],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 20,
        "Rang": 10,
        "timeperiod": 200,
        #"timeperiod_delta": 2,
        "psar_acceleration": 0.02,
        #"psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "donchain",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 999999999,
        "days_between_signals": 10,        "Indicator_1": "SMA_200",
        "Indicator_101": "RSI_5"
    }
    return xyz, Signaler

Setup_TD_Camouflage
def Setup_TD_Camouflage():
    #mini description:
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        direction = xyz['Direction']        #direction *
        df_EntrySignal["Entry1"] = np.where(
            # two closes each less the prior
            (df_sel_Index['Close'] < df_sel_Index['Close'].shift(1)) & # todays close less than prior
            (df_sel_Index['Close'] > df_sel_Index['Open'].shift(1)) & # yesterdays close less than prior
            (df_sel_Index['Low'] < (np.minimum(df_sel_Index['Low'].shift(1), df_sel_Index['Low'].shift(2))))&
            (df_sel_Index['Close'] < (ta.SMA(df_sel_Index[calc_on], timeperiod=50))) # filter
        , 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        # Developer AS
        "Strategy_Code": "td",
        "Strategy_Name": "TendRSI cross 15 15.2",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Momentum",
        "Timeframe": "ST",
        "max_time": 65,
        "Timestop": 5,
        "Timestop_delta": [5,10,20],
        "donchian": 5,
        #"donchian_delta": 2,
        "Initialstop": -3,
        #"Initialstop_delta": 1,
        "Takeprofit": 3,
        #"Takeprofit_delta": 1,
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 5,
        "Rang": 10,
        "timeperiod": 30,
        #"timeperiod_delta": 2,
        "psar_acceleration": 0.02,
        #"psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "psar",
        "Trailingstop_active_after": 5,
        "number_open_trades_per_symbol_allowed": 999999999,
        "days_between_signals": 5,        "Indicator_1": "SMA_200",
        "Indicator_101": "RSI_5"
    }
    return xyz, Signaler


####### Golden Cross


Setup006
def Setup006():
    direction = 1
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        df_EntrySignal["Entry1"] = np.where((
            (direction*ta.SMA(df_sel_Index[calc_on], timeperiod=20) < direction*ta.SMA(df_sel_Index[calc_on], timeperiod=10)) &
            (direction*ta.SMA(df_sel_Index[calc_on], timeperiod=20).shift(1) > direction * ta.SMA(df_sel_Index[calc_on], timeperiod=10).shift(1))
            ), 1, 0)

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "L_MT_GC_10_20",
        "Strategy_Name": "Golden Cross 10 20",
        "Direction": direction,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "Trend", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "MT", # ST, MT, LT
        "Timestop": 1000,
        "Initialstop": -10,
        "Takeprofit": 50,
        "donchian": 20,
        "timeperiod": 20,
        "sl_calc_on": "percent", # percent oder atr, ist noch nicht umgesetzt
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_per_symbol_allowed": 1000, # geht ab 1 los #TODO ?
        "psar_acceleration": 0.02,
        "order_typ": "limit", # next_open oder limit. Bis jetzt nur der Ausstieg, auch Einstieg?
        "first_possible_trade": 100,
        "timeperiod": 100,
        "Indicator_1": "SMA_20",
        "Indicator_2": "SMA_10",
    }
    return xyz, Signaler


Setup007
def Setup007():
    direction = 1
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        df_EntrySignal["Entry1"] = np.where((
            (direction*ta.SMA(df_sel_Index[calc_on], timeperiod=200).shift(1) < direction*ta.SMA(df_sel_Index[calc_on],timeperiod=100).shift(1)) &
            (direction * ta.SMA(df_sel_Index[calc_on], timeperiod=200).shift(2) > direction*ta.SMA(df_sel_Index[calc_on],timeperiod=100).shift(2))
        ), 1, 0)

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        "Strategy_Code": "L_LT_GC_100_200",
        "Strategy_Name": "Golden Cross 100 200",
        "Direction": direction,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "Trend", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "LT", # ST, MT, LT
        "max_time": 50,
        "Timestop": 40,
        "Initialstop": -5,
        "Takeprofit": 7,
        "Takeprofit_delta": [5,7,10],
        "sl_calc_on": "percent", # percent oder atr, ist noch nicht umgesetzt
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000,
        "order_typ": "limit", # next_open oder limit. Bis jetzt nur der Ausstieg, auch Einstieg?
        "first_possible_trade": 200,
        "timeperiod": 200,
        "Indicator_1": "200_SMA",
        "Indicator_2": "100_SMA",
    }
    return xyz, Signaler


######## Break out

Setup008
def Setup008():
    direction = 1
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        df_EntrySignal["Entry1"] = np.where((
            (direction*df_sel_Index[calc_on].rolling(20).max().shift(2) < direction*df_sel_Index[calc_on].shift(1)) &
            (df_sel_Index[calc_on].rolling(20).max().shift(2) == df_sel_Index[calc_on].rolling(20).max().shift(round(20 / 5))) # mindestens timeperiod/5 Tage kein neues Hoch
        ), 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "L_MT_Bm_20",
        "Strategy_Name": "Breakout max 20",
        "Direction": direction,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "Break", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "ST", # ST, MT, LT
        "max_time": 40,
        "Timestop": 20,
        "Initialstop": -4.5,
        "Takeprofit": 5,
        "Takeprofit_delta": [5, 10, 15],
        "sl_calc_on": "percent", # percent oder atr, ist noch nicht umgesetzt
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000,
        "order_typ": "limit", # next_open oder limit. Bis jetzt nur der Ausstieg, auch Einstieg?
        "first_possible_trade": 20,
        "timeperiod": 20,
        "Indicator_1": "20_DON",


    }
    return xyz, Signaler

Setup_L_CH_1_12
def Setup_L_CH_1_12():
    #mini description:

    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        #benchmark = Benchmark(df_sel_Index, 'zzz_SPX')
        #df_sel_Index = benchmark.get_df_sel_Index()
        df_EntrySignal["Entry1"] = np.where(
            (ta.CDLMATCHINGLOW(df_sel_Index['Open'], df_sel_Index['High'], df_sel_Index['Low'], df_sel_Index['Close']) == 100)
            # & (df_sel_Index['vergleich_100'] >= 0)
            #& (df_sel_Index['i_lastHigh_days_50'] >= 25)
            #& (df_sel_Index['zz_distance_tmp_p_10'] >= 0)
            , 1, 0)

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        # Developer AS
        "Strategy_Code": "L_Candle_MATCHINGLOW",
        "Strategy_Name": "Candle_MATCHINGLOW",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen

        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Pattern_C",
        "Timeframe": "ST",
        "max_time": 30,
        "Timestop": 50,
        "Timestop_delta": [10,20,40,60],
        "donchian": 7,
        #"donchian_delta": 2,
        "Initialstop": -6,
        "Initialstop_delta": [-3, -6, -10, -12],
        "Takeprofit": 12,
        "Takeprofit_delta": [6,8,10,15],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 0,
        "Rang": 10,
        "timeperiod": 20,
        #"timeperiod_delta": 2,
        "psar_acceleration": 0.02,
        #"psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "donchain",
        "Trailingstop_active_after": 5,
        "number_open_trades_per_symbol_allowed": 999999999,
        "days_between_signals": 10,

        "Indicator_1": "SMA_200",
        "Indicator_101": "RSI_5",
    }
    return xyz, Signaler



Setup_S_Senti_Trend_add
def Setup_S_Senti_Trend_add():
    #mini description:
    #nur auf SPX oder US Markt, short der in Crash helfen kann

    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        print("111")
        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_ARMS.csv')
        print("222")
        df_sel_Index = externaldata.get_df_sel_Index()

        df_EntrySignal["Entry1"] = np.where((
                                            (ta.SMA(df_sel_Index[calc_on], timeperiod=5) >= ta.SMA(df_sel_Index[calc_on], timeperiod=10))
                                            & (ta.SMA(df_sel_Index[calc_on], timeperiod=5).shift(1) < ta.SMA(df_sel_Index[calc_on], timeperiod=10).shift(1))
                                            & (df_sel_Index[calc_on] < (ta.SMA(df_sel_Index[calc_on], timeperiod=100)))# filter
                                            )
                                            ,1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        # Developer AS
        "Strategy_Code": "L_ST_Senti_ARMS",
        "Strategy_Name": "Setup_L_Senti_ARMS2.2",
        "Direction": -1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen

        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Sentiment",
        "Timeframe": "ST",
        "max_time": 30,
        "Timestop": 15,
        #"Timestop_delta": 3,
        "donchian": 10,
        #"donchian_delta": 2,
        "Initialstop": -4,
        #"Initialstop_delta": 2,
        "Takeprofit": 4,
        "Takeprofit_delta": [4,6,8],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 5,
        "Rang": 10,
        "timeperiod": 7,
        #"timeperiod_delta": 1,
        "psar_acceleration": 0.02,
        #"psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "psar",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 999999999,
        "days_between_signals": 10,

        "Indicator_1": "SMA_200",
        "Indicator_101": "RSI_5"
    }
    return xyz, Signaler


Setup_L_MR_2_3
def Setup_L_MR_2_3():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):

        direction = xyz['Direction']
        timeperiod = xyz['timeperiod']

        df_EntrySignal["Entry1"] = np.where((
            (direction * ta.SMA(df_sel_Index[calc_on], timeperiod=timeperiod) < direction * ta.LINEARREG(df_sel_Index[calc_on], timeperiod = timeperiod))
            & (direction * ta.SMA(df_sel_Index[calc_on], timeperiod=timeperiod).shift(1) >= direction * ta.LINEARREG(df_sel_Index[calc_on],timeperiod = timeperiod).shift(1))
            & (direction*df_sel_Index['abst_sma_percent_200'] > 0)
        ), 1, 0)

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        # Developer AS
        "Strategy_Code": "L_ST_LREG_100",
        "Strategy_Name": "Close under LinRegr",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen

        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Meanreversion",
        "Timeframe": "LT",
        "max_time": 65,
        "Timestop": 40,
        "Timestop_delta": 5,
        "donchian": 20,
        "donchian_delta": 4,
        "Initialstop": -7,
        "Initialstop_delta": 2,
        "Takeprofit": 12,
        "Takeprofit_delta": 5,
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 20,
        "Rang": 10,
        "timeperiod": 100,
        "timeperiod_delta": 2,
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "donchain",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 999999999,
        "days_between_signals": 10,

        "Indicator_1": "SMA_200",
        "Indicator_101": "RSI_5",

    }
    return xyz, Signaler


#Setup
def _Setup_TRE():

    direction = 1
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = xyz['timeperiod'] # var_1_T_period
        timeperiod_signal = xyz['timeperiod_signal']
        slow_sma = xyz['slow_sma']
        fast_sma = xyz['fast_sma']
        signal = xyz['signal']
        data_source = xyz['data_source']
        download_S3 = xyz['download_S3']
        tre = TailRiskEngine(df_EntrySignal, data_source, download_S3)
        tre.calcTailRisk(timeperiod, timeperiod_signal, slow_sma, fast_sma, signal)
        df_EntrySignal = tre.getEntrySignals(df_EntrySignal)
        if 'Date' in df_EntrySignal.columns:
            df_EntrySignal.set_index('Date', inplace=True)
        #print(df_EntrySignal[df_EntrySignal['Entry1'] == 1])
        #exit()
        del tre
        gc.collect()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        "Ticker": ['i_SPX'],
        "Strategy_Code": "TRE",
        "Strategy_Name": "Tail Risk Engine",
        "Direction": direction,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", #TA = Technical Analysis
        "Strategy_Style": "Break", #Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "LT", #ST, MT, LT
        "data_source": "history",    # daily or history
        "download_S3": True, #
        "max_time": 250,
        "Timestop": 500,
        #"Timestop_delta": 50,
        "Initialstop": -50,
        #"Initialstop_delta": 2.5,
        "Takeprofit": 200,
        "Takeprofit_delta": [50,100,200],
        "psar_acceleration": 0.01,
        #"psar_acceleration_delta": 1.5,
        "sl_calc_on": "percent", # percent oder atr, ist noch nicht umgesetzt
        "Trailingstop": "", # psar, donchian
        "Trailingstop_active_after": 8,
        "number_open_trades_allowed": 1000,
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "first_possible_trade": 1,
        "number_open_trades_per_symbol_allowed": 1,
        "days_between_signals": 1, #
        "timeperiod": 200,
        #"timeperiod_delta": 20,
        "timeperiod_signal": 1,
        "timeperiod_signal_delta": [1,2,5,10],
        "slow_sma": 100,
        "slow_sma_delta": [100,120,140,160,180,200],
        "fast_sma": 10,
        "fast_sma_delta": [4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],
        "signal": 50,
        "signal_delta": [20,30,40,50,60,70,80],
        "donchian": 50,
        "Filter": "" # sma200_underlying, sma200_benchmark, TRE

    }
    return xyz, Signaler



Setup_Divergenz
def Setup_Divergenz():
    #mini description:

    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        indicator = xyz['div_indicator']
        candle = CandleStick()
        df_sel_Index = candle.getHammer(df_sel_Index, symbol, 2)
        #df_sel_Index = candle.load_add_data(df_sel_Index, 'i_SPX') # falls ['add_data'] verwendet wird muessen diese Daten hinzugefuegt werden. aber dann werden divergenzen nicht uebernommen???
        df_sel_Index = candle.addMittelfinger(df_sel_Index, symbol, 'Low')

        #indicator = 'obb'
        df_sel_Index, last_div, df_divergenzen = candle.addDivergence(df_sel_Index, symbol, [indicator])
        #df_sel_Index.to_csv('tmp/df_sel_Index.csv')
        #print(df_sel_Index[['div_last_obb','div_last_i_CCI_10']])
        #print(df_sel_Index[df_sel_Index['div_last_i_CCI_10'] == 1].shape[0])
        #exit()
        df_EntrySignal["Entry1"] = np.where((df_sel_Index['div_last_'+indicator] == 1)
                                            #& (df_sel_Index['div_l1_'+indicator].shift(1) > 1)
                                            # & (df_sel_Index['Close'] >= df_sel_Index['Close'].shift(1))
                                            # & (df_sel_Index[indicator] >= df_sel_Index[indicator].shift(1))
                                            # & (df_sel_Index['i_RSI_5'] >= df_sel_Index['i_RSI_5'].shift(1))
                                            #&(df_sel_Index['candle_hammer_TrendClose'] < 10)
                                            #& (df_sel_Index['div_m2'] < -0.2)
                                            #& ((df_sel_Index['div_m1'] >= -2.5) & (df_sel_Index['div_m1'] <= -0.5))
                                            #& (df_sel_Index['div_l2'] > 0)
                                            ,1, 0)

        arr_ind = ['i_CCI_10', 'i_CCI_20', 'i_RSI_5', 'i_RSI_14','obb', 'macdhist','obb']
        arr_ind.remove(indicator)
        df_sel_Index, last_div, df_divergenzen = candle.addDivergence(df_sel_Index, symbol,arr_ind)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index


    xyz = {
        # Developer JZ
        "Strategy_Code": "Setup_Divergenz",
        "Strategy_Name": "Setup_Divergenz",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Breakout",
        "Timeframe": "LT",
        "max_time": 30,
        "div_indicator": 'macdhist',
        "div_indicator_delta": ['i_CCI_10', 'i_CCI_20', 'i_RSI_5', 'i_RSI_14','obb', 'macdhist','obb'],
        "Timestop": 100,
        "Timestop_delta": 3,
        "donchian": 20,
        "donchian_delta": 2,
        "Initialstop": -6,
        "Initialstop_delta": 1,
        "Takeprofit": 12,
        "Takeprofit_delta": 2,
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 5,
        "timeperiod": 100,
        "timeperiod_delta": 5,
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "",
        "Trailingstop_active_after": 5,
        "number_open_trades_per_symbol_allowed": 10,
        "days_between_signals": 0,
        "Indicator_1": "SMA_200",
        "Indicator_101": "macdhist",
        "Indicator_102": "i_RSI_5",
    }
    return xyz, Signaler


Setup_everyWeek
def Setup_everyWeek():

    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])
        direction = int(xyz['Direction'])
        df_EntrySignal["Entry1"] = np.where((
            df_sel_Index['week'].shift(-1) != df_sel_Index['week'].shift(0)
        ), 1, 0)
        #df_EntrySignal["Exit1"] = np.where((
        #    df_sel_Index['week'].shift(-1) != df_sel_Index['week'].shift(0)
        #), 1, 0)

        #print(df_EntrySignal[df_EntrySignal['Entry1'] == 1])
        #exit()
        return df_EntrySignal, df_sel_Index
    xyz = {
        # Developer JZ
        "Strategy_Code": "everyWeek",
        "Strategy_Name": "everyWeek",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Breakout",
        "Timeframe": "LT",
        "max_time": 30,
        "Timestop": 3,
        "Timestop_delta": 3,
        "donchian": 20,
        "donchian_delta": 2,
        "Initialstop": -10,
        "Initialstop_delta": [-2,-3,-4,-8],
        "Takeprofit": 30,
        "Takeprofit_delta": [4, 8, 12, 16],
        "order_typ": "close",
        "sl_calc_on": "percent",
        "first_possible_trade": 5,
        "timeperiod": 100,
        "timeperiod_delta": 5,
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "",
        "Trailingstop_active_after": 5,
        "number_open_trades_per_symbol_allowed": 10,
        "days_between_signals": 0,
        "Indicator_1": "SMA_200",
        "Indicator_101": "macdhist",
        "Indicator_102": "i_RSI_5",
    }
    return xyz, Signaler

Setup_SMA50
def Setup_SMA50():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])
        direction = int(xyz['Direction'])
        #benchmark = Benchmark(df_sel_Index, 'i_SPX')
        #df_sel_Index = benchmark.get_df_sel_Index()
        df_EntrySignal["Entry1"] = np.where((
            (direction*df_sel_Index[calc_on]         > direction*ta.SMA(df_sel_Index[calc_on], timeperiod = timeperiod))                         # close > sma
            & (direction*df_sel_Index[calc_on].shift(1) < direction*ta.SMA(df_sel_Index[calc_on], timeperiod = timeperiod).shift(1))                 # close_last < sma
        ), 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    # setup_parameter
    xyz = {
        #"Ticker": ['add_WQDV', 'add_IWMO', 'add_IWQU', 'add_IWSZ', 'add_IWVL', 'add_MVOL'],
        # #"Ticker": ['MXWO_O', 'IWSZ.L', 'MVOL.L', 'IWQU.L', 'IWVL.L', 'IWMO.L'],
        #"Type_Strategy": "relativeStrength",
        "Strategy_Code": "L_ST_CA_50",             # Code to have short name and fist information
        "Strategy_Name": "Cross above 50 MOV",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 50,                             # stop the trade afer periods
        "Timestop_delta": [50],
        "donchian": 20,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Initialstop": -10,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-10], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 25,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        #"Takeprofit_delta": [30,60],                         # forward optimization: intervals Takeprofit
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 50,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [50],                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 100,     # geht ab 1 los #TODO ?
        "days_between_signals": 5,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_50", # TODO: ?
        #"Indicator_101": "RS-Ratio",
        #"Indicator_102": "RS-Momentum",
        #"Indicator_101": "i_RSI_5",
        #"Indicator_102": "RS-Radius",
        "Indicator_101": "momentum_100",                     # TODO: ?

    }
    return xyz, Signaler


SetupBreakout100
def SetupBreakout100():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        direction = xyz['Direction']
        timeperiod = int(xyz['timeperiod'])
        timeperiod_obv = int(xyz['timeperiod_obv'])
        anz_davor = int(xyz['anz_davor'])
        vol10 = float(xyz['vol10'])
        vol50 = float(xyz['vol50'])
        calc_on = 'Close'
        benchmark = Benchmark(config, df_sel_Index, 'i_SPX')
        df_sel_Index = benchmark.get_df_sel_Index()

        #if 'i_lastHigh_days_Close_davor_100' not in df_sel_Index.columns:
        df_sel_Index['i_lastHigh_days_Close_davor_100'] = 100 - df_sel_Index["Close"].rolling(100).apply(lambda x: x.argmax()).shift(2)
        #print(df_sel_Index.columns.values)
        #exit()
        df_EntrySignal["Entry1"] = np.where(
            (direction*df_sel_Index[calc_on].rolling(timeperiod).max().shift(1) < direction*df_sel_Index[calc_on])
            & (direction*df_sel_Index[calc_on].rolling(timeperiod).max().shift(2) > direction*df_sel_Index[calc_on].shift(1))
            & (df_sel_Index['i_lastHigh_days_Close_davor_100'] >= anz_davor)
            #& (df_sel_Index['i_vol_m_10'] >= vol10)
            & (df_sel_Index['i_vol_m_50'] >= vol50)
            & (df_sel_Index['i_SPX_i_abst_sma_percent_200'] >= -2)
            , 1,0)

        if 'donchian_100' not in df_sel_Index.columns:
            df_sel_Index['donchian_100'] = df_sel_Index[calc_on].rolling(timeperiod).max()
        if 'i_donchian_100' not in df_sel_Index.columns:
            df_sel_Index['i_donchian_100'] = df_sel_Index[calc_on].rolling(timeperiod).max()

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        # Developer AS
        "Strategy_Code": "breakout_donchian100",
        "Strategy_Name": "breakout_donchian100",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Breakout",
        "Timeframe": "LT",
        #"filter_ml": 'forward_steps_Setup_L_B_1_4',
        #"filter_cut": 'filter_cut_rules_Setup_L_B_1_4',
        "anz_davor": 15,
        "anz_davor_delta": [5, 10, 15, 20, 25],
        "vol10": -10,
        "vol10_delta": [-10, 0, 0.1, 0.2, 0.3],
        "vol50": -10,
        "vol50_delta": [-10, 0, 0.01, 0.02],
        "Timestop": 40,
        "Timestop_delta": [20, 30, 40, 50, 75, 100],
        "donchian": 20,
        "donchian_delta": [5, 10, 20],
        "Initialstop": -6,
        "Initialstop_delta": [-4, -6,- 9, -12],
        "Takeprofit": 12,
        "Takeprofit_delta": [6,9,12,18],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 100,
        "timeperiod": 100,
        "timeperiod_delta": 5,
        "timeperiod_obv": 100,
        "timeperiod_obv_delta": [2,3,4,5,6],
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 10,
        #"number_open_trades_allowed": 5, # all_trades wird damit abgespeichert, max_parallel_trade2 nur portfolio2
        "days_between_signals": 10,
        "Indicator_1": "donchian_100",
        #"Indicator_2": "donchian_high_100",
        "Indicator_101": "i_SPX_Close",
        #"Indicator_101": "i_lastHigh_days_Close_davor_100",
        #"Indicator_102": "i_lastHigh_days_Close_100"
    }
    return xyz, Signaler

def _SetupIntraday():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])
        direction = int(xyz['Direction'])
        #benchmark = Benchmark(config, df_sel_Index, 'i_SPX')
        #df_sel_Index = benchmark.get_df_sel_Index()
        df_EntrySignal["Entry1"] = np.where((
            #(direction*df_sel_Index[calc_on]         > direction*ta.SMA(df_sel_Index[calc_on], timeperiod = timeperiod))                         # close > sma
            #& (direction*df_sel_Index[calc_on].shift(1) < direction*ta.SMA(df_sel_Index[calc_on], timeperiod = timeperiod).shift(1))                 # close_last < sma
            (direction*df_sel_Index['i_RSI_14']         >= 30)
            & (direction*df_sel_Index['i_RSI_14'].shift(1) < 30)
            & (df_sel_Index['hour'] >= 20)
            #& (direction*df_sel_Index[calc_on] > direction*ta.SMA(df_sel_Index[calc_on], timeperiod = 200))                 # close_last < sma
        ), 1, 0)

        #print(df_sel_Index['hour'].tail(25))
        #print(df_sel_Index[['Date', 'day']])

        #exit()
        #print("Anzahl Entry1", df_EntrySignal[(df_EntrySignal['Entry1'] == 1)].shape[0])
        # Filter sma200
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-Radius'] <= 5, df_EntrySignal["Entry1"], 0)
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-NewCenterX_50'] <= 100, df_EntrySignal["Entry1"], 0)
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-NewRadius_50'] <= 3, df_EntrySignal["Entry1"], 0)

        #df_EntrySignal["Exit1"] = np.where(
        #        direction * ta.MIN(df_sel_Index['Low'],timeperiod=donchian) < direction * ta.MIN(df_sel_Index['Low'],timeperiod=donchian).shift(1), 1, 0)

        #df_EntrySignal["Exit1"] = np.where((
        #        (direction * df_sel_Index[calc_on] < direction * ta.SMA(df_sel_Index[calc_on],timeperiod=timeperiod)) &                             # close < sma
        #        (direction * df_sel_Index[calc_on].shift(1) > direction * ta.SMA(df_sel_Index[calc_on],timeperiod=timeperiod).shift(1))             # close_last > sma
        #), 1, 0)

        # pruefen ob Exit in abhängigkeit von Trade Dauer und % gew/verlust geschlossen werden kann
        #df_EntrySignal["Exit1"] = np.where(df_EntrySignal["Entry1"].shift(5), 1, df_EntrySignal["Exit1"])
        #print(df_EntrySignal[(df_EntrySignal['Entry1'] == 1) | (df_EntrySignal['Exit1'] == 1)].tail(30))
        #print(df_sel_Index[['Close','pctChange1d']])
        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    # setup_parameter
    xyz = {
        #"Ticker": ['add_WQDV', 'add_IWMO', 'add_IWQU', 'add_IWSZ', 'add_IWVL', 'add_MVOL'],
        # #"Ticker": ['MXWO_O', 'IWSZ.L', 'MVOL.L', 'IWQU.L', 'IWVL.L', 'IWMO.L'],
        #"Type_Strategy": "relativeStrength",
        "Strategy_Code": "L_ST_CA_50",             # Code to have short name and fist information
        "Strategy_Name": "Cross above 50 MOV",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 50,                             # stop the trade afer periods
        "Timestop_delta": [50],
        "donchian": 20,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Initialstop": -1.5,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-10], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 3,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        #"Takeprofit_delta": [30,60],                         # forward optimization: intervals Takeprofit
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 50,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [50],                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 100,     # geht ab 1 los #TODO ?
        "days_between_signals": 5,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_200", # TODO: ?
        #"Indicator_101": "RS-Ratio",
        #"Indicator_102": "RS-Momentum",
        #"Indicator_101": "i_RSI_5",
        #"Indicator_102": "RS-Radius",
        "Indicator_101": "RSI_14",                     # TODO: ?

    }
    return xyz, Signaler

def _Setup_Pair_short():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        pair = PairSymbol()
        symbol2 = pair.getSymbol2(symbol)
        #print("symbols short:", symbol, symbol2)
        if symbol2 != '':
            if 'ratio' not in df_sel_Index.columns:
                ratio = Ratio(df_sel_Index, config.get("MODUL2", 'directory_modul2'), symbol, symbol2)
                df_sel_Index = ratio.get_df_sel_Index()
                df_EntrySignal = pd.DataFrame(index=df_sel_Index.index)
                df_EntrySignal["Date"] = df_sel_Index["Date"]
                df_EntrySignal["Date"] = pd.to_datetime(df_EntrySignal["Date"])
            #print(df_sel_Index[['Date', 'Close_SILVER', 'Close_GOLD','ratio','1_ratio']].head(10))
            #print(df_sel_Index)
            #print(df_sel_Index[['Date', 'ratio']])
            #exit()
            period_stoch = int(xyz['period_stoch'])
            period_stress_mean = int(xyz['period_stress_mean'])
            period_mean = 1
            df_sel_Index['range1'] = df_sel_Index['High'].rolling(period_stoch).max() - df_sel_Index['Low'].rolling(period_stoch).min()
            df_sel_Index['range2'] = df_sel_Index['High_' + symbol2].rolling(period_stoch).max() - df_sel_Index['Low_' + symbol2].rolling(period_stoch).min()
            df_sel_Index['stoch1'] = ((df_sel_Index['Close'] - df_sel_Index['Low'].rolling(period_stoch).min()) / df_sel_Index['range1']).rolling(period_mean).mean()
            df_sel_Index['stoch2'] = ((df_sel_Index['Close_' + symbol2] - df_sel_Index['Low_' + symbol2].rolling(period_stoch).min()) / df_sel_Index['range2']).rolling(period_mean).mean()
            df_sel_Index['diff'] = (df_sel_Index['stoch1'] - df_sel_Index['stoch2']).rolling(period_stress_mean).mean()
            df_sel_Index['range_diff'] = df_sel_Index['diff'].rolling(period_stoch).max() - df_sel_Index['diff'].rolling(period_stoch).min()
            df_sel_Index['stress'] = (df_sel_Index['diff'] - df_sel_Index['diff'].rolling(period_stoch).min()) / df_sel_Index['range_diff']

            direction = xyz['Direction']
            threshold = xyz['threshold']

            period_bb = int(xyz['period_bb'])
            period_bb_std = float(xyz['period_bb_std'])
            bb_stdev_p = int(xyz['bb_stdev_p'])
            df_sel_Index['bb_middle'] = df_sel_Index['ratio'].rolling(period_bb).mean()
            df_sel_Index['bb_std'] = df_sel_Index['ratio'].rolling(period_bb).std()
            #df_sel_Index['bb_upper'], df_sel_Index['bb_middle'], df_sel_Index['bb_lower'] = ta.BBANDS(df_sel_Index['ratio'],timeperiod=20,nbdevup=2, nbdevdn=2,matype=0)
            df_sel_Index['bb_upper'] = df_sel_Index['bb_middle'] + 2*df_sel_Index['bb_std']
            df_sel_Index['bb_lower'] = df_sel_Index['bb_middle'] - 2 * df_sel_Index['bb_std']
            #df_sel_Index['bb_stdev'] = 2 * (df_sel_Index['ratio'] - df_sel_Index['bb_middle']) / (df_sel_Index['bb_upper'] - df_sel_Index['bb_middle'])

            df_sel_Index['bb_stdev'] = 2 * (df_sel_Index['ratio'] - df_sel_Index['bb_middle']) / (df_sel_Index['bb_upper'] - df_sel_Index['bb_middle'])
            df_sel_Index['bb_stdev_p'] = 100*(df_sel_Index['ratio'] - df_sel_Index['bb_middle'])/df_sel_Index['ratio']
            df_sel_Index['1_ratio'] = 1 / df_sel_Index['ratio']

            setup = 'ratio'
            setup = 'stochastic'
            if setup == 'ratio':
                df_EntrySignal["Entry1"] = np.where(
                    (df_sel_Index['bb_stdev'].shift(1) > period_bb_std)
                    & (df_sel_Index['bb_stdev'] <= period_bb_std)
                    #& (abs(df_sel_Index['bb_stdev_p']) >= bb_stdev_p)
                    , 1, 0)
                df_EntrySignal["Exit1"] = np.where((df_sel_Index['bb_stdev'] <= 0), 1, 0)
                df_EntrySignal["Exit1"] = 0
            elif setup == 'stochastic':
                if direction == -1:
                    df_EntrySignal["Entry1"] = np.where(
                        (df_sel_Index['stress'] >= 1 - threshold)
                        & (df_sel_Index['stress'].shift(1) < 1 - threshold)
                        , 1, 0)
                    df_EntrySignal["Exit1"] = np.where(
                        (df_sel_Index['stress'] < threshold)
                        #| (df_sel_Index['stress'] > df_sel_Index['stress'].shift(1))
                        , 1, 0)
                    #df_EntrySignal["Exit1"] = 0
        else:
            df_EntrySignal["Entry1"] = 0
            df_EntrySignal["Exit1"] = 0

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index


    xyz = {
        # Developer JZ
        "Strategy_Code": "pair_trade short",
        "Strategy_Name": "pair_trade short",
        "Direction": -1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Breakout",
        "Timeframe": "LT",
        #"filter_ml": 'forward_steps_Setup_L_B_1_4',
        #"filter_cut": 'filter_cut_rules_Setup_L_B_1_4',
        "period_bb": 50,
        "period_bb_delta": [10, 20,50,100],
        "period_bb_std": 2,
        "period_bb_std_delta": [1.5, 1.75, 2, 2.25, 2.5, 3],
        "bb_stdev_p": 0,
        "bb_stdev_p_delta": [0, 2, 4, 6, 8, 10],

        "period_stoch": 60,
        "period_stoch_delta": [10,20,30,40,50,60,80,100],
        "period_stress_mean": 1,
        "period_stress_mean_delta": [1, 2, 5, 10],
        "threshold": 0.15,
        "threshold_delta": [0.05, 0.1, 0.15, 0.2],
        "Timestop": 100,
        "Timestop_delta": [20, 30, 40, 50, 75, 100,200,300],
        "donchian": 50,
        "donchian_delta": [10, 20, 50, 100],
        "Initialstop": -10,
        "Initialstop_delta": [-2.5, -5, -10,- 20],
        "Takeprofit": 20,
        "Takeprofit_delta": [-2.5, 5,10,20,40],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 100,
        "timeperiod": 100,
        "timeperiod_delta": [20,50,100,200],
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 100,
        #"number_open_trades_allowed": 5, # all_trades wird damit abgespeichert, max_parallel_trade2 nur portfolio2
        "days_between_signals": 5,
        #"Indicator_1": "donchian_high_100",
        "Indicator_101": "stress",
        "Indicator_102": "stoch1",
        "Indicator_103": "stoch2",
        #"Indicator_101": "ratio",
        #"Indicator_102": "bb_upper",
        #"Indicator_103": "bb_lower",
    }
    return xyz, Signaler

def _Setup_Pair_long():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        pair = PairSymbol()
        symbol2 = pair.getSymbol2(symbol)
        #print("symbols long", symbol, symbol2)
        if symbol2 != '':
            if 'ratio' not in df_sel_Index.columns:
                ratio = Ratio(df_sel_Index, config.get("MODUL2", 'directory_modul2'), symbol, symbol2)
                df_sel_Index = ratio.get_df_sel_Index()
                df_EntrySignal = pd.DataFrame(index=df_sel_Index.index)
                df_EntrySignal["Date"] = df_sel_Index["Date"]
                df_EntrySignal["Date"] = pd.to_datetime(df_EntrySignal["Date"])
            #print(df_sel_Index[['Date', 'Close_SILVER', 'Close_GOLD', 'ratio', '1_ratio']].head(10))
            period_stoch = int(xyz['period_stoch'])
            period_stress_mean = int(xyz['period_stress_mean'])
            period_mean = 1
            df_sel_Index['range1'] = df_sel_Index['High'].rolling(period_stoch).max() - df_sel_Index['Low'].rolling(period_stoch).min()
            df_sel_Index['range2'] = df_sel_Index['High_' + symbol2].rolling(period_stoch).max() - df_sel_Index['Low_' + symbol2].rolling(period_stoch).min()
            df_sel_Index['stoch1'] = ((df_sel_Index['Close'] - df_sel_Index['Low'].rolling(period_stoch).min()) / df_sel_Index['range1']).rolling(period_mean).mean()
            df_sel_Index['stoch2'] = ((df_sel_Index['Close_' + symbol2] - df_sel_Index['Low_' + symbol2].rolling(period_stoch).min()) / df_sel_Index['range2']).rolling(period_mean).mean()
            df_sel_Index['diff'] = (df_sel_Index['stoch1'] - df_sel_Index['stoch2']).rolling(period_stress_mean).mean()
            df_sel_Index['range_diff'] = df_sel_Index['diff'].rolling(period_stoch).max() - df_sel_Index['diff'].rolling(period_stoch).min()
            df_sel_Index['stress'] = (df_sel_Index['diff'] - df_sel_Index['diff'].rolling(period_stoch).min()) / df_sel_Index['range_diff']

            direction = xyz['Direction']
            threshold = xyz['threshold']

            period_bb = int(xyz['period_bb'])
            period_bb_std = float(xyz['period_bb_std'])
            bb_stdev_p = int(xyz['bb_stdev_p'])

            df_sel_Index['bb_middle'] = df_sel_Index['ratio'].rolling(period_bb).mean()
            df_sel_Index['bb_std'] = df_sel_Index['ratio'].rolling(period_bb).std()
            df_sel_Index['bb_upper'] = df_sel_Index['bb_middle'] + 2 * df_sel_Index['bb_std']
            df_sel_Index['bb_lower'] = df_sel_Index['bb_middle'] - 2 * df_sel_Index['bb_std']
            df_sel_Index['bb_stdev'] = 2 * (df_sel_Index['ratio'] - df_sel_Index['bb_middle']) / (df_sel_Index['bb_upper'] - df_sel_Index['bb_middle'])
            df_sel_Index['bb_stdev_p'] = 100 * (df_sel_Index['ratio'] - df_sel_Index['bb_middle']) / df_sel_Index['ratio']
            df_sel_Index['1_ratio'] = 1/df_sel_Index['ratio']
            #print(df_sel_Index[['Date', 'ratio', '1_ratio', 'bb_upper', 'bb_middle', 'bb_lower', 'bb_stdev', 'bb_stdev_p']].iloc[20:80])
            setup = 'ratio'
            setup = 'stochastic'
            if setup == 'ratio':
                df_EntrySignal["Entry1"] = np.where(
                    (df_sel_Index['bb_stdev'].shift(1) < -period_bb_std)
                    & (df_sel_Index['bb_stdev'] >= -period_bb_std)
                    #& (abs(df_sel_Index['bb_stdev_p']) >= bb_stdev_p)
                    , 1, 0)
                df_EntrySignal["Exit1"] = np.where((df_sel_Index['bb_stdev'] >= 0), 1, 0)
                df_EntrySignal["Exit1"] = 0
            elif setup == 'stochastic':
                if direction == 1:
                    df_EntrySignal["Entry1"] = np.where(
                        (df_sel_Index['stress'] <= threshold)
                        & (df_sel_Index['stress'].shift(1) > threshold)
                        , 1,0)
                    df_EntrySignal["Exit1"] = np.where(
                        (df_sel_Index['stress'] > 0.5)
                        #| (df_sel_Index['stress'] < df_sel_Index['stress'].shift(1))
                        , 1, 0)
                    #df_EntrySignal["Exit1"] = 0

        else:
            df_EntrySignal["Entry1"] = 0
            df_EntrySignal["Exit1"] = 0

        #df_sel_Index.to_csv('./tmp/ratio_'+symbol+'.txt', sep=',')
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        # Developer JZ
        "Strategy_Code": "pair_trade long",
        "Strategy_Name": "pair_trade long",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Breakout",
        "Timeframe": "LT",
        #"filter_ml": 'forward_steps_Setup_L_B_1_4',
        #"filter_cut": 'filter_cut_rules_Setup_L_B_1_4',
        "period_bb": 50,
        "period_bb_delta": [10, 20, 50, 100],
        "period_bb_std": 2,
        "period_bb_std_delta": [1.5, 1.75, 2, 2.25, 2.5, 3],
        "bb_stdev_p": 0,
        "bb_stdev_p_delta": [0, 2, 4, 6, 8, 10],
        "period_stoch": 60,
        "period_stoch_delta": [10, 30, 60, 90],
        "period_stress_mean": 1,
        "period_stress_mean_delta": [1, 2, 5, 10],
        "threshold": 0.15,
        "threshold_delta": [0.1, 0.15],
        "Timestop": 50,
        "Timestop_delta": [20, 30, 40, 50, 75, 100, 200, 300],
        "donchian": 50,
        "donchian_delta": [10, 20, 50, 100],
        "Initialstop": -10,
        "Initialstop_delta": [-5, -10, - 20, -30],
        "Takeprofit": 10,
        "Takeprofit_delta": [5, 10, 20, 30],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 100,
        "timeperiod": 100,
        "timeperiod_delta": [20, 50, 100, 200],
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 100,
        # "number_open_trades_allowed": 5, # all_trades wird damit abgespeichert, max_parallel_trade2 nur portfolio2
        "days_between_signals": 5,
        #"Indicator_1": "donchian_high_100",
        "Indicator_101": "stress",
        "Indicator_102": "stoch1",
        "Indicator_103": "stoch2",
        #"Indicator_101": "ratio",
        #"Indicator_102": "bb_upper",
        #"Indicator_103": "bb_lower",
    }
    return xyz, Signaler

Setup_Random
def Setup_Random():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        direction = xyz['Direction']
        timeperiod = xyz['timeperiod']
        calc_on = 'Close'
        df_EntrySignal["Entry1"] = np.where(
            (direction*df_sel_Index[calc_on].rolling(timeperiod).max().shift(1) < direction*df_sel_Index[calc_on])
            & (direction*df_sel_Index[calc_on].rolling(timeperiod).max().shift(2) > direction*df_sel_Index[calc_on].shift(1))
            & (df_sel_Index['i_lastHigh_days_Close_davor_100'] >= 15)
            , 1,0)

        signals = Signals(config, df_EntrySignal, df_sel_Index, symbol)
        df_EntrySignal = signals.getRandomSignals()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        # Developer AS
        "Strategy_Code": "Random",
        "Strategy_Name": "Random",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Breakout",
        "Timeframe": "LT",
        #"filter_ml": 'forward_steps_Setup_L_B_1_4',
        #"filter_cut": 'filter_cut_rules_Setup_L_B_1_4',
        "Timestop": 40,
        "Timestop_delta": [20, 30, 40, 50, 75, 100],
        "donchian": 20,
        "donchian_delta": [5, 10, 20],
        "Initialstop": -6,
        "Initialstop_delta": [-4, -6,- 9, -12],
        "Takeprofit": 12,
        "Takeprofit_delta": [6,9,12,18],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 100,
        "timeperiod": 100,
        "timeperiod_delta": 5,
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 10,
        #"number_open_trades_allowed": 5, # all_trades wird damit abgespeichert, max_parallel_trade2 nur portfolio2
        "days_between_signals": 10,
        "Indicator_1": "donchian_high_100",

        #"Indicator_101": "i_lastHigh_days_Close_davor_100",
        #"Indicator_102": "i_lastHigh_days_Close_100"
    }
    return xyz, Signaler
Setup_BuyHold
def Setup_BuyHold():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        direction = xyz['Direction']
        timeperiod = xyz['timeperiod']
        calc_on = 'Close'
        df_EntrySignal["Entry1"] = 0
        df_EntrySignal["Exit1"] = 0
        df_EntrySignal["Entry1"].iloc[10] = 1
        df_EntrySignal["Exit1"].iloc[-1] = 1

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        # Developer AS
        "Strategy_Code": "BuyHold",
        "Strategy_Name": "BuyHold",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "BuyHold",
        "Timeframe": "LT",
        #"filter_ml": 'forward_steps_Setup_L_B_1_4',
        #"filter_cut": 'filter_cut_rules_Setup_L_B_1_4',
        "Timestop": 400000,
        "Timestop_delta": [20, 30, 40, 50, 75, 100],
        "donchian": 20,
        "donchian_delta": [5, 10, 20],
        "Initialstop": -100,
        "Initialstop_delta": [-4, -6,- 9, -12],
        "Takeprofit": 12000,
        "Takeprofit_delta": [6,9,12,18],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 100,
        "timeperiod": 100,
        "timeperiod_delta": 5,
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 10,
        #"number_open_trades_allowed": 5, # all_trades wird damit abgespeichert, max_parallel_trade2 nur portfolio2
        "days_between_signals": 10,
        "Indicator_1": "donchian_high_100",

        #"Indicator_101": "i_lastHigh_days_Close_davor_100",
        #"Indicator_102": "i_lastHigh_days_Close_100"
    }
    return xyz, Signaler

SetupSupertrend
def SetupSupertrend():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        direction = xyz['Direction']
        timeperiod = xyz['timeperiod']
        calc_on = 'Close'
        #timeperiod = 50
        df_sel_Index[['supertrend_'+str(timeperiod), 'supertrend_'+str(timeperiod)+'d', 'supertrend_'+str(timeperiod)+'l', 'supertrend_'+str(timeperiod)+'s']] = pta.supertrend(df_sel_Index['High'], df_sel_Index['Low'], df_sel_Index['Close'], timeperiod, 3)
        df_EntrySignal["Entry1"] = np.where(
            (df_sel_Index['supertrend_'+str(timeperiod)].shift(1) > df_sel_Index[calc_on].shift(1))
            & (df_sel_Index['supertrend_'+str(timeperiod)] < df_sel_Index[calc_on])
            , 1,0)
        df_EntrySignal["Exit1"] = np.where(
            (df_sel_Index['supertrend_'+str(timeperiod)].shift(1) < df_sel_Index[calc_on].shift(1))
            & (df_sel_Index['supertrend_'+str(timeperiod)] > df_sel_Index[calc_on])
            , 1, 0)

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        # Developer AS
        "Strategy_Code": "Random",
        "Strategy_Name": "Random",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices", # Löschen
        "Analysis_Philosphy": "TA",
        "Strategy_Style": "Breakout",
        "Timeframe": "LT",
        #"filter_ml": 'forward_steps_Setup_L_B_1_4',
        #"filter_cut": 'filter_cut_rules_Setup_L_B_1_4',
        "Timestop": 40,
        "Timestop_delta": [20, 30, 40, 50, 75, 100],
        "donchian": 20,
        "donchian_delta": [5, 10, 20],
        "Initialstop": -10,
        "Initialstop_delta": [-5, -6,- 7, -8, -9, -10],
        "Takeprofit": 25,
        "Takeprofit_delta": [10,20,30,50,100,200],
        "order_typ": "next_open",
        "sl_calc_on": "percent",
        "first_possible_trade": 100,
        "timeperiod": 20,
        "timeperiod_delta": [1,2,3,4,5,6,7,8,9,10,20,30,40,50,100],
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,
        "psar_acceleration_multiply": 1,
        "Trailingstop": "",
        "Trailingstop_active_after": 10,
        "number_open_trades_per_symbol_allowed": 10,
        #"number_open_trades_allowed": 5, # all_trades wird damit abgespeichert, max_parallel_trade2 nur portfolio2
        "days_between_signals": 10,
        "Indicator_1": "supertrend_7",
        "Indicator_2": "supertrend_50",
        #"Indicator_101": "i_lastHigh_days_Close_davor_100",
        #"Indicator_102": "i_lastHigh_days_Close_100"
    }
    return xyz, Signaler


SetupSMA
def SetupSMA():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])
        donchian = int(xyz['donchian'])
        direction = int(xyz['Direction'])
        factor_sma_band = (xyz['factor_sma_band'])
        #benchmark = Benchmark(config, df_sel_Index, 'i_SPX')
        #df_sel_Index = benchmark.get_df_sel_Index()
        df_EntrySignal["Entry1"] = np.where((
            (direction*df_sel_Index[calc_on]         > direction*ta.SMA(df_sel_Index[calc_on], timeperiod = timeperiod) * factor_sma_band)                         # close > sma
            & (direction*df_sel_Index[calc_on].shift(1) < direction*ta.SMA(df_sel_Index[calc_on], timeperiod = timeperiod).shift(1) * factor_sma_band)                 # close_last < sma
            #& (df_sel_Index['vergleich_100'] >= 0)
            #& (direction*df_sel_Index[calc_on]         > direction*ta.SMA(df_sel_Index[calc_on], timeperiod = 200))                         # Filter
        ), 1, 0)
        # Filter sma200
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-Radius'] <= 5, df_EntrySignal["Entry1"], 0)
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-NewCenterX_50'] <= 100, df_EntrySignal["Entry1"], 0)
        #df_EntrySignal["Entry1"] = np.where(df_sel_Index['RS-NewRadius_50'] <= 3, df_EntrySignal["Entry1"], 0)


        #df_EntrySignal["Exit1"] = np.where((
        #        (direction * df_sel_Index[calc_on] < direction * ta.SMA(df_sel_Index[calc_on],timeperiod=timeperiod)) &                             # close < sma
        #        (direction * df_sel_Index[calc_on].shift(1) > direction * ta.SMA(df_sel_Index[calc_on],timeperiod=timeperiod).shift(1))             # close_last > sma
        #), 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    # setup_parameter
    xyz = {
        #"Ticker": ['add_WQDV', 'add_IWMO', 'add_IWQU', 'add_IWSZ', 'add_IWVL', 'add_MVOL'],
        # #"Ticker": ['MXWO_O', 'IWSZ.L', 'MVOL.L', 'IWQU.L', 'IWVL.L', 'IWMO.L'],
        #"Type_Strategy": "relativeStrength",
        "Strategy_Code": "L_ST_CA_50",             # Code to have short name and fist information
        "Strategy_Name": "Cross above 50 MOV",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 500,                             # stop the trade afer periods
        "Timestop_delta": [50, 100],
        "donchian": 20,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Initialstop": -60,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-10], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 500,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        #"Takeprofit_delta": [30,60],                         # forward optimization: intervals Takeprofit
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 50, # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [20, 40, 60, 80, 100, 150, 200, 250, 300], # forward optimization: intervals timeperiod
        "factor_sma_band": 1, # kann im Entrysignal verwendet werden.
        "factor_sma_band_delta": [1, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.08, 1.1, 1.15, 1.2], # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "donchian",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 10,     # geht ab 1 los #TODO ?
        "days_between_signals": 5,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_50", # TODO: ?
        #"Indicator_101": "RS-Ratio",
        #"Indicator_102": "RS-Momentum",
        #"Indicator_101": "i_RSI_5",
        #"Indicator_102": "RS-Radius",
        "Indicator_101": "momentum_100",                     # TODO: ?

    }
    return xyz, Signaler



SetupLR
def SetupLR():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])
        r_square = float(xyz['r_square'])
        slope = float(xyz['slope'])
        df_sel_Index['x'] = df_sel_Index.Index
        df_sel_Index['y'] = df_sel_Index['Close']

        df_sel_Index['setup_roll_' + str(timeperiod) + '_m'], df_sel_Index['setup_roll_' + str(timeperiod) + '_r2'] = regression_stats_rolling(df_sel_Index[['x', 'y']], timeperiod)
        #print(df_sel_Index[['roll_' + str(timeperiod) + '_m', 'Close', 'roll_' + str(timeperiod) + '_r2']])
        #print("r_square",r_square, timeperiod)
        #print(df_sel_Index[['roll_' + str(timeperiod) + '_m', 'Close', 'roll_' + str(timeperiod) + '_r2']].describe())
        #print(df_sel_Index[(df_sel_Index['roll_' + str(timeperiod) + '_m'] >= 0) & (df_sel_Index['roll_' + str(timeperiod) + '_m'].shift() <= 0)])

        df_EntrySignal["Entry1"] = np.where((
            (df_sel_Index['setup_roll_' + str(timeperiod) + '_m']         >= slope)                         # close > sma
            & (df_sel_Index['setup_roll_' + str(timeperiod) + '_m'].shift(1) < slope)                 # close_last < sma
            & (df_sel_Index['setup_roll_' + str(timeperiod) + '_r2'] >= r_square) # R2
        ), 1, 0)

        df_EntrySignal["Exit1"] = np.where((
                (df_sel_Index['setup_roll_' + str(timeperiod) + '_m'] < slope) # close > sma
                & (df_sel_Index['setup_roll_' + str(timeperiod) + '_m'].shift(1) >= slope) # close_last < sma
        ), 1, 0)
        #print(df_EntrySignal[df_EntrySignal['Entry1'] == 1])

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    # setup_parameter
    xyz = {
        "Strategy_Code": "LinearRegression",             # Code to have short name and fist information
        "Strategy_Name": "LinearRegression",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 500,                             # stop the trade afer periods
        "Timestop_delta": [50],
        "donchian": 20,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Initialstop": -60,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-10], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 500 ,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        #"Takeprofit_delta": [30,60],                         # forward optimization: intervals Takeprofit
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 100,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [20, 40, 60, 80, 100, 150, 200, 250, 300],                         # forward optimization: intervals timeperiod
        "slope": 0.1,
        "slope_delta": [0,1,2,3,4,5,6,8,10],
        "r_square": 0,#0.0005,
        "r_square_delta": [0, 0.0001, 0.0005, 0.001, 0.005],
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 10,     # geht ab 1 los #TODO ?
        "days_between_signals": 5,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_200", # TODO: ?
        "Indicator_101": "setup_roll_200_m",
        #"Indicator_102": "RS-Momentum",
        #"Indicator_101": "i_RSI_5",
        #"Indicator_102": "RS-Radius",
        #"Indicator_101": "momentum_100",                     # TODO: ?

    }
    return xyz, Signaler



SetupBottomFisher
def SetupBottomFisher():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):

        bottom = float(xyz['bottom'])

        if ('PRBFISH' not in df_sel_Index.columns) & ('add_PRBFISH' not in df_sel_Index.columns):
            externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_PRBFISH.csv')
            df_sel_Index = externaldata.get_df_sel_Index()
        timeperiod = int(xyz['timeperiod'])
        #print(df_sel_Index[df_sel_Index['add_PRBFISH']>0])
        #print("bottom", bottom)
        df_EntrySignal["Entry1"] = np.where(
                (df_sel_Index['add_PRBFISH'] >= bottom)
                & (df_sel_Index['add_PRBFISH'].shift(1) < bottom)
        , 1, 0)
        df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)

        #print(df_EntrySignal[(df_EntrySignal['Entry1'] == 1) | (df_EntrySignal['Exit1'] == 1)])
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    # setup_parameter
    xyz = {
        "Strategy_Code": "BottomFisher",             # Code to have short name and fist information
        "Strategy_Name": "BottomFisher",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 40,                             # stop the trade afer periods
        "Timestop_delta": [50, 100],
        "donchian": 20,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Initialstop": -10,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-10], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 500 ,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        "bottom": 5,
        "bottom_delta": [-30, -25, -20,-15, -10, -5, 0, 5, 10], # takeprofit #TODO: auf was Close oder Intraday
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 50,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [20, 40, 60, 80, 100, 150, 200, 250, 300],                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 10,     # geht ab 1 los #TODO ?
        "days_between_signals": 5,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_200", # TODO: ?
        "Indicator_101": "setup_roll_200_m",
        #"Indicator_102": "RS-Momentum",
        #"Indicator_101": "i_RSI_5",
        #"Indicator_102": "RS-Radius",
        #"Indicator_101": "momentum_100",                     # TODO: ?

    }
    return xyz, Signaler


def ETF_Hamster():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        month1_entry = xyz['month1'] + 0
        month1_exit = xyz['month1']
        month2 = xyz['month2']
        month3 = xyz['month3']
        ticker2 = 'com_Gold'
        #ticker2 = 'SILVER'
        #ticker1 = 'i_RTY'
        #ticker3 = 'i_SPX'
        ticker1 = 'i_MDAX'
        #ticker1 = 'WTIC' # zu viel drawdown
        ticker3 = 'i_DAX'
        #ticker1 = 'SILVER1'
        #ticker3 = 'SILVER3'
        #ticker1 = 'com_Gold1'
        #ticker3 = 'com_Gold3'
        #benchmark = Benchmark(config, df_sel_Index, 'i_SPX')
        #df_sel_Index = benchmark.get_df_sel_Index()
        if 'Month_Change' not in df_sel_Index:
            #df_sel_Index['Month_Change'] = 1
            df_sel_Index = calculateFirstofMonth(df_sel_Index)
            #print(df_sel_Index['Month_Change'].tail(30))
            #exit()
        if month1_entry > 12:
            month1_entry = month1_entry - 12
        if month1_exit > 12:
            month1_exit = month1_exit - 12
        if (symbol == ticker1):
            df_EntrySignal["Entry1"] = np.where((df_sel_Index['Date'].dt.month == month1_entry) & (df_sel_Index['Month_Change'] == 1), 1, 0)
            df_EntrySignal["Exit1"] = np.where((df_sel_Index['Date'].dt.month == month2 + 0) & (df_sel_Index['Month_Change'] == 1), 1, 0)
        if (symbol == ticker2):
            df_EntrySignal["Entry1"] = np.where((df_sel_Index['Date'].dt.month == month2 + 0) & (df_sel_Index['Month_Change'] == 1), 1, 0)
            df_EntrySignal["Exit1"] = np.where((df_sel_Index['Date'].dt.month == month3 + 0) & (df_sel_Index['Month_Change'] == 1), 1, 0)
        if (symbol == ticker3):
            df_EntrySignal["Entry1"] = np.where((df_sel_Index['Date'].dt.month == month3) & (df_sel_Index['Month_Change'] == 1), 1, 0)
            df_EntrySignal["Exit1"] = np.where((df_sel_Index['Date'].dt.month == month1_exit + 0) & (df_sel_Index['Month_Change'] == 1), 1, 0)
        # & (df_sel_Index['zzz_SPX_abst_sma_percent_200'] >= 0) # Filter mit SPX sma200

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    # setup_parameter
    xyz = {
        "Ticker": ['i_DAX', 'i_MDAX', 'com_Gold'],
        "Strategy_Code": "ETF_Hamster",             # Code to have short name and fist information
        "Strategy_Name": "ETF_Hamster",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Seasonal",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "MT",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "max_time": 40,                            # max time of holding period and optimization window
        "Timestop": 200,                             # stop the trade afer periods
        "Timestop_delta": 5,                        # forward optimization: intervals Timestop
        "donchian": 500,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "donchian_delta": 25,                     # forward optimization: intervals donchain
        "Initialstop": -50,                         # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": 5,                     # forward optimization: intervals Initialstop
        "Takeprofit": 125,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50,100,125],                         # forward optimization: intervals Takeprofit
        "month1": 1,
        "month1_delta": 1,
        "month2": 7,
        "month2_delta": 1,
        "month3": 10,
        "month3_delta": 1,
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 20,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 200,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": 2,                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": 2,                 # forward optimization: intervals psar_acceleration_delta
        "psar_acceleration_multiply": 1,                # 1:multiplizieren mit delta und nicht addieren
        "Trailingstop": "",                             # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 6,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 1,     # geht ab 1 los #TODO ?
        "days_between_signals": 1,                     #
        "Filter": "",                                 # sma200_underlying, sma200_benchmark, TRE
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_200",                     # TODO: ?
        "Indicator_101": "RSI_5",                     # TODO: ?
        #"Indicator_103": "5_MOM",                     # TODO: ?

    }
    return xyz, Signaler




#Setup Marktbreite
Setup_MB_MCC
def Setup_MB_MCC():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod1 = int(xyz['timeperiod1'])
        timeperiod2 = int(xyz['timeperiod2'])
        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_MCSUMRSPX.csv', 'Close')
        df_sel_Index = externaldata.get_df_sel_Index()

        df_EntrySignal["Entry1"] = np.where((
             (df_sel_Index['add_MCSUMRSPX'].rolling(timeperiod1).mean() >= df_sel_Index['add_MCSUMRSPX'].rolling(timeperiod2).mean()) &
             (df_sel_Index['add_MCSUMRSPX'].rolling(timeperiod1).mean().shift(1) < df_sel_Index['add_MCSUMRSPX'].rolling(timeperiod2).mean().shift(1)) #&
             #((df_sel_Index['Close'] >ta.SMA(df_sel_Index[calc_on], timeperiod=200))) # filter

        ), 1, 0)
        df_EntrySignal["Exit1"] = np.where((
                (df_sel_Index['add_MCSUMRSPX'].rolling(timeperiod1).mean() < df_sel_Index['add_MCSUMRSPX'].rolling(timeperiod2).mean()) &
                (df_sel_Index['add_MCSUMRSPX'].rolling(timeperiod1).mean().shift(1) >= df_sel_Index['add_MCSUMRSPX'].rolling(timeperiod2).mean().shift(1))
        ), 1, 0)
        #print("Anzahl Signale, Entry1", df_EntrySignal[df_EntrySignal['Entry1'] == 1].shape[0])
        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "L_MT_MB_MCC",
        "Strategy_Name": "upTrend McClellan Summation Index",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "MB", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "MT", # ST, MT, LT
        "max_time": 200,
        "donchian": 20, # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Timestop": 100, # nach soviel Tagen wird trade beendet
        "Timestop_delta": [10,20,50,100], # delta wird für forward verwendet
        "threshold": 60,
        "threshold_delta": [2,2.5, 3,4],
        "timeperiod1": 20,
        "timeperiod1_delta": [10, 20, 30, 40, 50],
        "timeperiod2": 50,
        "timeperiod2_delta": [50, 100, 200],
        "Initialstop": -5,
        "Initialstop_delta": 0.5, # delta wird für forward verwendet
        "Takeprofit": 10,
        "Takeprofit_delta": 0.5, # delta wird für forward verwendet
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "first_possible_trade": 20,
        "timeperiod": 20,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1000,
        "days_between_signals": 1, #
        "Indicator_1": "SMA_200", # Indikatoren
        #"Indicator_103": "Ratio",
        "Indicator_101": "Ratio_sma10",
        "Indicator_102": "Ratio_sma40",
        #"Indicator_103": "const_60",
        # "Indicator_103": "5_MOM",

    }
    return xyz, Signaler



Setup_MB_AD_Ratio_RSI_dev
def Setup_MB_AD_Ratio_RSI_dev():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):

        timeperiod1 = int(xyz['timeperiod1'])
        timeperiod2 = int(xyz['timeperiod2'])

        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_BINYAPTI.csv', 'Close')
        df_sel_Index = externaldata.get_df_sel_Index()

        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_BINYDPTI.csv', 'Close')
        df_sel_Index = externaldata.get_df_sel_Index()

        df_sel_Index['add_BINYAPTI'].fillna(method='ffill', inplace=True)
        df_sel_Index['add_BINYDPTI'].fillna(method='ffill', inplace=True)
        df_sel_Index['Ratio'] = ta.SMA(df_sel_Index['add_BINYAPTI'], timeperiod=5) / ta.SMA(df_sel_Index['add_BINYDPTI'], timeperiod=5)

        df_EntrySignal["Entry1"] = np.where((
                (ta.RSI(df_sel_Index['Ratio'], timeperiod=7) > 50)
                & (ta.RSI(df_sel_Index['Ratio'], timeperiod=7).shift(1) <= 50)
                & (df_sel_Index[calc_on] > (ta.SMA(df_sel_Index[calc_on], timeperiod=200)))
        ), 1, 0)

        df_EntrySignal["Exit1"] = 0
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        "Strategy_Code": "L_MT_MB_ADRatio_RSI_Thresh",
        "Strategy_Name": "NYSE Advance Decline Ratio RSI + Threshold",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "MB", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "MT", # ST, MT, LT
        "max_time": 100,
        "donchian": 20, # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Timestop": 60, # nach soviel Tagen wird trade beendet
        "Timestop_delta": [10,20,50,100], # delta wird für forward verwendet
        #"threshold": 60,
        "threshold_delta": [2,2.5, 3,4],
        "timeperiod1": 5,
        "timeperiod1_delta": [10, 20, 30, 40, 50],
        "timeperiod2": 20,
        "timeperiod2_delta": [50, 100, 200],
        "Initialstop": -5,
        "Initialstop_delta": 0.5, # delta wird für forward verwendet
        "Takeprofit": 15,
        "Takeprofit_delta": 0.5, # delta wird für forward verwendet
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "first_possible_trade": 20,
        "timeperiod": 20,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1,
        "days_between_signals": 20, #
        "Indicator_1": "SMA_200", # Indikatoren
        #"Indicator_103": "Ratio",
        "Indicator_101": "Ratio_sma10",
        "Indicator_102": "Ratio_sma40",
        #"Indicator_103": "const_60",
        # "Indicator_103": "5_MOM",

    }
    return xyz, Signaler

#### Development plotly
Setup_MB_plotly_dev
def Setup_MB_plotly_dev():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):

        threshold = int(xyz['threshold'])
        timeperiod1 = int(xyz['timeperiod1'])
        timeperiod2 = int(xyz['timeperiod2'])

        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_PCRATCBO.csv', 'Close', ffill_if_empty_data = True)
        df_sel_Index = externaldata.get_df_sel_Index()
        df_sel_Index['indicator'] = ta.RSI(df_sel_Index['add_PCRATCBO'], timeperiod=3)

        print(df_sel_Index['zz_distance_actual_p_10'])

        df_EntrySignal["Entry1"] = np.where((
             (df_sel_Index['indicator'] > 80)
             #& (df_sel_Index['add_PCRATCBO'] > 1.0)
        ), 1, 0)

        df_EntrySignal["Exit1"] = 0


        ##---
        title = 'Test MB Indicators'

        panel1 = 'indicator'
        panel2 = 'Entry1'
        hLine1 = 140 #horizontal Line in Panel 2

        #plot_template(title, df_sel_Index, df_EntrySignal ,panel1, panel2, hLine1)
        #print('plot_finished')
        ##---
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        "Strategy_Code": "L_MT_MB_Put Call Ratio Thres",
        "Strategy_Name": "CBOE Put/Call Ratio Threshold",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "MB", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "MT", # ST, MT, LT
        "max_time": 40,
        "donchian": 20, # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Timestop": 20, # nach soviel Tagen wird trade beendet
        "Timestop_delta": [10,20,50,100], # delta wird für forward verwendet
        "threshold": 90,
        "threshold_delta": [2,2.5, 3,4],
        "timeperiod1": 3,
        "timeperiod1_delta": [2,5,10,20],
        "timeperiod2": 20,
        "timeperiod2_delta": [5,7,14,30,40],
        "Initialstop": -5,
        "Initialstop_delta": [-4,-5,-7,-10], # delta wird für forward verwendet
        "Takeprofit": 5,
        "Takeprofit_delta": [7,10,15], # delta wird für forward verwendet
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "first_possible_trade": 2,
        "timeperiod": 20,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 5,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1,
        "days_between_signals": 10, #
        "Indicator_1": "SMA_200", # Indikatoren
        "Indicator_101": "indicator",
        #"Indicator_101": "Ratio_sma10",
        #"Indicator_102": "Ratio_sma40",
        #"Indicator_103": "const_60",
        # "Indicator_103": "5_MOM",

    }
    return xyz, Signaler

SetupNews
def SetupNews():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        openai_answer = int(xyz['openai'])
        #print(symbol, "anz", df_sel_Index.shape[0])
        if 'openai_answer' not in df_sel_Index.columns:
            externaldata = ExternalData(df_sel_Index, 'source/openai', 'n_'+str(symbol)+'.txt', 'openai_answer')
            df_sel_Index = externaldata.get_df_sel_Index()
        #print(df_sel_Index.columns.values)
        #exit()
        #print("anz", df_sel_Index.shape[0])
        #print(df_sel_Index[['Date', 'Close', 'openai_answer']].describe())
        #print(df_sel_Index[df_sel_Index['openai_answer'] > 0])
        #exit()
        #df_sel_Index['Ratio'] = df_sel_Index['add_ADLINENYA'] / df_sel_Index[calc_on]
        #df_sel_Index['Ratio_sma10'] = df_sel_Index['Ratio'].rolling(timeperiod1).mean()
        #df_sel_Index['Ratio_sma40'] = df_sel_Index['Ratio'].rolling(timeperiod2).mean()
        df_sel_Index['filter_openai_answer'] = df_sel_Index['openai_answer']
        df_EntrySignal["Entry1"] = np.where((
             (df_sel_Index['openai_answer'] >= openai_answer)
        ), 1, 0)
        # df_EntrySignal["Exit1"] = np.where((
        #         (df_sel_Index['Ratio'].rolling(timeperiod1).mean() < df_sel_Index['Ratio'].rolling(timeperiod2).mean())
        #         & (df_sel_Index['Ratio'].rolling(timeperiod1).mean().shift(1) >= df_sel_Index['Ratio'].rolling(timeperiod2).mean().shift(1))
        # ), 1, 0)
        #print(df_EntrySignal[df_EntrySignal['Entry1'] == 1])
        #print("Anzahl Signale", df_EntrySignal[df_EntrySignal['Entry1'] == 1].shape[0])
        #exit()
        df_EntrySignal["Exit1"] = 0
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "News",
        "Strategy_Name": "SeekingAlphaNews",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "MB", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "MT", # ST, MT, LT
        "max_time": 200,
        "donchian": 20, # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Timestop": 40, # nach soviel Tagen wird trade beendet
        "Timestop_delta": [5, 10, 20, 40,60,80, 100], # delta wird für forward verwendet
        "openai": 97, # nach soviel Tagen wird trade beendet
        "openai_delta": [0,50,75,90,95, 100], # delta wird für forward verwendet
        "Initialstop": -5,
        "Initialstop_delta": [-20,-15,-10,-5,-3], # delta wird für forward verwendet
        "Takeprofit": 15,
        "Takeprofit_delta": [5,10,15,20,25], # delta wird für forward verwendet
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "first_possible_trade": 20,
        "timeperiod": 20,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1000,
        "days_between_signals": 0, #
        "Indicator_1": "SMA_200", # Indikatoren
        #"Indicator_103": "Ratio",
        "Indicator_101": "Ratio_sma10",
        "Indicator_102": "Ratio_sma40",
        #"Indicator_103": "const_60",
        # "Indicator_103": "5_MOM",

    }
    return xyz, Signaler






Setup_MB_upVolperc
def Setup_MB_upVolperc():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):

        threshold = int(xyz['threshold'])
        timeperiod1 = int(xyz['timeperiod1'])


        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_UVOLNYA.csv', 'Close', ffill_if_empty_data = False)
        df_sel_Index = externaldata.get_df_sel_Index()
        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_DVOLNYA.csv', 'Close', ffill_if_empty_data = False)
        df_sel_Index = externaldata.get_df_sel_Index()

        df_sel_Index['roll_sum_upVOL'] = df_sel_Index['add_UVOLNYA'].rolling(window=timeperiod1).sum()
        df_sel_Index['roll_sum_downVOL'] = df_sel_Index['add_DVOLNYA'].rolling(window=timeperiod1).sum()

        df_sel_Index['indicator'] = df_sel_Index['roll_sum_upVOL'] / (df_sel_Index['roll_sum_upVOL']+df_sel_Index['roll_sum_downVOL'])


        df_EntrySignal["Entry1"] = np.where((
                (df_sel_Index['indicator'] > 0.60)
                & (df_sel_Index['indicator'].shift(1) <= 0.60)
                #& (df_sel_Index[calc_on] > (ta.SMA(df_sel_Index[calc_on], timeperiod=200)))

        ), 1, 0)

        df_EntrySignal["Entry1"] = df_EntrySignal["Entry1"] .mask(
            df_EntrySignal["Entry1"] .rolling(window=60).apply(lambda x: x.sum()) > 1, 0)

        df_EntrySignal["Exit1"] = 0

        ##---
        title = 'Test MB Indicators'

        panel1 = {
                'Indicator': ['indicator', '#bbbbbb','tozeroy'], # Key = name in plot, Values= column_name, color
                #'fast_xy': ['fast', '#8aea00', 'tozeroy'], # Key = name in plot, Values= column_name, color
                #'slow_xy': ['slow', '#006c0d', 'tonexty'],

                 }


        panel2 = 'Entry1' #richtig
        #panel2 = 'zz_distance_actual_p_4'


        hLine1 = 0.6 #horizontal Line in Panel 2
        rangeslider = 'yes'

        #plot = plot_template(title, df_sel_Index, df_EntrySignal, rangeslider,panel1, panel2, hLine1)
        #print('plot_finished')

        ##---
        return df_EntrySignal, df_sel_Index

    xyz = {
        "Strategy_Code": "L_MT_MB_NYnHnLpct_Ratio RSI",
        "Strategy_Name": "NYSE new High Low Percent ratio RSI with threshold",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "MB", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "MT", # ST, MT, LT
        "max_time": 40,
        "donchian": 20, # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Timestop": 20, # nach soviel Tagen wird trade beendet
        "Timestop_delta": [10,20,50,100], # delta wird für forward verwendet
        "threshold": 0.60,
        "threshold_delta": [2,2.5, 3,4],
        "timeperiod1": 10,
        "timeperiod1_delta": [2,5,10,20],
        "timeperiod2": 200,
        "timeperiod2_delta": [5,7,14,30,40],
        "Initialstop": -4,
        "Initialstop_delta": [-4,-5,-7,-10], # delta wird für forward verwendet
        "Takeprofit": 8,
        "Takeprofit_delta": [7,10,15], # delta wird für forward verwendet
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "first_possible_trade": 2,
        "timeperiod": 20,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 10,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1,
        "days_between_signals": 60, #
        "Indicator_1": "SMA_200", # Indikatoren
        "Indicator_101": "indicator",
        #"Indicator_101": "Ratio_sma10",
        #"Indicator_102": "Ratio_sma40",
        #"Indicator_103": "const_60",
        # "Indicator_103": "5_MOM",

    }
    return xyz, Signaler






Setup_MB_NYnHperct_dev
def Setup_MB_NYnHperct_dev():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):

        threshold = int(xyz['threshold'])
        timeperiod1 = int(xyz['timeperiod1'])
        timeperiod2 = int(xyz['timeperiod2'])

        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'add_BINYNLPTI.csv', 'Close', ffill_if_empty_data = False)
        df_sel_Index = externaldata.get_df_sel_Index()

        df_sel_Index['fast'] = ta.RSI(df_sel_Index['add_BINYNLPTI'], timeperiod=timeperiod1)


        df_EntrySignal["Entry1"] = np.where((
                (df_sel_Index['fast'] < threshold)
                & (df_sel_Index['fast'].shift(1) >= threshold)
                & (df_sel_Index[calc_on] > (ta.SMA(df_sel_Index[calc_on], timeperiod=200)))

        ), 1, 0)

        df_EntrySignal["Exit1"] = 0

        ##---
        title = 'Test MB Indicators'

        panel1 = {
                'Indicator': ['add_BINYNLPTI', '#bbbbbb','tozeroy'], # Key = name in plot, Values= column_name, color
                'fast_xy': ['fast', '#8aea00', 'tozeroy'], # Key = name in plot, Values= column_name, color
                #'slow_xy': ['slow', '#006c0d', 'tonexty'],

                 }


        #panel2 = 'Entry1' #richtig
        panel2 = 'zz_distance_actual_p_4'


        hLine1 = 0 #horizontal Line in Panel 2

        #plot_template(title, df_sel_Index, df_EntrySignal ,panel1, panel2, hLine1)
        #print('plot_finished')

        ##---
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index

    xyz = {
        "Strategy_Code": "L_MT_MB_NYnHnLpct_Ratio RSI",
        "Strategy_Name": "NYSE new High Low Percent ratio RSI with threshold",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "TA", # TA = Technical Analysis
        "Strategy_Style": "MB", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "MT", # ST, MT, LT
        "max_time": 40,
        "donchian": 20, # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Timestop": 15, # nach soviel Tagen wird trade beendet
        "Timestop_delta": [10,20,50,100], # delta wird für forward verwendet
        "threshold": 70,
        "threshold_delta": [2,2.5, 3,4],
        "timeperiod1": 10,
        "timeperiod1_delta": [2,5,10,20],
        "timeperiod2": 200,
        "timeperiod2_delta": [5,7,14,30,40],
        "Initialstop": -4,
        "Initialstop_delta": [-4,-5,-7,-10], # delta wird für forward verwendet
        "Takeprofit": 8,
        "Takeprofit_delta": [7,10,15], # delta wird für forward verwendet
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "first_possible_trade": 2,
        "timeperiod": 20,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 10,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1,
        "days_between_signals": 10, #
        "Indicator_1": "SMA_200", # Indikatoren
        "Indicator_101": "indicator",
        #"Indicator_101": "Ratio_sma10",
        #"Indicator_102": "Ratio_sma40",
        #"Indicator_103": "const_60",
        # "Indicator_103": "5_MOM",

    }
    return xyz, Signaler


Setup_Stochastic
def Setup_Stochastic():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        fastk_period = xyz['fastk_period']
        slowk_period = xyz['slowk_period']
        slowd_period = xyz['slowd_period']
        threshold = xyz['threshold']
        threshold_exit = xyz['threshold_exit']

        df_sel_Index['slowk'], df_sel_Index['slowd'] = ta.STOCH(df_sel_Index['High'] , df_sel_Index['Low'] , df_sel_Index['Close'] , fastk_period=fastk_period, slowk_period=slowk_period, slowk_matype=0, slowd_period=slowd_period, slowd_matype=0)
        df_sel_Index['ema20'] = ta.EMA(df_sel_Index['Close'], 20)
        df_sel_Index['ema200'] = ta.EMA(df_sel_Index['Close'], 200)
        df_sel_Index['ma20'] = ta.MA(df_sel_Index['Close'], 20)
        df_sel_Index['ma200'] = ta.MA(df_sel_Index['Close'], 200)
        #print(df_sel_Index[['Close', 'ema20', 'ema200']])
        #exit()
        #df_sel_Index['RSI_' + str(timeperiod)] = ta.RSI(df_sel_Index['Close'], timeperiod=timeperiod)
        df_EntrySignal["Entry1"] = np.where((
                (df_sel_Index['slowk'] < threshold)
                & (df_sel_Index['slowk'].shift(0) > (df_sel_Index['slowd'].shift(0)))
                & (df_sel_Index['slowk'].shift(1) < (df_sel_Index['slowd'].shift(1)))
                #& ta.EMA(df_sel_Index['Close'], 20) > ta.EMA(df_sel_Index['Close'], 200)
                #& (df_sel_Index['Close'].rolling(window=20).mean() > df_sel_Index['Close'].rolling(window=200).mean())
                & (df_sel_Index['ema20'] > df_sel_Index['ema200'])
        ), 1, 0)
        df_EntrySignal["Exit1"] = np.where((
                (df_sel_Index['slowk'] > threshold_exit)
                & (df_sel_Index['slowk'].shift(0) < (df_sel_Index['slowd'].shift(0)))
                & (df_sel_Index['slowk'].shift(1) > (df_sel_Index['slowd'].shift(1)))
        ), 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        #print(df_EntrySignal[df_EntrySignal['Entry1']==1])
        #df_sel_Index['filter_ind'] = df_sel_Index['RSI_' + str(timeperiod)]
        return df_EntrySignal, df_sel_Index

    # setup_parameter
    xyz = {
        "Strategy_Code": "StochasticRuecksetzer",             # Code to have short name and fist information
        "Strategy_Name": "StochasticRuecksetzer",     # Long name
        "Type_Strategy": "Signal",
        "Timestop": 1000,                             # stop the trade afer periods
        "Timestop_delta": [50],
        "donchian": 20,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "order_typ": "close",
        "fastk_period": 21,
        "fastk_period_delta": [5, 8, 10, 15, 21, 25, 30, 35],
        "slowk_period": 3,
        "slowk_period_delta": [3,5,8,10,15],
        "slowd_period": 3,
        "slowd_period_delta": [3, 5, 8, 10, 15],
        "threshold": 25,
        "threshold_delta": [20, 25, 30, 35],
        "threshold_exit": 75,
        "threshold_exit_delta": [30,40,50, 60, 70, 80, 90],
        "Initialstop": -3,
        "Initialstop_delta": [-20, -15, -10, -5, -3], # delta wird für forward verwendet
        "Takeprofit": 15,
        "Takeprofit_delta": [5, 10, 15, 20, 25], # delta wird für forward verwendet
        "number_open_trades_per_symbol_allowed": 10,
        "Indicator_1": "SMA_20",
        "Indicator_2": "SMA_200",
        "Indicator_101": "slowk",
        "Indicator_102": "slowd",
    }
    return xyz, Signaler


Setup_sma200_dive
def Setup_sma200_dive():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])

        df_sel_Index['sma200'] = ta.SMA(df_sel_Index['Close'], timeperiod=timeperiod)
        df_sel_Index['setup_sma200_slope'] = 10000*(df_sel_Index['sma200'] - df_sel_Index['sma200'].shift(1))/df_sel_Index['sma200'].shift(1)
        df_sel_Index['setup_sma200_cross_up'] = np.where(((df_sel_Index['Close'] > ta.SMA(df_sel_Index['Close'], timeperiod = timeperiod))& (df_sel_Index['Close'].shift(1) < ta.SMA(df_sel_Index['Close'], timeperiod = timeperiod).shift(1))), 1, 0)
        df_sel_Index['setup_sma200_cross_down'] = np.where(((df_sel_Index['Close'] < ta.SMA(df_sel_Index['Close'],timeperiod=timeperiod)) & (
                        df_sel_Index['Close'].shift(1) >= ta.SMA(df_sel_Index['Close'], timeperiod=timeperiod).shift(1))), 1,0)

        #print(df_sel_Index[['Date', 'Close', 'sma200', 'sma200_cross', 'sma200_cross_count']].loc[497:521])
        #print(df_sel_Index[['Date', 'Close', 'sma200', 'setup_sma200_cross_up', 'setup_sma200_cross_up_count']].loc[685:717])
        #print(df_EntrySignal[df_EntrySignal['Entry1'] == 1])

        df_sel_Index['setup_sma200_cross_up_count'] = df_sel_Index.groupby((df_sel_Index['setup_sma200_cross_up'] == 1).cumsum()).cumcount() + 1
        df_sel_Index['setup_sma200_cross_down_count'] = df_sel_Index.groupby((df_sel_Index['setup_sma200_cross_down'] == 1).cumsum()).cumcount() + 1

        group_indices = (df_sel_Index['setup_sma200_cross_down_count'] != df_sel_Index['setup_sma200_cross_down_count'].shift() + 1).cumsum()
        df_sel_Index['setup_tiefe'] = df_sel_Index.groupby(group_indices)['Close'].transform(lambda x: x.rolling(len(x), min_periods=1).min())
        df_sel_Index['setup_tiefe'] = 100*(df_sel_Index['setup_tiefe'] - df_sel_Index['sma200'])/df_sel_Index['sma200']
        df_sel_Index['setup_tiefe_20'] = 100 * (df_sel_Index['Close'].rolling(20).min() - df_sel_Index['sma200']) / df_sel_Index['sma200']

        #print(df_sel_Index[['Date', 'Close', 'sma200','setup_sma200_slope', 'setup_sma200_cross_up', 'setup_sma200_cross_up_count', 'setup_sma200_cross_down', 'setup_sma200_cross_down_count','setup_tiefe','setup_tiefe_20']].loc[685:717])

        df_EntrySignal["Entry1"] = np.where((
                (df_sel_Index['Close'] > ta.SMA(df_sel_Index['Close'], timeperiod=timeperiod)) # close > sma
                & (df_sel_Index['Close'].shift(1) < ta.SMA(df_sel_Index['Close'], timeperiod=timeperiod).shift(1))
                #& (df_sel_Index['setup_tiefe_20'] == df_sel_Index['setup_tiefe'])
                #& (df_sel_Index['setup_sma200_slope'] >= 2)
                #& (df_sel_Index['setup_tiefe'] >= -1)
                #& (df_sel_Index['setup_tiefe_20'] >= -2)
                #& (df_sel_Index['i_atr7_atr14'] >= 1)
        ), 1, 0)

        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(int(xyz['Timestop'])) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    # setup_parameter
    xyz = {
        #"Ticker": ['add_WQDV', 'add_IWMO', 'add_IWQU', 'add_IWSZ', 'add_IWVL', 'add_MVOL'],
        # #"Ticker": ['MXWO_O', 'IWSZ.L', 'MVOL.L', 'IWQU.L', 'IWVL.L', 'IWMO.L'],
        #"Type_Strategy": "relativeStrength",
        "Strategy_Code": "L_ST_CA_200",             # Code to have short name and fist information
        "Strategy_Name": "Cross above 200 MOV",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 200,                             # stop the trade afer periods
        "Timestop_delta": [75,100],
        "donchian": 60,                                # SL nachziehen #TODO welche funktion; Stop-Logik?
        "donchian_delta": [20, 40, 60, 80, 100],
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Initialstop": -20,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-5, -10, -20], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 200,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        #"Takeprofit_delta": [30,60],                         # forward optimization: intervals Takeprofit
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 200,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [180, 200,220],                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 1,     # geht ab 1 los #TODO ?
        "number_open_trades_allowed": 1000, # geht ab 1 los #TODO ?
        "days_between_signals": 0,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_200",
        "Indicator_2": "SMA_20",
        #"Indicator_101": "RS-Ratio",
        #"Indicator_102": "RS-Momentum",
        #"Indicator_101": "i_RSI_5",
        #"Indicator_102": "RS-Radius",
        "Indicator_101": "RSI_14",                     # TODO: ?

    }
    return xyz, Signaler

Setup_date_entry
def Setup_date_entry():
    # signal
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = 200
        df_EntrySignal["Entry1"] = 0
        #df_EntrySignal["Entry1"] = np.where((
        #        (df_sel_Index['Close'] > ta.SMA(df_sel_Index['Close'], timeperiod=timeperiod)) # close > sma
        #        & (df_sel_Index['Close'].shift(1) < ta.SMA(df_sel_Index['Close'], timeperiod=timeperiod).shift(1))
        #), 1, 0)
        dauer = 20
        if symbol == 'i_BEL20':
            entries = [10, 20, 30]
            for entry in entries:
                df_EntrySignal.loc[df_EntrySignal.index[entry], 'Entry1'] = 1
                df_EntrySignal.loc[df_EntrySignal.index[entry + dauer], 'Exit1'] = 1
        elif symbol == 'i_COLCAP':
            entries = [10, 40]
            for entry in entries:
                df_EntrySignal.loc[df_EntrySignal.index[entry], 'Entry1'] = 1
                df_EntrySignal.loc[df_EntrySignal.index[entry + dauer], 'Exit1'] = 1
        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(int(xyz['Timestop'])) == 1, 1, 0)

        print(df_EntrySignal[(df_EntrySignal['Entry1'] >= 1) | (df_EntrySignal['Exit1'] >= 1)])
        return df_EntrySignal, df_sel_Index
    # setup_parameter
    xyz = {
        #"Ticker": ['add_WQDV', 'add_IWMO', 'add_IWQU', 'add_IWSZ', 'add_IWVL', 'add_MVOL'],
        # #"Ticker": ['MXWO_O', 'IWSZ.L', 'MVOL.L', 'IWQU.L', 'IWVL.L', 'IWMO.L'],
        #"Type_Strategy": "relativeStrength",
        "Strategy_Code": "L_ST_CA_200",             # Code to have short name and fist information
        "Strategy_Name": "Cross above 200 MOV",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 50,                             # stop the trade afer periods
        "Timestop_delta": [75,100],
        "Initialstop": -99,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-5, -10, -20], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 1000,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 200,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [180, 200,220],                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 1000,     # w
        "number_open_trades_allowed": 1000, # geht ab 1 los #TODO ?
        "days_between_signals": 0,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_200",
        "Indicator_2": "SMA_20",
        "Indicator_101": "RSI_14",                     # TODO: ?
    }
    return xyz, Signaler


Setup_OBV
def Setup_OBV():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])


        df_sel_Index['OBV'] = ta.OBV(df_sel_Index['Close'], df_sel_Index['Volume'])
        df_sel_Index['OBV_200'] = df_sel_Index['OBV'].rolling(timeperiod).mean()

        df_EntrySignal["Entry1"] = np.where((
            (df_sel_Index['OBV'] > df_sel_Index['OBV_200'])
            & (df_sel_Index['OBV'].shift(1) < df_sel_Index['OBV_200'].shift(1))
        ), 1, 0)
        #df_EntrySignal["Exit1"] = np.where((
        #        (df_sel_Index['OBV'] < df_sel_Index['OBV_200'])
        #        & (df_sel_Index['OBV'].shift(1) > df_sel_Index['OBV_200'].shift(1))
        #), 1, 0)

        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(int(xyz['Timestop'])) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    # setup_parameter
    xyz = {
        #"Ticker": ['add_WQDV', 'add_IWMO', 'add_IWQU', 'add_IWSZ', 'add_IWVL', 'add_MVOL'],
        # #"Ticker": ['MXWO_O', 'IWSZ.L', 'MVOL.L', 'IWQU.L', 'IWVL.L', 'IWMO.L'],
        #"Type_Strategy": "relativeStrength",
        "Strategy_Code": "L_ST_CA_200",             # Code to have short name and fist information
        "Strategy_Name": "Cross above 200 MOV",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
                                                    # Currencies, Crypto, Commodities, Bond_Indices, Additionals
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 100,                             # stop the trade afer periods
        "Timestop_delta": [50,75,100],
        "donchian": 20,                             # SL nachziehen #TODO welche funktion; Stop-Logik?
        "zigzag": 5,                                    # SL nachziehen #TODO welche funktion; Stop-Logik?
        "Initialstop": -50,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-10], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 200,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        #"Takeprofit_delta": [30,60],                         # forward optimization: intervals Takeprofit
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 200,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [180, 200,220],                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 100,     # geht ab 1 los #TODO ?
        "number_open_trades_allowed": 100, # geht ab 1 los #TODO ?
        "days_between_signals": 0,                     #
        #"number_open_trades_per_strategy_allowed": 1, # geht ab 1 los, wozu war das eingeplant? #TODO?
        "Indicator_1": "SMA_200",
        "Indicator_101": "i_OBV",
        #"Indicator_102": "RS-Momentum",
        #"Indicator_101": "i_RSI_5",
        #"Indicator_102": "RS-Radius",
        "Indicator_101": "RSI_14",                     # TODO: ?

    }
    return xyz, Signaler

Setup_WilliamsR
def Setup_WilliamsR():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])
        df_sel_Index['WilliamsPctR'] = ta.WILLR(df_sel_Index.High.values, df_sel_Index.Low.values, df_sel_Index.Close.values, timeperiod=timeperiod)
        df_EntrySignal["Entry1"] = np.where((
            (df_sel_Index['WilliamsPctR'] <= -80)
             & (df_sel_Index['WilliamsPctR'].shift(1) > -80)
            #(df_sel_Index['WilliamsPctR'] >= -20)
            #& (df_sel_Index['WilliamsPctR'].shift(1) < -20)
        ), 1, 0)
        df_EntrySignal["Exit1"] = np.where((
            (df_sel_Index['WilliamsPctR'] >= -20)
            & (df_sel_Index['WilliamsPctR'].shift(1) < -20)
            #(df_sel_Index['WilliamsPctR'] <= -80)
            # & (df_sel_Index['WilliamsPctR'].shift(1) > -80)
        ), 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(int(xyz['Timestop'])) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    # setup_parameter
    xyz = {
        "Strategy_Code": "WilliamsR",             # Code to have short name and fist information
        "Strategy_Name": "WilliamsR cross 20/80",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 15,                             # stop the trade afer periods
        "Timestop_delta": [3,4,5, 10, 15, 20,30,50],
        "Initialstop": -50,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-10], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 200,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,                     # TODO: nach 200 Tagen wegen bspw. berechnung 200 MA?
        "timeperiod": 5,                             # kann im Entrysignal verwendet werden.
        "timeperiod_delta": [2,3,4,5,6,7,8,9, 10,12,15, 20, 30, 50, 100],                         # forward optimization: intervals timeperiod
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 100,     # geht ab 1 los #TODO ?
        "number_open_trades_allowed": 100, # geht ab 1 los #TODO ?
        "days_between_signals": 0,                     #
        "Indicator_1": "SMA_200",
        "Indicator_101": "WilliamsPctR",
        "Indicator_102": "const_-20",
        "Indicator_103": "const_-80",
    }
    return xyz, Signaler

SetupGoldRatio
def SetupGoldRatio():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])
        threshold_exit = int(xyz['threshold_exit'])
        externaldata = ExternalData(df_sel_Index, 'source/external_data', 'com_Gold.csv', 'Close',ffill_if_empty_data=True)
        df_sel_Index = externaldata.get_df_sel_Index()

        df_sel_Index['Ratio'] = df_sel_Index['Close'] / df_sel_Index['com_Gold']
        df_sel_Index['Ratio-1'] = df_sel_Index['com_Gold'] / df_sel_Index['Close']
        df_sel_Index['Ratio_sma10'] = df_sel_Index['Ratio'].rolling(10).mean()
        df_sel_Index['RSI_Ratio'] = ta.RSI(df_sel_Index['Ratio'], timeperiod=timeperiod)
        #print(df_sel_Index[['Close', 'com_Gold','Ratio', 'RSI_Ratio']])
        #exit()
        df_EntrySignal["Entry1"] = np.where((
            (df_sel_Index['RSI_Ratio'] >= 30)
             & (df_sel_Index['RSI_Ratio'].shift(1) < 30)
        ), 1, 0)
        #df_EntrySignal["Exit1"] = np.where((
        #    (df_sel_Index['RSI_Ratio'] >= threshold_exit)
        #    & (df_sel_Index['RSI_Ratio'].shift(1) < threshold_exit)
        #), 1, 0)
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(int(xyz['Timestop'])) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    # setup_parameter
    xyz = {
        "Strategy_Code": "GoldSilverRatio",             # Code to have short name and fist information
        "Strategy_Name": "GoldSilverRatio",     # Long name
        "Direction": 1,                             # Direction 1=long, 0=short #TODO prüfen ob 0 wirklich short
        "Strategy_Asset_Class": "Equity_Indices", # to filter out ouf: Region_Indices, Sector_Indices, SPX_SingleStocks, Stoxx2_SingleStocks
        "Analysis_Philosphy": "FA",                 # to filter out of: TA = Technical Analysis, FA = Fundment. Analysis, ...
        "Strategy_Style": "Trend",                 # to filter out of: Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical ...
        "Timeframe": "ST",                         # to filter out of: ST, MT, LT #TODO manuelle vs. automatische Klassifizierung prüfen
        "Timestop": 50,                             # stop the trade afer periods
        "Timestop_delta": [5, 10, 20,40,60, 100, 200],
        "Initialstop": -20,                             # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_delta": [-10], # inital Stop #TODO: auf was Close oder Intraday
        "Initialstop_ATR": 2,                         # inital Stop #TODO: auf was Close oder Intraday
        "Takeprofit": 200,                             # takeprofit #TODO: auf was Close oder Intraday
        "Takeprofit_delta": [50], # takeprofit #TODO: auf was Close oder Intraday
        "order_typ": "next_open",                         # next_open oder limit oder close. #TODO: Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent",                        # percent oder atr
        "first_possible_trade": 0,
        "timeperiod": 9,
        "timeperiod_delta": [7,8,9,10, 11, 12,13,14, 15],
        "threshold_exit": 80,
        "threshold_exit_delta": [50, 60, 70, 80],
        "donchian": 20,
        "donchian_delta": [10, 20, 50, 100],
        "psar_acceleration": 0.02,
        "psar_acceleration_delta": [0.02],
        "Trailingstop": "donchian",                         # psar, donchian, zigzag #TODO?
        "Trailingstop_active_after": 3,                 # TODO ?
        "number_open_trades_per_symbol_allowed": 100,     # geht ab 1 los #TODO ?
        "number_open_trades_allowed": 100, # geht ab 1 los #TODO ?
        "days_between_signals": 0,                     #
        "Indicator_1": "SMA_200",
        "Indicator_101": "RSI_Ratio",
        "Indicator_102": "Ratio-1",
        "Indicator_103": "const_30",
    }
    return xyz, Signaler

Setup_CoT
def Setup_CoT():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        symbol_cot = symbol
        externaldata = ExternalDataSource(df_sel_Index, 'external_data/cot', str(symbol_cot) + '_cot.csv', col_name='Comm', ffill=True)
        df_sel_Index = externaldata.get_df_sel_Index()
        #df_sel_Index.rename(columns={})
        externaldata = ExternalDataSource(df_sel_Index, 'external_data/cot', str(symbol_cot) + '_cot.csv', col_name='CoT_Index', ffill=True)
        df_sel_Index = externaldata.get_df_sel_Index()
        #externaldata = ExternalDataSource(df_sel_Index, 'external_data/cot', 'GOLD_cot.csv', 'Small', ffill=True)
        #df_sel_Index = externaldata.get_df_sel_Index()

        timeperiod = int(xyz['timeperiod'])
        timeperiod_6m = int(xyz['timeperiod_6m'])
        timeperiod_12m = 2*timeperiod_6m
        min_periods = 50
        direction = int(xyz['Direction'])
        kaufzone = int(xyz['kaufzone'])

        df_sel_Index['CoT_Index_6m'] = df_sel_Index['CoT_Index'].rolling(timeperiod_6m).mean()
        df_sel_Index['CoT_Index_12m'] = df_sel_Index['CoT_Index'].rolling(timeperiod_12m).mean()
        df_sel_Index['trend'] = df_sel_Index['Close'].rolling(timeperiod, min_periods=min_periods).mean() - df_sel_Index['Close'].rolling(timeperiod, min_periods=min_periods).mean().shift(1)
        #print(df_sel_Index[['Date', 'Close','Comm', 'CoT_Index', 'CoT_Index_6m', 'CoT_Index_12m', 'trend']].tail(20))
        #print(df_sel_Index.shape[0],df_EntrySignal.shape[0])

        #print(df_sel_Index)
        #exit()
        df_EntrySignal["Entry1"] = np.where((
                #(direction * df_sel_Index['CoT_Index_6m'] >= direction * df_sel_Index['CoT_Index_12m'])
                #& (direction * df_sel_Index['CoT_Index_6m'].shift(1) < direction * df_sel_Index['CoT_Index_12m'].shift(1))
                (direction * df_sel_Index['CoT_Index_6m'] >= kaufzone)
                & (direction * df_sel_Index['CoT_Index_12m'] >= kaufzone)
                & ((direction * df_sel_Index['CoT_Index_6m'].shift(1) < kaufzone) | (direction * df_sel_Index['CoT_Index_12m'].shift(1) < kaufzone))
        ), 1, 0)
        df_sel_Index['filter_CoT_Index_6m'] = df_sel_Index['CoT_Index_6m']
        df_sel_Index['filter_CoT_Index_12m'] = df_sel_Index['CoT_Index_12m']
        df_sel_Index['filter_CoT_Index'] = df_sel_Index['CoT_Index']
        df_sel_Index['filter_Comm'] = df_sel_Index['Comm']
        if 'Date' not in df_EntrySignal.columns:
            df_EntrySignal['Date'] = df_EntrySignal.index
        #print("Signals:", df_EntrySignal[df_EntrySignal['Entry1'] == 1].shape[0])
        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "CoT",
        "Strategy_Name": "CoT",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "FA", # TA = Technical Analysis
        "Strategy_Style": "Trend", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "ST", # ST, MT, LT
        "Timestop": 100, # nach soviel Tagen wird trade beendet
        "Initialstop": -5,
        "Initialstop_delta": [-3, -5, -10, -20], # delta wird für forward verwendet
        "Takeprofit": 20,
        "Takeprofit_delta": [5,10,20,50,100], # delta wird für forward verwendet
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "timeperiod": 50,
        "timeperiod_delta": [2,3,4,5,7, 10, 14,20, 50, 100, 200],
        "timeperiod_6m": 15,
        "timeperiod_6m_delta": [5, 10, 15, 20, 25, 50, 100],
        "kaufzone": 80,
        "kaufzone_delta": [60, 65,70,75,80,90],
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1000,
        "days_between_signals": 1, #
        "first_possible_trade": 1000,
        "Indicator_1": "SMA_200", # Indikatoren
        "Indicator_101": "CoT_Index",
        "Indicator_102": "CoT_Index_6m",
        "Indicator_103": "CoT_Index_12m",
        "Indicator_104": "const_80",
        #"Indicator_104": "trend",
    }
    return xyz, Signaler

Setup_gap_up
def Setup_gap_up():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        timeperiod = int(xyz['timeperiod'])

        gap_atr = float(xyz['gap_atr'])
        df_sel_Index['gap'] = (df_sel_Index['Open'] - df_sel_Index['High'].shift(1))/df_sel_Index['ATR_21']
        #df_sel_Index['Close-1'] = df_sel_Index['Close'].shift()
        #print(df_sel_Index[['Date', 'Open', 'High','Close','Close-1', 'gap', 'ATR_21']].head(100))
        #print(df_sel_Index[['Date', 'Open', 'High','Close','Close-1', 'gap', 'ATR_21']][df_sel_Index['gap'] >= gap_atr])
        #print("anzahl", df_sel_Index[df_sel_Index['gap'] >= gap_atr].shape[0], "gap_atr", gap_atr)
        df_EntrySignal["Entry1"] = np.where((
            (df_sel_Index['gap'] >= gap_atr)
            #& (df_sel_Index['i_vol_m_2'] >= 0)
            #& (df_sel_Index['i_lastHigh_days_10'] >= 5)
            #& (df_sel_Index['i_lastHigh_days_10'] <= 9)
            #& (df_sel_Index['i_lastHigh_days_50'] >= 20)
        ), 1, 0)
        df_sel_Index['E1'] = df_EntrySignal['Entry1']
        df_sel_Index['filter_gap'] = df_sel_Index['gap']
        df_sel_Index['filter_vol'] = df_sel_Index['Volume']/df_sel_Index['Volume'].shift(1)
        #print(df_sel_Index[['Date', 'Close','gap', 'filter_vol', 'i_lastHigh_days_10']][df_sel_Index['E1'] == 1].head(10))


        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "gap",
        "Strategy_Name": "gap",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "FA", # TA = Technical Analysis
        "Strategy_Style": "Trend", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "ST", # ST, MT, LT
        "Timestop": 200, # nach soviel Tagen wird trade beendet
        "Initialstop": -5,
        "Initialstop_delta": 0.5, # delta wird für forward verwendet
        "Takeprofit": 10,
        "Takeprofit_delta": 0.5, # delta wird für forward verwendet
        "gap_atr": 0.5,
        "gap_atr_delta": [0.2, 0.4, 0.6, 0.8, 1],
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "timeperiod": 200,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1000,
        "days_between_signals": 1, #
        "Indicator_1": "SMA_200", # Indikatoren
        #"Indicator_101": "Comm",
        #"Indicator_102": "Large",

    }
    return xyz, Signaler

SetupHindenburg
def SetupHindenburg():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        # 3 von 5:
        # 1. McClellan
        # 2. 10 week GD steigt
        # 3. Neue 52wochen Hochs > 2.2% von Geamtzahl Aktien NYSE
        # 4. Neue 52wochen Tiefs > 2.2% von Geamtzahl Aktien NYSE
        # 5. Anzahl neue Hochs <= 2 * Anzahl neuer Tiefs
        mcclellan = 'add_MCOSIRSPX'
        if mcclellan not in df_sel_Index.columns:
            externaldata = ExternalDataSource(df_sel_Index, 'external_data', mcclellan + '.csv')
            df_sel_Index = externaldata.get_df_sel_Index()
            df_sel_Index.dropna(subset=[mcclellan], inplace=True)
            df_EntrySignal = df_sel_Index[['Date']]

        externaldata = ExternalDataSource(df_sel_Index, 'external_data', 'add_NEWHINYA.csv', col_name='Close',ffill=True)
        df_sel_Index = externaldata.get_df_sel_Index()
        externaldata = ExternalDataSource(df_sel_Index, 'external_data', 'add_NEWLONYA.csv', col_name='Close',ffill=True)
        df_sel_Index = externaldata.get_df_sel_Index()

        df_EntrySignal.loc[df_EntrySignal.index[100], 'Entry1'] = 1
        #df_EntrySignal["Entry1"] = np.where((
        #    (df_sel_Index['hindenburg'] >= 3)
        #), 1, 0)

        #df_sel_Index['E1'] = df_EntrySignal['Entry1']
        #df_sel_Index['filter_gap'] = df_sel_Index['gap']
        #df_sel_Index['filter_vol'] = df_sel_Index['Volume']/df_sel_Index['Volume'].shift(1)
        #print(df_sel_Index[['Date', 'Close','gap', 'filter_vol', 'i_lastHigh_days_10']][df_sel_Index['E1'] == 1].head(10))


        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "gap",
        "Strategy_Name": "gap",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "FA", # TA = Technical Analysis
        "Strategy_Style": "Trend", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "ST", # ST, MT, LT
        "Timestop": 200, # nach soviel Tagen wird trade beendet
        "Initialstop": -5,
        "Initialstop_delta": 0.5, # delta wird für forward verwendet
        "Takeprofit": 10,
        "Takeprofit_delta": 0.5, # delta wird für forward verwendet
        "gap_atr": 0.5,
        "gap_atr_delta": [0.2, 0.4, 0.6, 0.8, 1],
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "percent", # percent oder atr
        "timeperiod": 200,
        "Trailingstop": "", # psar, donchian, zigzag
        "Trailingstop_active_after": 6,
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1000,
        "days_between_signals": 1, #
        "Indicator_1": "SMA_200", # Indikatoren
        #"Indicator_101": "Comm",
        #"Indicator_102": "Large",

    }
    return xyz, Signaler


Setup_bullkowski
def Setup_bullkowski():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):
        #print("symbol", symbol)
        pattern = xyz['pattern'].replace(',', '').replace(' ', '')
        if 'date_external' not in df_sel_Index.columns:
            #bullish_kickerdf_agg_pct_change_n_days
            #three_inside_updf_agg_pct_change_n_days
            #externaldata = ExternalDataSource(df_sel_Index, 'external_data', 'bullish_kickerdf_agg_pct_change_n_days.csv', col_name='ticker', ffill=False, print_infos=False, symbol=symbol)
            #externaldata = ExternalDataSource(df_sel_Index, 'external_data', 'three_inside_updf_agg_pct_change_n_days.csv',col_name='ticker', ffill=False, print_infos=False, symbol=symbol)
            bullkowski_filename = 'bullkowski_doublebottoms.csv'
            bullkowski_filename = 'bullkowski_triangle.csv'
            bullkowski_filename = 'bullkowski_spx_triangle.csv'
            externaldata = ExternalDataSource(df_sel_Index.copy(), 'external_data', bullkowski_filename,col_names=['ticker', 'Pattern Description','Breakout Date','Breakout'], ffill=False, print_infos=False, symbol=symbol)
            df_sel_Index = externaldata.get_df_sel_Index()
            #print("loaded ext", pattern)

        #patterns = df_sel_Index_tmp['Pattern Description'].drop_duplicates()
        #print(df_sel_Index[df_sel_Index['ticker'].isna() == False])
        #df_sel_Index_tmp['ticker'] = np.where(df_sel_Index_tmp['Breakout Date'] == '', '', df_sel_Index_tmp['ticker'])
        df_sel_Index['ticker'] = np.where(df_sel_Index['Breakout'] == 'Up', df_sel_Index['ticker'], np.nan)
        #df_sel_Index_tmp['ticker'] = np.where(df_sel_Index_tmp['ticker'] == symbol, df_sel_Index_tmp['ticker'], '')
        #df_sel_Index['ticker'] = np.where(df_sel_Index_tmp['Pattern Description'] == xyz['pattern'], df_sel_Index_tmp['ticker'], '')
        #df_sel_Index['Pattern Description'] = np.where(df_sel_Index['ticker'] == symbol,df_sel_Index['Pattern Description'], '')

        #print(symbol, "anzahl", df_sel_Index[df_sel_Index['ticker'].isna() == False].shape[0])
        df_sel_Index['ticker'] = df_sel_Index['ticker'].str.replace('^', '')
        df_sel_Index['ticker'] = df_sel_Index['ticker'].str.replace('GSPC', 'SPX')

        df_EntrySignal["Entry1"] = np.where((
                (df_sel_Index['ticker'] == symbol)
                #& (df_sel_Index['distance'] <= 0.0003)
        ), 1, 0)
        #df_sel_Index['filter_Comm'] = df_sel_Index['Comm']
        if 'Date' not in df_EntrySignal.columns:
            df_EntrySignal['Date'] = df_EntrySignal.index

        print(symbol, "Signals:", df_EntrySignal[df_EntrySignal['Entry1'] == 1].shape[0])
        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "extern",
        "Strategy_Name": "extern",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "FA", # TA = Technical Analysis
        "Strategy_Style": "Trend", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "ST", # ST, MT, LT
        "Timestop": 40,
        "Timestop_delta": [40, 80],
        "pattern":'Double bottom (DB)',
        #"pattern_delta":['Double bottom, Eve & Adam (EADB)','Double Top, Adam & Adam (AADT)'],
        "pattern_delta": ['Doublebottom(DB)', 'DoublebottomAdam&Adam(AADB)'],
        #"pattern_delta": ['Double bottom,Eve&Adam(EADB)', 'DoublebottomEve&Eve(EEDB)'],
        #"pattern_delta":['Double bottom (DB)','Double bottom, Eve & Adam (EADB)','Double Top, Eve & Adam (EADT)', 'Double bottom, Eve & Eve (EEDB)','Double Top, Adam & Adam (AADT)','Double bottom, Adam & Adam (AADB)','Double bottom, Adam & Eve (AEDB)'],
        "Initialstop": -3,
        "Takeprofit": 6,
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "atr", # percent oder atr
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1000,
        "days_between_signals": 0, #
        #"Indicator_1": "SMA_200", # Indikatoren
        "Indicator_101": "RSI_14",

    }
    return xyz, Signaler

Setup_extern
def Setup_extern():
    def Signaler(df_EntrySignal, df_sel_Index, config = '', symbol = ''):

        if 'date_external' not in df_sel_Index.columns:
            #bullish_kickerdf_agg_pct_change_n_days
            #three_inside_updf_agg_pct_change_n_days
            external_filename = 'three_inside_updf_agg_pct_change_n_days.csv'
            external_filename = '20241021_bullish_engulfingdf_agg_pct_change_n_days.csv'
            #externaldata = ExternalDataSource(df_sel_Index, 'external_data', 'bullish_kickerdf_agg_pct_change_n_days.csv', col_name='ticker', ffill=False, print_infos=False, symbol=symbol)
            externaldata = ExternalDataSource(df_sel_Index, 'external_data', external_filename,col_names=['ticker'], ffill=False, print_infos=False, symbol=symbol)
            df_sel_Index = externaldata.get_df_sel_Index()
            #except Exception as e:
            #    print("Exception loading external data in Startegy.py", e)
            #    df_sel_Index['ticker'] = ''
            #    exit()
        #print(df_sel_Index)
        #exit()
        df_sel_Index['distance'] = 0
        df_sel_Index['ticker'] = df_sel_Index['ticker'].str.replace('^', '')
        df_sel_Index['ticker'] = df_sel_Index['ticker'].str.replace('GSPC', 'SPX')
        #print(df_sel_Index[df_sel_Index['col1_pattern'] > 0])
        #print(df_sel_Index[df_sel_Index['ticker'] == symbol])
        #print("Anzahl", df_sel_Index[df_sel_Index['symbol_pattern'] == symbol].shape[0])
        #print("symbol", symbol)
        #print(df_sel_Index['ticker'].drop_duplicates())
        #exit()
        df_EntrySignal["Entry1"] = np.where((
                (df_sel_Index['ticker'] == symbol)
                #& (df_sel_Index['distance'] <= 0.0003)
        ), 1, 0)
        #df_sel_Index['filter_Comm'] = df_sel_Index['Comm']
        if 'Date' not in df_EntrySignal.columns:
            df_EntrySignal['Date'] = df_EntrySignal.index
        df_sel_Index['filter_distance'] = df_sel_Index['distance']

        #print(symbol, "Signals:", df_EntrySignal[df_EntrySignal['Entry1'] == 1].shape[0])
        #print("symbol", symbol)
        #print(df_sel_Index[['Date','ticker']])
        #print(df_sel_Index[['Date', 'ticker']].dropna())
        #exit()
        if "Exit1" not in df_EntrySignal.columns:
            df_EntrySignal["Exit1"] = np.where(df_EntrySignal['Entry1'].shift(xyz['Timestop']) == 1, 1, 0)
        return df_EntrySignal, df_sel_Index
    xyz = {
        "Strategy_Code": "extern",
        "Strategy_Name": "extern",
        "Direction": 1,
        "Strategy_Asset_Class": "Equity_Indices",
        "Analysis_Philosphy": "FA", # TA = Technical Analysis
        "Strategy_Style": "Trend", # Trend, Breakout, Meanreversion, Range, Pattern, Seasonal, Statistical
        "Timeframe": "ST", # ST, MT, LT
        "Timestop": 40, # nach soviel Tagen wird trade beendet
        "Initialstop": -3,
        "Takeprofit": 6,
        "order_typ": "next_open", # next_open oder limit oder close. Bis jetzt nur der Ausstieg, auch Einstieg?
        "sl_calc_on": "atr", # percent oder atr
        "number_open_trades_allowed": 1000, # geht ab 2 los
        "number_open_trades_per_symbol_allowed": 1000,
        "days_between_signals": 0, #
        #"Indicator_1": "SMA_200", # Indikatoren
        "Indicator_101": "RSI_14",

    }
    return xyz, Signaler