iRSI Open Close Multisymbol

Author: Copyright © 2021, Vladimir Karputov
0 Views
0 Downloads
0 Favorites
iRSI Open Close Multisymbol
ÿþ//+------------------------------------------------------------------+

//|                                  iRSI Open Close Multisymbol.mq5 |

//|                              Copyright © 2021, Vladimir Karputov |

//|                      https://www.mql5.com/en/users/barabashkakvn |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2021, Vladimir Karputov"

#property link      "https://www.mql5.com/en/users/barabashkakvn"

#property version   "1.000"

//---

#include <Trade\SymbolInfo.mqh>

#include "TradingEngine4.mqh"

#include <Arrays\ArrayObj.mqh>

CArrayObj      m_array_obj;

//--- input parameters

input string               InpSymbols              = "GBPUSD;EURGBP;CADJPY;NZDJPY;AUDJPY;USDJPY;AUDUSD;AUDCAD;NZDUSD;USDCAD"; // Symbols

input group             "Trading settings"

input ENUM_TIMEFRAMES      InpWorkingPeriod        = PERIOD_CURRENT; // Working timeframe

input ENUM_BAR_CURRENT     InpSignalsBarCurrent    = bar_1;          // Search signals on ...

input group             "Position size management (lot calculation)"

input double               InpLots                 = 0.01;           // Lots

input group             "RSI"

input int                  Inp_RSI_ma_period       = 14;             // RSI: averaging period

input ENUM_APPLIED_PRICE   Inp_RSI_applied_price   = PRICE_CLOSE;    // RSI: type of price

input double               Inp_RSI_Level_UP        = 70;             // RSI Level UP (70)

input double               Inp_RSI_Level_DOWN      = 30;             // RSI Level DOWN (30)

input group             "Additional features"

input bool                 InpOnlyOne              = false;          // Positions: Only one

input bool                 InpReverse              = false;          // Positions: Reverse

input bool                 InpPrintLog             = true;           // Print log

input uchar                InpFreezeCoefficient    = 1;              // Coefficient (if Freeze==0 Or StopsLevels==0)

input ulong                InpDeviation            = 10;             // Deviation, in Points (1.00045-1.00055=10 points)

input ulong                InpMagic                = 288018148;      // Magic number

//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

//---

   CSymbolInfo    m_symbol_temp;    // object of CSymbolInfo class

   string to_split=InpSymbols;      // a string to split into substrings

   string sep=";";                  // a separator as a character

   ushort u_sep;                    // the code of the separator character

   string result[];                 // an array to get strings

//--- Get the separator code

   u_sep=StringGetCharacter(sep,0);

//--- Split the string to substrings

   int k=StringSplit(to_split,u_sep,result);

//--- Show a comment

   PrintFormat("Strings obtained: %d. Used separator '%s' with the code %d",k,sep,u_sep);

//--- Now output all obtained strings

   if(k>0)

     {

      for(int i=0; i<k; i++)

        {

         PrintFormat("result[%d]=\"%s\"",i,result[i]);

        }

     }

//---

   for(int i=0; i<k; i++)

     {

      if(m_symbol_temp.Name(Symbol())) // sets symbol name

        {

         CTradingEngine4 *multi=new CTradingEngine4;

         if(multi==NULL)

           {

            Print("Object CTradingEngine4 create error");

            return(INIT_FAILED);

           }

         m_array_obj.Add(multi);

         int init=multi.OnInit(result[i],

                               // "Trading settings"

                               InpWorkingPeriod,            // Working timeframe

                               InpSignalsBarCurrent,        // Search signals on ...

                               // "Position size management (lot calculation)"

                               InpLots,                     // Lots

                               // "RSI"

                               Inp_RSI_ma_period,           // RSI: averaging period

                               Inp_RSI_applied_price,       // RSI: type of price

                               Inp_RSI_Level_UP,            // RSI Level UP (70)

                               Inp_RSI_Level_DOWN,          // RSI Level DOWN (30)

                               // "Additional features"

                               InpOnlyOne,                  // Positions: Only one

                               InpReverse,                  // Positions: Reverse

                               InpPrintLog,                 // Print log

                               InpDeviation,                // Deviation, in Points (1.00045-1.00055=10 points)

                               InpMagic                     // Magic number

                              );

         if(init!=INIT_SUCCEEDED)

            return(init);

        }

     }

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---

   for(int i=0; i<m_array_obj.Total(); i++)

     {

      CTradingEngine4 *multi=m_array_obj.At(i);

      if(multi==NULL)

        {

         //--- Error reading from array

         Print("Object CMultiGrid create error");

         return;

        }

      multi.OnDeinit(reason);

     }

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

//---

   for(int i=0; i<m_array_obj.Total(); i++)

     {

      CTradingEngine4 *multi=m_array_obj.At(i);

      if(multi==NULL)

        {

         //--- Error reading from array

         Print("Object CMultiGrid create error");

         return;

        }

      multi.OnTick();

     }

  }

//+------------------------------------------------------------------+

//| TradeTransaction function                                        |

//+------------------------------------------------------------------+

void OnTradeTransaction(const MqlTradeTransaction &trans,

                        const MqlTradeRequest &request,

                        const MqlTradeResult &result)

  {

//---

   for(int i=0; i<m_array_obj.Total(); i++)

     {

      CTradingEngine4 *multi=m_array_obj.At(i);

      if(multi==NULL)

        {

         //--- Error reading from array

         Print("Object CMultiiMATrend create error");

         return;

        }

      multi.OnTradeTransaction(trans,request,result);

     }

  }

//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---