Regr Three Strategies

Author: Copyright © 2019, Vladimir Karputov
0 Views
0 Downloads
0 Favorites
Regr Three Strategies
ÿþ//+------------------------------------------------------------------+

//|                                        Regr Three Strategies.mq5 |

//|                              Copyright © 2019, Vladimir Karputov |

//|                                           http://wmua.ru/slesar/ |

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

#property copyright "Copyright © 2019, Vladimir Karputov"

#property link      "http://wmua.ru/slesar/"

#property version   "1.000"

/*

   barabashkakvn Trading engine 3.023

*/

#include <CRegrThreeStrategies.mqh>

#include <Arrays\ArrayObj.mqh>

CArrayObj      m_array_obj;   // CArrayObj object

//--- Linear: input parameters

input bool     InpUseLinear               = true;        // Use Linear

input bool     InpCurrentBarZeroLinear    = false;       // Linear: Current Bar Zero

input ushort   InpStopLossLinear          = 45;          // Linear: Stop Loss, in pips (1.00045-1.00055=1 pips)

input ushort   InpTakeProfitLinear        = 250;         // Linear: Take Profit, in pips (1.00045-1.00055=1 pips)

input ushort   InpTrailingFrequencyLinear = 10;          // Linear: Trailing, in seconds (< "10" -> only on a new bar)

input ushort   InpSignalsFrequencyLinear  = 9;           // Linear: Search signals, in seconds (< "10" -> only on a new bar)

input ushort   InpTrailingStopLinear      = 45;          // Linear: Trailing Stop (min distance from price to Stop Loss, in pips

input ushort   InpTrailingStepLinear      = 5;           // Linear: Trailing Step, in pips (1.00045-1.00055=1 pips)

input ENUM_LOT_OR_RISK InpLotOrRiskLinear = lots_min;    // Linear: Money management: Lot OR Risk

input double   InpVolumeLotOrRiskLinear   = 3.0;         // Linear: The value for "Money management"

input double   Inp_Linear_kstd            = 1.5;         // i-Regr Linear: kstd

input int      Inp_Linear_bars            = 250;         // i-Regr Linear: bars

input int      Inp_Linear_shift           = 0;           // i-Regr Linear: shift

input bool     InpOnlyOneLinear           = false;       // Linear: Only one positions 

input bool     InpReverseLinear           = true;        // Linear: Reverse

input bool     InpCloseOppositeLinear     = true;        // Linear: Close opposite

input bool     InpPrintLogLinear          = false;       // Linear: Print log

input ulong    InpMagicLinear             = 489419974;   // Linear: Magic number 

//--- Parabolic: input parameters

input bool     InpUseParabolic               = true;        // Use Parabolic

input bool     InpCurrentBarZeroParabolic    = false;       // Parabolic: Current Bar Zero

input ushort   InpStopLossParabolic          = 45;          // Parabolic: Stop Loss, in pips (1.00045-1.00055=1 pips)

input ushort   InpTakeProfitParabolic        = 180;         // Parabolic: Take Profit, in pips (1.00045-1.00055=1 pips)

input ushort   InpTrailingFrequencyParabolic = 10;          // Parabolic: Trailing, in seconds (< "10" -> only on a new bar)

input ushort   InpSignalsFrequencyParabolic  = 9;           // Parabolic: Search signals, in seconds (< "10" -> only on a new bar)

input ushort   InpTrailingStopParabolic      = 25;          // Parabolic: Trailing Stop (min distance from price to Stop Loss, in pips

input ushort   InpTrailingStepParabolic      = 5;           // Parabolic: Trailing Step, in pips (1.00045-1.00055=1 pips)

input ENUM_LOT_OR_RISK InpLotOrRiskParabolic = lots_min;    // Parabolic: Money management: Lot OR Risk

input double   InpVolumeLotOrRiskParabolic   = 3.0;         // Parabolic: The value for "Money management"

input double   Inp_Parabolic_kstd         = 1.5;      // i-Regr Parabolic: kstd

input int      Inp_Parabolic_bars         = 250;      // i-Regr Parabolic: bars

input int      Inp_Parabolic_shift        = 0;        // i-Regr Parabolic: shift

input bool     InpOnlyOneParabolic        = false;    // Parabolic: Only one positions 

input bool     InpReverseParabolic        = false;    // Parabolic: Reverse

input bool     InpCloseOppositeParabolic  = false;    // Parabolic: Close opposite

input bool     InpPrintLogParabolic       = false;    // Parabolic: Print log

input ulong    InpMagicParabolic          = 89419975; // Parabolic: Magic number 

//--- Third Power: input parameters

input bool     InpUseThird                = true;        // Use Third Power

input bool     InpCurrentBarZeroThird     = false;       // Third Power: Current Bar Zero

input ushort   InpStopLossThird           = 45;          // Third Power: Stop Loss, in pips (1.00045-1.00055=1 pips)

input ushort   InpTakeProfitThird         = 180;         // Third Power: Take Profit, in pips (1.00045-1.00055=1 pips)

input ushort   InpTrailingFrequencyThird  = 10;          // Third Power: Trailing, in seconds (< "10" -> only on a new bar)

input ushort   InpSignalsFrequencyThird   = 9;           // Third Power: Search signals, in seconds (< "10" -> only on a new bar)

input ushort   InpTrailingStopThird       = 25;          // Third Power: Trailing Stop (min distance from price to Stop Loss, in pips

input ushort   InpTrailingStepThird       = 5;           // Third Power: Trailing Step, in pips (1.00045-1.00055=1 pips)

input ENUM_LOT_OR_RISK InpLotOrRiskThird  = lots_min;    // Third Power: Money management: Lot OR Risk

input double   InpVolumeLotOrRiskThird    = 3.0;         // Third Power: The value for "Money management"

input double   Inp_Third_kstd          = 1.5;         // i-Regr Third Power: kstd

input int      Inp_Third_bars          = 250;         // i-Regr Third Power: bars

input int      Inp_Third_shift         = 0;           // i-Regr Third Power: shift

input bool     InpOnlyOneThird         = false;       // Third Power: Only one positions 

input bool     InpReverseThird         = false;       // Third Power: Reverse 

input bool     InpCloseOppositeThird   = false;       // Third Power: Close opposite

input bool     InpPrintLogThird        = false;       // Third Power: Print log

input ulong    InpMagicThird           = 489419976;   // Third Power: Magic number 

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

//| Expert initialization function                                   |

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

int OnInit()

  {

   if(InpUseLinear)

     {

      CTradingEngine3 *multi=new CTradingEngine3;

      if(multi==NULL)

        {

         Print("Object CTradingEngine3 create error");

         return(INIT_FAILED);

        }

      m_array_obj.Add(multi);

      int init=multi.OnInit(

                            Symbol(),

                            InpCurrentBarZeroLinear,

                            InpStopLossLinear,

                            InpTakeProfitLinear,

                            InpTrailingFrequencyLinear,

                            InpSignalsFrequencyLinear,

                            InpTrailingStopLinear,

                            InpTrailingStepLinear,

                            InpLotOrRiskLinear,

                            InpVolumeLotOrRiskLinear,

                            linear,

                            Inp_Linear_kstd,

                            Inp_Linear_bars,

                            Inp_Linear_shift,

                            InpOnlyOneLinear,

                            InpReverseLinear,

                            InpCloseOppositeLinear,

                            InpPrintLogLinear,

                            InpMagicLinear

                            );

      if(init!=INIT_SUCCEEDED)

         return(init);

     }

//---

   if(InpUseParabolic)

     {

      CTradingEngine3 *multi=new CTradingEngine3;

      if(multi==NULL)

        {

         Print("Object CTradingEngine3 create error");

         return(INIT_FAILED);

        }

      m_array_obj.Add(multi);

      int init=multi.OnInit(

                            Symbol(),

                            InpCurrentBarZeroParabolic,

                            InpStopLossParabolic,

                            InpTakeProfitParabolic,

                            InpTrailingFrequencyParabolic,

                            InpSignalsFrequencyParabolic,

                            InpTrailingStopParabolic,

                            InpTrailingStepParabolic,

                            InpLotOrRiskParabolic,

                            InpVolumeLotOrRiskParabolic,

                            parabolic,

                            Inp_Parabolic_kstd,

                            Inp_Parabolic_bars,

                            Inp_Parabolic_shift,

                            InpOnlyOneParabolic,

                            InpReverseParabolic,

                            InpCloseOppositeParabolic,

                            InpPrintLogParabolic,

                            InpMagicParabolic

                            );

      if(init!=INIT_SUCCEEDED)

         return(init);

     }

//---

   if(InpUseThird)

     {

      CTradingEngine3 *multi=new CTradingEngine3;

      if(multi==NULL)

        {

         Print("Object CTradingEngine3 create error");

         return(INIT_FAILED);

        }

      m_array_obj.Add(multi);

      int init=multi.OnInit(

                            Symbol(),

                            InpCurrentBarZeroThird,

                            InpStopLossThird,

                            InpTakeProfitThird,

                            InpTrailingFrequencyThird,

                            InpSignalsFrequencyThird,

                            InpTrailingStopThird,

                            InpTrailingStepThird,

                            InpLotOrRiskThird,

                            InpVolumeLotOrRiskThird,

                            Third_power,

                            Inp_Third_kstd,

                            Inp_Third_bars,

                            Inp_Third_shift,

                            InpOnlyOneThird,

                            InpReverseThird,

                            InpCloseOppositeThird,

                            InpPrintLogThird,

                            InpMagicThird

                            );

      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++)

     {

      CTradingEngine3 *multi=m_array_obj.At(i);

      if(multi==NULL)

        {

         //--- Error reading from array 

         Print("Object CMultiiMATrend create error");

         return;

        }

      multi.OnDeinit(reason);

     }

  }

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

//| Expert tick function                                             |

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

void OnTick()

  {

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

     {

      CTradingEngine3 *multi=m_array_obj.At(i);

      if(multi==NULL)

        {

         //--- Error reading from array 

         Print("Object CMultiiMATrend 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++)

     {

      CTradingEngine3 *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 ---