Skip to content
TheChatArchiveThe Chat Archive
Mistralmagistral-medium-2506· Mistral AIHugging Face LMArena Human Preference 140K

partendo dal cambio euro dollaro degli ultimi 15 anni time frame 1 ora mi scrivi un…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Kimikimi-k2-0711-preview’s answer.
  1. User

    partendo dal cambio euro dollaro degli ultimi 15 anni time frame 1 ora mi scrivi un expert advisor che abbia comunque guadagnato un 200% del valore di inizio anno ogni anno, impostando anche eventuali stop loss, tecniche di determianzione del lotto.

  2. Mistral Assistant

    Expert Advisor per EUR/USD con rendimento del 200% annuo

    Ecco un esempio di Expert Advisor (EA) per il trading su EUR/USD con un timeframe di 1 ora, che cerca di massimizzare i profitti utilizzando una strategia basata su crossover di medie mobili, con una gestione del rischio adeguata.

    Strategia di Trading

    La strategia utilizzata è basata su crossover di medie mobili:

    • Media mobile a breve termine (10 periodi)
    • Media mobile a lungo termine (50 periodi)

    Quando la media mobile a breve termine incrocia al rialzo quella a lungo termine, l'EA apre una posizione long. Quando incrocia al ribasso, l'EA apre una posizione short.

    Gestione del Rischio

    L'EA include le seguenti tecniche di gestione del rischio:

    • Stop loss fisso (50 pip)
    • Take profit fisso (100 pip)
    • Determinazione del lotto basata sul rischio (1% del capitale per trade)

    Codice MQL4

    //+------------------------------------------------------------------+
    //|                                                      MyEA.mq4     |
    //|                        Copyright 2023, Your Name                |
    //+------------------------------------------------------------------+
    #property strict
    
    // Input parameters
    extern double RiskPercentage = 1.0; // 1% del capitale per trade
    extern int StopLossPips = 50;
    extern int TakeProfitPips = 100;
    extern int FastMAPeriod = 10;
    extern int SlowMAPeriod = 50;
    
    //+------------------------------------------------------------------+
    //| Expert initialization function                                   |
    //+------------------------------------------------------------------+
    int OnInit()
    {
       return(INIT_SUCCEEDED);
    }
    
    //+------------------------------------------------------------------+
    //| Expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
    }
    
    //+------------------------------------------------------------------+
    //| Calculate lot size based on risk                                  |
    //+------------------------------------------------------------------+
    double CalculateLotSize(double riskPercentage, double stopLossPips, double accountBalance)
    {
       double riskAmount = accountBalance * riskPercentage / 100;
       double pipValue = MarketInfo(Symbol(), MODE_TICKVALUE) * 100000; // Value of one pip for a standard lot (100,000 units)
       double lotSize = riskAmount / (stopLossPips * pipValue);
       return lotSize;
    }
    
    //+------------------------------------------------------------------+
    //| Expert tick function                                             |
    //+------------------------------------------------------------------+
    void OnTick()
    {
       double fastMA = iMA(NULL, 0, FastMAPeriod, 0, MODE_SMA, PRICE_CLOSE, 0);
       double slowMA = iMA(NULL, 0, SlowMAPeriod, 0, MODE_SMA, PRICE_CLOSE, 0);
       double accountBalance = AccountBalance();
       double lotSize = CalculateLotSize(RiskPercentage, StopLossPips, accountBalance);
    
       // Check for open positions
       bool hasBuyPosition = false;
       bool hasSellPosition = false;
    
       for (int i = 0; i < OrdersTotal(); i++)
       {
          if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
          {
             if (OrderSymbol() == Symbol() && OrderType() == OP_BUY)
                hasBuyPosition = true;
             if (OrderSymbol() == Symbol() && OrderType() == OP_SELL)
                hasSellPosition = true;
          }
       }
    
       // Trading logic
       if (fastMA > slowMA && !hasBuyPosition)
       {
          // Close any sell positions
          if (hasSellPosition)
          {
             for (int i = 0; i < OrdersTotal(); i++)
             {
                if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
                {
                   if (OrderSymbol() == Symbol() && OrderType() == OP_SELL)
                      OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrRed);
                }
             }
          }
          // Open a buy position
          double sl = Bid - StopLossPips * Point;
          double tp = Bid + TakeProfitPips * Point;
          int ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, sl, tp, "Buy Order", 0, 0, clrGreen);
          if (ticket < 0)
             Print("Errore nell'apertura dell'ordine: ", GetLastError());
       }
       else if (fastMA < slowMA && !hasSellPosition)
       {
          // Close any buy positions
          if (hasBuyPosition)
          {
             for (int i = 0; i < OrdersTotal(); i++)
             {
                if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
                {
                   if (OrderSymbol() == Symbol() && OrderType() == OP_BUY)
                      OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrRed);
                }
             }
          }
          // Open a sell position
          double sl = Ask + StopLossPips * Point;
          double tp = Ask - TakeProfitPips * Point;
          int ticket = OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, sl, tp, "Sell Order", 0, 0, clrRed);
          if (ticket < 0)
             Print("Errore nell'apertura dell'ordine: ", GetLastError());
       }
    }
    

    Considerazioni Finali

    Un rendimento del 200% annuo è estremamente ambizioso e probabilmente irrealistico. Tuttavia, questo EA cerca di massimizzare i profitti utilizzando una strategia basata su crossover di medie mobili, con una gestione del rischio adeguata. È importante eseguire un backtest su dati storici per verificare le prestazioni dell'EA e ottimizzare i parametri per massimizzare i profitti. Tuttavia, è fondamentale ricordare che nessun EA può garantire rendimenti costanti e che il trading comporta sempre un rischio di perdita.

  3. User

    aggiungi all'expert che hai programmato i seguenti elementi: Evitare trading in prossimità di NFP o ECB (news filter). Aggiungere filtro orario (es. solo 08-18 CET).

  4. Mistral Assistant

    Expert Advisor per EUR/USD con Filtri per News e Orario

    Ecco un esempio di Expert Advisor (EA) per il trading su EUR/USD con un timeframe di 1 ora, che include filtri per evitare il trading in prossimità di eventi importanti come il Non-Farm Payrolls (NFP) o le riunioni della Banca Centrale Europea (ECB), e che opera solo in un determinato intervallo orario (08:00-18:00 CET).

    Strategia di Trading

    La strategia utilizzata è basata su crossover di medie mobili:

    • Media mobile a breve termine (10 periodi)
    • Media mobile a lungo termine (50 periodi)

    Quando la media mobile a breve termine incrocia al rialzo quella a lungo termine, l'EA apre una posizione long. Quando incrocia al ribasso, l'EA apre una posizione short.

    Gestione del Rischio

    L'EA include le seguenti tecniche di gestione del rischio:

    • Stop loss fisso (50 pip)
    • Take profit fisso (100 pip)
    • Determinazione del lotto basata sul rischio (1% del capitale per trade)

    Filtri Aggiuntivi

    1. Filtro per le News: L'EA evita di fare trading se siamo entro un certo numero di ore (specificato da NewsBufferHours) da un evento importante come NFP o ECB.
    2. Filtro Orario: L'EA opera solo tra le 08:00 e le 18:00 CET.

    Codice MQL4

    //+------------------------------------------------------------------+
    //|                                                      MyEA.mq4     |
    //|                        Copyright 2023, Your Name                |
    //+------------------------------------------------------------------+
    #property strict
    
    // Input parameters
    extern double RiskPercentage = 1.0; // 1% del capitale per trade
    extern int StopLossPips = 50;
    extern int TakeProfitPips = 100;
    extern int FastMAPeriod = 10;
    extern int SlowMAPeriod = 50;
    extern int CETOffset = 1; // Offset UTC per CET (1 per ora solare, 2 per ora legale)
    extern int StartHour = 8; // Ora di inizio trading (CET)
    extern int EndHour = 18; // Ora di fine trading (CET)
    extern int NewsBufferHours = 2; // Numero di ore prima/dopo un evento news da evitare
    
    // Struttura per gli eventi news
    struct NewsEvent {
        datetime dateTime;
        string name;
    };
    
    NewsEvent newsEvents[];
    int newsEventsCount = 0;
    
    //+------------------------------------------------------------------+
    //| Expert initialization function                                   |
    //+------------------------------------------------------------------+
    int OnInit()
    {
       // Aggiungi eventi news importanti (esempio)
       AddNewsEvent(D'2023.01.06 13:30', "NFP");
       AddNewsEvent(D'2023.02.03 13:30', "NFP");
       AddNewsEvent(D'2023.03.10 13:30', "NFP");
       AddNewsEvent(D'2023.04.07 13:30', "NFP");
       AddNewsEvent(D'2023.05.05 13:30', "NFP");
       AddNewsEvent(D'2023.06.02 13:30', "NFP");
       AddNewsEvent(D'2023.07.07 13:30', "NFP");
       AddNewsEvent(D'2023.08.04 13:30', "NFP");
       AddNewsEvent(D'2023.09.01 13:30', "NFP");
       AddNewsEvent(D'2023.10.06 13:30', "NFP");
       AddNewsEvent(D'2023.11.03 13:30', "NFP");
       AddNewsEvent(D'2023.12.01 13:30', "NFP");
    
       // Aggiungi riunioni ECB (esempio)
       AddNewsEvent(D'2023.01.26 13:45', "ECB");
       AddNewsEvent(D'2023.02.16 13:45', "ECB");
       AddNewsEvent(D'2023.03.16 13:45', "ECB");
       AddNewsEvent(D'2023.04.13 13:45', "ECB");
       AddNewsEvent(D'2023.05.04 13:45', "ECB");
       AddNewsEvent(D'2023.06.15 13:45', "ECB");
       AddNewsEvent(D'2023.07.27 13:45', "ECB");
       AddNewsEvent(D'2023.09.14 13:45', "ECB");
       AddNewsEvent(D'2023.10.26 13:45', "ECB");
       AddNewsEvent(D'2023.12.14 13:45', "ECB");
    
       return(INIT_SUCCEEDED);
    }
    
    //+------------------------------------------------------------------+
    //| Aggiungi un evento news                                           |
    //+------------------------------------------------------------------+
    void AddNewsEvent(datetime dateTime, string name) {
        newsEventsCount++;
        ArrayResize(newsEvents, newsEventsCount);
        newsEvents[newsEventsCount-1].dateTime = dateTime;
        newsEvents[newsEventsCount-1].name = name;
    }
    
    //+------------------------------------------------------------------+
    //| Controlla se siamo vicini a un evento news                       |
    //+------------------------------------------------------------------+
    bool IsNearNewsEvent() {
        datetime currentTime = TimeCurrent();
        for (int i = 0; i < newsEventsCount; i++) {
            datetime eventTime = newsEvents[i].dateTime;
            if (currentTime >= eventTime - NewsBufferHours * 3600 && currentTime <= eventTime + NewsBufferHours * 3600) {
                return true;
            }
        }
        return false;
    }
    
    //+------------------------------------------------------------------+
    //| Controlla se siamo nell'intervallo orario di trading              |
    //+------------------------------------------------------------------+
    bool IsTradingTime() {
        datetime currentTime = TimeCurrent();
        // Converti il tempo corrente in CET
        datetime cetTime = currentTime + CETOffset * 3600;
        int currentHour = Hour(cetTime);
        if (currentHour >= StartHour && currentHour < EndHour) {
            return true;
        }
        return false;
    }
    
    //+------------------------------------------------------------------+
    //| Calculate lot size based on risk                                  |
    //+------------------------------------------------------------------+
    double CalculateLotSize(double riskPercentage, double stopLossPips, double accountBalance)
    {
       double riskAmount = accountBalance * riskPercentage / 100;
       double pipValue = MarketInfo(Symbol(), MODE_TICKVALUE) * 100000; // Value of one pip for a standard lot (100,000 units)
       double lotSize = riskAmount / (stopLossPips * pipValue);
       return lotSize;
    }
    
    //+------------------------------------------------------------------+
    //| Expert deinitialization function                                 |
    //+------------------------------------------------------------------+
    void OnDeinit(const int reason)
    {
    }
    
    //+------------------------------------------------------------------+
    //| Expert tick function                                             |
    //+------------------------------------------------------------------+
    void OnTick()
    {
       // Controlla se siamo vicini a un evento news o fuori dall'orario di trading
       if (IsNearNewsEvent() || !IsTradingTime()) {
          return; // Non fare trading se siamo vicini a un evento news o fuori dall'orario di trading
       }
    
       double fastMA = iMA(NULL, 0, FastMAPeriod, 0, MODE_SMA, PRICE_CLOSE, 0);
       double slowMA = iMA(NULL, 0, SlowMAPeriod, 0, MODE_SMA, PRICE_CLOSE, 0);
       double accountBalance = AccountBalance();
       double lotSize = CalculateLotSize(RiskPercentage, StopLossPips, accountBalance);
    
       // Check for open positions
       bool hasBuyPosition = false;
       bool hasSellPosition = false;
    
       for (int i = 0; i < OrdersTotal(); i++)
       {
          if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
          {
             if (OrderSymbol() == Symbol() && OrderType() == OP_BUY)
                hasBuyPosition = true;
             if (OrderSymbol() == Symbol() && OrderType() == OP_SELL)
                hasSellPosition = true;
          }
       }
    
       // Trading logic
       if (fastMA > slowMA && !hasBuyPosition)
       {
          // Close any sell positions
          if (hasSellPosition)
          {
             for (int i = 0; i < OrdersTotal(); i++)
             {
                if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
                {
                   if (OrderSymbol() == Symbol() && OrderType() == OP_SELL)
                      OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrRed);
                }
             }
          }
          // Open a buy position
          double sl = Bid - StopLossPips * Point;
          double tp = Bid + TakeProfitPips * Point;
          int ticket = OrderSend(Symbol(), OP_BUY, lotSize, Ask, 3, sl, tp, "Buy Order", 0, 0, clrGreen);
          if (ticket < 0)
             Print("Errore nell'apertura dell'ordine: ", GetLastError());
       }
       else if (fastMA < slowMA && !hasSellPosition)
       {
          // Close any buy positions
          if (hasBuyPosition)
          {
             for (int i = 0; i < OrdersTotal(); i++)
             {
                if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
                {
                   if (OrderSymbol() == Symbol() && OrderType() == OP_BUY)
                      OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrRed);
                }
             }
          }
          // Open a sell position
          double sl = Ask + StopLossPips * Point;
          double tp = Ask - TakeProfitPips * Point;
          int ticket = OrderSend(Symbol(), OP_SELL, lotSize, Bid, 3, sl, tp, "Sell Order", 0, 0, clrRed);
          if (ticket < 0)
             Print("Errore nell'apertura dell'ordine: ", GetLastError());
       }
    }
    

    Considerazioni Finali

    • Aggiornamento degli Eventi News: Gli eventi news devono essere aggiornati manualmente nel codice. Potresti voler creare un sistema per aggiornare questi eventi automaticamente, forse leggendo da un file esterno o utilizzando un servizio web.
    • Gestione dell'Ora Legale: L'offset per CET è impostato manualmente. Potresti voler implementare una logica per gestire automaticamente l'ora legale.
    • Backtesting: Ricorda che questo EA deve essere testato accuratamente su dati storici per verificare le sue prestazioni. Un rendimento del 200% annuo è estremamente ambizioso e potrebbe non essere realisticamente raggiungibile.

    Questo EA include i filtri richiesti per evitare il trading in prossimità di eventi importanti e per operare solo in un determinato intervallo orario. Tuttavia, è importante ricordare che nessun EA può garantire rendimenti costanti e che il trading comporta sempre un rischio di perdita.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.