Scriverò un EA gratuitamente - pagina 161

 

Ciao a tutti, chi può scrivere un indicatore su 2 raggi con un legame al prezzo corrente?

In generale: ad una certa distanza dal prezzo (Bid e Ask) sono posti due raggi orizzontali - uno sotto, l'altro sopra. La distanza può essere impostata nelle impostazioni dell'indicatore. Grazie!

 
Radmir Serebrennikov #:

Ciao a tutti! Chi può scrivere un indicatore su 2 raggi con un legame al prezzo corrente?

In generale: ad una certa distanza dal prezzo (Bid e Ask) sono posti due raggi orizzontali - uno sotto, l'altro sopra. La distanza può essere impostata nelle impostazioni dell'indicatore. Grazie!

Codice: Dynamic High e Low

Alta e bassa dinamica

Figura 1: Dynamic High e Low

Dynamic High and Low
Dynamic High and Low
  • www.mql5.com
Индикатор без индикаторных буферов - просто две линии на постоянном расстоянии от цены
 
Vladimir Karputov #:

Codice: Dynamic High e Low


Fig. 1. Dinamica alta e bassa

GRAZIE MILLE!!!
 
Qualcuno può scrivere uno scriptor in mt5, che, dopo l'esecuzione, dia una lista di strumenti disponibili con bdb bar? Bdb bar, è anche inversione, con un minimo sotto il precedente e chiusura nel 30% superiore e viceversa, sopra e chiusura nel 30% inferiore. Ci sono circa 3 mila strumenti.
 
È sorta la necessità di fare compravendite utilizzando i dati di un file. In sostanza, un bot che prende una coppia da un file, la direzione, calcola il rischio del lotto... Ho cercato e non ho trovato nulla di simile, avete qualcosa di simile?
 
Salve. Buon anno a voi! Per favore aiutatemi ad aggiungere comandi in MQL5 per chiudere tutte le posizioni di acquisto al segnale="buy" e viceversa, tutte le posizioni di acquisto saranno chiuse al segnale="sell". Grazie in anticipo.
 
Namiq Acalov #:
Salve. Buon anno a voi! Per favore aiutatemi ad aggiungere comandi in MQL5 per chiudere tutte le posizioni di acquisto al segnale="buy" e viceversa, tutte le posizioni di acquisto saranno chiuse al segnale="sell". Grazie in anticipo.

Usa l'articoloQuasi un costruttore per creare un EA- hai bisogno del parametro'InpCloseOpposite' impostato a'true'.

input group             "Additional features"

*** 
input bool                 InpCloseOpposite        = true;          // Positions: Close opposite

*** 
Почти конструктор для создания советника
Почти конструктор для создания советника
  • www.mql5.com
Предлагаю свой набор торговых функций в виде готового советника. Представленный способ позволяет получать множество торговых стратегий простым добавлением индикаторов и изменением входных параметров.
 
Vladimir Karputov #:

Usa ilcostruttore dell'articoloQuasi per creare un EA- hai bisogno che il parametro'InpCloseOpposite' sia impostato a'true'.

Grazie Vladimir. Lo sto leggendo ora.
 

Buona sera, cari esperti. Come trovare la dimensione del lotto del primo ordine nella griglia?

La mia domanda è come specificare il valore massimo di drawdown per infopanel (il drawdown stesso è calcolato, ma è fluttuante; come ottenere il valore massimo da esso).

Sto ricevendo un buon feedback, sto provando MQL4 con esempi e mi sono bloccato con queste due posizioni come prova (

 
Namiq Acalov #:
Salve. Buon anno a voi! Per favore aiutatemi ad aggiungere comandi in MQL5 per chiudere tutte le posizioni di acquisto al segnale="buy" e viceversa, tutte le posizioni di acquisto saranno chiuse al segnale="sell". Grazie in anticipo.

La funzione è presa dal codicedi Vladimir Karputov

//+------------------------------------------------------------------+
//|                                                ClosePosition.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//---
#define    InpMagic  0
//---
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\AccountInfo.mqh>
//---
CTrade            m_trade;                      // trading object
CSymbolInfo       m_symbol;                     // symbol info object
CPositionInfo     m_position;                   // trade position object
CAccountInfo      m_account;                    // account info wrapper
//---
input double InpLots          =0.1; // Lots
input int    InpTakeProfit    =50;  // Take Profit (in pips)
//---
double            m_adjusted_point;             // point value adjusted for 3 or 5 points
double            m_take_profit=0.0;
//---
string m_name[]= {"Buy","Sell","CloseBuy","CloseSell"};
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- initialize common information
   m_symbol.Name(Symbol());                  // symbol
   m_trade.SetExpertMagicNumber(InpMagic); // magic
   m_trade.SetMarginMode();
   m_trade.SetTypeFillingBySymbol(Symbol());
//--- tuning for 3 or 5 digits
   int digits_adjust=1;
   if(m_symbol.Digits()==3 || m_symbol.Digits()==5)
      digits_adjust=10;
   m_adjusted_point=m_symbol.Point()*digits_adjust;
//--- set default deviation for trading in adjusted points
   m_take_profit     =InpTakeProfit*m_adjusted_point;
//--- set default deviation for trading in adjusted points
   m_trade.SetDeviationInPoints(3*digits_adjust);
//---
   int u=15;
   for(int y=0; y<ArraySize(m_name); y++)
     {
      ButtonCreate(m_name[y],5,u,170,15,8);
      u=u+17;
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   for(int y=0; y<ArraySize(m_name); y++)
     {
      ObjectDelete(0,Symbol()+m_name[y]);
     }
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(!RefreshRates())
      return;
   if(ObjectGetInteger(0,Symbol()+"Buy",OBJPROP_STATE)!=0)
     {
      ObjectSetInteger(0,Symbol()+"Buy",OBJPROP_STATE,0);
      double priceAsk=m_symbol.Ask();
      double tpAsk   =m_symbol.Bid()+m_take_profit;
      //--- check for free money
      if(m_account.FreeMarginCheck(Symbol(),ORDER_TYPE_BUY,InpLots,priceAsk)<0.0)
         printf("We have no money. Free Margin = %f",m_account.FreeMargin());
      else
        {
         //--- open position
         if(m_trade.PositionOpen(Symbol(),ORDER_TYPE_BUY,InpLots,priceAsk,0.0,tpAsk))
            printf("Position by %s to be opened",Symbol());
         else
           {
            printf("Error opening BUY position by %s : '%s'",Symbol(),m_trade.ResultComment());
            printf("Open parameters : price=%f,TP=%f",priceAsk,tpAsk);
           }
        }
     }
   if(ObjectGetInteger(0,Symbol()+"Sell",OBJPROP_STATE)!=0)
     {
      ObjectSetInteger(0,Symbol()+"Sell",OBJPROP_STATE,0);
      double priceBid=m_symbol.Bid();
      double tpBid   =m_symbol.Ask()-m_take_profit;
      //--- check for free money
      if(m_account.FreeMarginCheck(Symbol(),ORDER_TYPE_SELL,InpLots,priceBid)<0.0)
         printf("We have no money. Free Margin = %f",m_account.FreeMargin());
      else
        {
         //--- open position
         if(m_trade.PositionOpen(Symbol(),ORDER_TYPE_SELL,InpLots,priceBid,0.0,tpBid))
            printf("Position by %s to be opened",Symbol());
         else
           {
            printf("Error opening SELL position by %s : '%s'",Symbol(),m_trade.ResultComment());
            printf("Open parameters : price=%f,TP=%f",priceBid,tpBid);
           }
        }
     }
   if(ObjectGetInteger(0,Symbol()+"CloseBuy",OBJPROP_STATE)!=0)
     {
      ObjectSetInteger(0,Symbol()+"CloseBuy",OBJPROP_STATE,0);
      ClosePositions(POSITION_TYPE_BUY);
     }
   if(ObjectGetInteger(0,Symbol()+"CloseSell",OBJPROP_STATE)!=0)
     {
      ObjectSetInteger(0,Symbol()+"CloseSell",OBJPROP_STATE,0);
      ClosePositions(POSITION_TYPE_SELL);
     }
  }
//+------------------------------------------------------------------+
//| Refreshes the symbol quotes data                                 |
//+------------------------------------------------------------------+
bool RefreshRates(void)
  {
//--- refresh rates
   if(!m_symbol.RefreshRates())
     {
      Print(__FILE__," ",__FUNCTION__,", ERROR: ","RefreshRates error");
      return(false);
     }
//--- protection against the return value of "zero"
   if(m_symbol.Ask()==0 || m_symbol.Bid()==0)
     {
      Print(__FILE__," ",__FUNCTION__,", ERROR: ","Ask == 0.0 OR Bid == 0.0");
      return(false);
     }
//---
   return(true);
  }
//+------------------------------------------------------------------+
//| Close positions                                                  |
//+------------------------------------------------------------------+
void ClosePositions(const ENUM_POSITION_TYPE pos_type)
  {
   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of current positions
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==InpMagic)
            if(m_position.PositionType()==pos_type)
              {
               if(m_position.PositionType()==POSITION_TYPE_BUY)
                 {
                  if(!m_trade.PositionClose(m_position.Ticket())) // close a position by the specified m_symbol
                     Print(__FILE__," ",__FUNCTION__,", ERROR: ","BUY PositionClose ",m_position.Ticket(),", ",m_trade.ResultRetcodeDescription());
                 }
               if(m_position.PositionType()==POSITION_TYPE_SELL)
                 {
                  if(!m_trade.PositionClose(m_position.Ticket())) // close a position by the specified m_symbol
                     Print(__FILE__," ",__FUNCTION__,", ERROR: ","SELL PositionClose ",m_position.Ticket(),", ",m_trade.ResultRetcodeDescription());
                 }
              }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ButtonCreate(string name,int Xdist,int Ydist,int Xsize,int Ysize,int FONTSIZE=12)
  {
   if(ObjectFind(0,Symbol()+name)<0)
      ObjectCreate(0,Symbol()+name,OBJ_BUTTON,0,100,100);
   ObjectSetInteger(0,Symbol()+name,OBJPROP_COLOR,clrWhite);
   ObjectSetInteger(0,Symbol()+name,OBJPROP_BGCOLOR,clrDimGray);
   ObjectSetInteger(0,Symbol()+name,OBJPROP_XDISTANCE,Xdist);
   ObjectSetInteger(0,Symbol()+name,OBJPROP_YDISTANCE,Ydist);
   ObjectSetInteger(0,Symbol()+name,OBJPROP_XSIZE,Xsize);
   ObjectSetInteger(0,Symbol()+name,OBJPROP_YSIZE,Ysize);
   ObjectSetString(0,Symbol()+name,OBJPROP_FONT,"Sans Serif");
   ObjectSetString(0,Symbol()+name,OBJPROP_TEXT,name);
   ObjectSetInteger(0,Symbol()+name,OBJPROP_FONTSIZE,FONTSIZE);
   ObjectSetInteger(0,Symbol()+name,OBJPROP_SELECTABLE,false);
  }
//+------------------------------------------------------------------+