//+------------------------------------------------------------------+ //| FiatLibsForex.mqh | //| Copyright 2024, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2024, MetaQuotes Ltd." #property link "https://www.mql5.com" //+------------------------------------------------------------------+ //| defines | //+------------------------------------------------------------------+ // #define MacrosHello "Hello, world!" // #define MacrosYear 2010 //+------------------------------------------------------------------+ //| DLL imports | //+------------------------------------------------------------------+ // #import "user32.dll" // int SendMessageA(int hWnd,int Msg,int wParam,int lParam); // #import "my_expert.dll" // int ExpertRecalculate(int wParam,int lParam); // #import //+------------------------------------------------------------------+ //| EX5 imports | //+------------------------------------------------------------------+ // #import "stdlib.ex5" // string ErrorDescription(int error_code); // #import //+------------------------------------------------------------------+ //--- service objects CTrade trade; MqlRates rates[]; CTrade ExtTrade; CSymbolInfo ExtSymbolInfo; //############################################## //#constantes definidas para uso em todo o robo# //############################################## #define SIGNAL_BUY 1 // Buy signal #define SIGNAL_NOT 0 // no trading signal #define SIGNAL_SELL -1 // Sell signal #define CLOSE_LONG 2 // signal to close Long #define CLOSE_SHORT -2 // signal to close Short #define TAMANHO_LOTE 5 #define ROBO_NAME "Robo Fiat147-Spazio-Forex" #define ROBO_VERSION "v1.0.0" //############################################################## //#variaveis globais # //############################################################## //--- global variables int ExtAvgBodyPeriod, // average candlestick calculation period ExtSignalOpen =0, // Buy/Sell signal ExtSignalClose =0, // signal to close a position ExtIndicatorHandle=INVALID_HANDLE, ExtTrendMAHandle =INVALID_HANDLE; bool ExtPatternDetected=false, // pattern detected ExtConfirmed =false, // pattern confirmed ExtCloseByTime =true, // requires closing by time ExtCheckPassed =true; // status checking error double maxAtual = 0.00, minAtual = 0.00, maxPrev = 0.00, minPrev = 0.00, openAtual = 0.00, closeAtual = 0.00, amplitudeCandle = 0.00, entrada = 0.00, tamanhoLote = 0.01, pontoFiboProfit = 1.618, takeProfit = 0.00; string dataIntraday = NULL, ExtPatternInfo ="", // current pattern information ExtDirection =""; // position opening direction //############################################################## //#variaveis de input de parametros para o grafico # //############################################################## //--- Input parameters input int InpAverBodyPeriod = 12; // period for calculating average candlestick size input int InpMAPeriod = 5; // Trend MA period input int InpPeriodRSI = 37; // RSI period input int InpPeriodCCI = 37; // CCI period input int InpPeriodMFI = 37; // MFI period input int InpStochK = 47; // period %K input int InpStochD = 9; // period %D input int InpStochSlow = 13; // smoothing period %K input ENUM_STO_PRICE InpStochApplied = STO_LOWHIGH; // calculation type input ENUM_MA_METHOD InpStochMA = MODE_SMA; // smoothing type input ENUM_APPLIED_PRICE InpPrice = PRICE_CLOSE; // price type input ENUM_APPLIED_VOLUME InpVolume = VOLUME_TICK; // volume type //--- trade parameters input uint InpDuration=10; // position holding time in bars input uint InpSL =200; // Stop Loss in points input uint InpTP =400; // Take Profit in points input uint InpSlippage=10; // slippage in points //--- money management parameters input double InpLot = TAMANHO_LOTE; // lot //--- Expert ID input long InpMagicNumber=120700; // Magic Number //############################################################## //#funcao que ir centralizar todas as msg de saida para o chart# //############################################################## void setMsgChart(string pMsg=NULL) { //comment imprime msg no chart Comment(pMsg); //print imprime msg nos logs da caixa de ferramentas Print(pMsg); //abre uma caixa de msgDialog //Alert(pMsg); } void initMsgChart() { string msg = ROBO_NAME + "-" + ROBO_VERSION; Comment(msg); Print(msg); } //################################################################ //#funcoes genericas ultilizadas por todas as estrategias do robo# //################################################################ //+------------------------------------------------------------------+ //| Checks position closing time in bars | //+------------------------------------------------------------------+ int BarsHold(datetime open_time) { //--- first run a basic simple check if(TimeCurrent()-open_time