NetPrice TakeProfit

Author: Copyright © 2021, Vladimir Karputov
Price Data Components
Series array that contains tick volumes of each bar
0 Views
0 Downloads
0 Favorites
NetPrice TakeProfit
ÿþ//+--------------------------- PanelDialog --------------------------+

#include <Controls\Dialog.mqh>

#include <Canvas\Canvas.mqh>

#include <Controls\BmpButton.mqh>

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

//| defines                                                          |

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

//--- indents and gaps

#define INDENT_LEFT                         (11)      // indent from left (with allowance for border width)

#define INDENT_TOP                          (11)      // indent from top (with allowance for border width)

#define INDENT_RIGHT                        (11)      // indent from right (with allowance for border width)

#define INDENT_BOTTOM                       (11)      // indent from bottom (with allowance for border width)

//--- for buttons

#define BUTTON_WIDTH                        (100)     // size by X coordinate

#define BUTTON_HEIGHT                       (20)      // size by Y coordinate

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

//| Class CPanelDialog                                            |

//| Usage: main dialog of the Controls application                   |

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

class CPanelDialog : public CAppDialog

  {

private:

   CCanvas           m_canvas;                        // CCanvas object

   CBmpButton        m_bmp_button;                    // CBmpButton object



public:

                     CPanelDialog(void);

                    ~CPanelDialog(void);

   //--- create

   virtual bool      Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);

   //--- chart event handler

   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);

   //--- displaying text

   virtual void      DisplayingText(const string net_tp_buy,const string net_tp_sell,const string freeze);



protected:

   //--- create dependent controls

   bool              CreateCanvas(void);

  };

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

//| Event Handling                                                   |

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

EVENT_MAP_BEGIN(CPanelDialog)

EVENT_MAP_END(CAppDialog)

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

//| Constructor                                                      |

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

CPanelDialog::CPanelDialog(void)

  {

  }

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

//| Destructor                                                       |

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

CPanelDialog::~CPanelDialog(void)

  {

  }

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

//| Create                                                           |

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

bool CPanelDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2)

  {

   if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2))

      return(false);

//--- create dependent controls

   if(!CreateCanvas())

      return(false);

//--- succeed

   return(true);

  }

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

//| Displaying Text                                                  |

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

void CPanelDialog::DisplayingText(const string net_tp_buy,const string net_tp_sell,const string freeze)

  {

   m_canvas.Erase(ColorToARGB(clrAqua,255));

   m_canvas.TextOut(5,5,"NetPrice TakeProfit BUY:  "+net_tp_buy,ColorToARGB(clrBlue,255));

   m_canvas.TextOut(5,20,"NetPrice TakeProfit SELL: "+net_tp_sell,ColorToARGB(clrRed,255));

   m_canvas.TextOut(5,35,"Freeze level: "+freeze,ColorToARGB(clrBlack,255));

   m_canvas.Update(true);

  }

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

//| Create the canvas object                                         |

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

bool CPanelDialog::CreateCanvas(void)

  {

//--- coordinates

   int x1=1;

   int y1=1;

   int x2=ClientAreaWidth()-2;

   int y2=ClientAreaHeight()-2;

//--- create canvas

   if(!m_canvas.Create("Canvas1",x2,y2,COLOR_FORMAT_XRGB_NOALPHA))

     {

      Print("Error creating canvas: ",GetLastError());

      return(false);

     }

   m_canvas.FontSet("Consolas",-120,FW_THIN);

   m_canvas.Erase(ColorToARGB(clrAqua,255));

   m_canvas.Update(true);

//--- create

   if(!m_bmp_button.Create(m_chart_id,m_name+"BmpButton",m_subwin,x1,y1,x1,y1))

      return(false);

//--- sets the name of bmp files of the control CBmpButton

   if(!m_bmp_button.BmpOnName(m_canvas.ResourceName()))

      return(false);

   if(!Add(m_bmp_button))

      return(false);

//--- succeed

   return(true);

  }

//+----------------------------- Expert -----------------------------+

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

//|                                          NetPrice TakeProfit.mq5 |

//|                              Copyright © 2021, Vladimir Karputov |

//|                     https://www.mql5.com/ru/market/product/43516 |

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

#property copyright "Copyright © 2021, Vladimir Karputov"

#property link      "https://www.mql5.com/ru/market/product/43516"

#property version   "1.007"

#property description "Take Profit - in Points (1.00055-1.00045=10 points)"

/*

   barabashkakvn Trading engine 3.157

*/

#include <Trade\PositionInfo.mqh>

#include <Trade\Trade.mqh>

#include <Trade\SymbolInfo.mqh>

#include <Trade\AccountInfo.mqh>

//---

CPositionInfo  m_position;                   // object of CPositionInfo class

CTrade         m_trade;                      // object of CTrade class

CSymbolInfo    m_symbol;                     // object of CSymbolInfo class

CAccountInfo   m_account;                    // object of CAccountInfo class

//--- input parameters

input group             "Trading settings"

input uint                 InpTakeProfitBuy     = 460;                     // Take Profit Buy

input uint                 InpTakeProfitSell    = 460;                     // Take Profit Sell

input group             "Is running in the visual testing mode"

input ENUM_POSITION_TYPE   InpTradesType        = POSITION_TYPE_BUY;       // Trades type

input datetime             InpFirstTradeTime    = D'1970.01.01 02:10:10';  // First trade Start Time (HH:MM:SS)

input short                InpFirstTradeVolume  = 1;                       // First trade Volume: Number of minimum lots

input datetime             InpSecondTradeTime   = D'1970.01.01 05:15:00';  // Second trade Start Time (HH:MM:SS)

input short                InpSecondTradeVolume = 2;                       // Second trade Volume: Number of minimum lots

input datetime             InpThirdTradeTime    = D'1970.01.01 10:00:01';  // Third trade Start Time (HH:MM:SS)

input short                InpThirdTradeVolume  = 3;                       // Third trade Volume: Number of minimum lots

input group             "Additional features"

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             = 131239940;   // Magic number

//---

double   m_take_profit_buy          = 0.0;      // Take Profit Buy            -> double

double   m_take_profit_sell         = 0.0;      // Take Profit Sell           -> double

long     m_first_start              = 0;

long     m_second_start             = 0;

long     m_third_start              = 0;

//---

CPanelDialog   m_dialog;                                 // object of CPanelDialog class

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

//| Expert initialization function                                   |

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

int OnInit()

  {

//--- create application dialog

   if(!m_dialog.Create(0,"NetPrice TakeProfit",0,50,50,391,140))

      return(INIT_FAILED);

//--- run application

   if(!m_dialog.Run())

      return(INIT_FAILED);

//--- forced initialization of variables

   m_take_profit_buy          = 0.0;      // Take Profit Buy            -> double

   m_take_profit_sell         = 0.0;      // Take Profit Sell           -> double

//---

   ResetLastError();

   if(!m_symbol.Name(Symbol())) // sets symbol name

     {

      Print(__FILE__," ",__FUNCTION__,", ERROR: CSymbolInfo.Name");

      return(INIT_FAILED);

     }

   RefreshRates();

//---

   m_trade.SetExpertMagicNumber(InpMagic);

   m_trade.SetMarginMode();

   m_trade.SetTypeFillingBySymbol(m_symbol.Name());

   m_trade.SetDeviationInPoints(InpDeviation);

//---

   m_take_profit_buy          = InpTakeProfitBuy            * m_symbol.Point();

   m_take_profit_sell         = InpTakeProfitSell           * m_symbol.Point();

//---

   MqlDateTime STime;

   TimeToStruct(InpFirstTradeTime,STime);

   m_first_start=STime.hour*3600+STime.min*60+STime.sec;

   TimeToStruct(InpSecondTradeTime,STime);

   m_second_start=STime.hour*3600+STime.min*60+STime.sec;

   TimeToStruct(InpThirdTradeTime,STime);

   m_third_start=STime.hour*3600+STime.min*60+STime.sec;

//---

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

//--- destroy application dialog

   m_dialog.Destroy(reason);

  }

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

//| Expert tick function                                             |

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

void OnTick()

  {

   if(MQLInfoInteger(MQL_VISUAL_MODE))

     {

      int pos_total=PositionsTotal();

      if(pos_total<3)

        {

         MqlDateTime STime;

         TimeToStruct(TimeCurrent(),STime);

         long time=STime.hour*3600+STime.min*60+STime.sec;

         switch(pos_total)

           {

            case  0:

              {

               if(time>=m_first_start && m_first_start-60*5<=time)

                 {

                  bool res=false;

                  while(!res)

                    {

                     if(InpTradesType==POSITION_TYPE_BUY)

                        res=m_trade.Buy(InpFirstTradeVolume*m_symbol.LotsMin());

                     else

                        res=m_trade.Sell(InpFirstTradeVolume*m_symbol.LotsMin());

                    }

                 }

              }

            break;

            case  1:

              {

               if(time>=m_second_start && m_second_start-60*5<=time)

                 {

                  bool res=false;

                  while(!res)

                    {

                     if(InpTradesType==POSITION_TYPE_BUY)

                        res=m_trade.Buy(InpSecondTradeVolume*m_symbol.LotsMin());

                     else

                        res=m_trade.Sell(InpSecondTradeVolume*m_symbol.LotsMin());

                    }

                 }

              }

            break;

            default:

              {

               if(time>=m_third_start && m_third_start-60*5<=time)

                 {

                  bool res=false;

                  while(!res)

                    {

                     if(InpTradesType==POSITION_TYPE_BUY)

                        res=m_trade.Buy(InpThirdTradeVolume*m_symbol.LotsMin());

                     else

                        res=m_trade.Sell(InpThirdTradeVolume*m_symbol.LotsMin());

                    }

                 }

              }

            break;

           }

        }

     }

   Trailing();

  }

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

//| Expert chart event function                                      |

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

void OnChartEvent(const int id,         // event ID

                  const long& lparam,   // event parameter of the long type

                  const double& dparam, // event parameter of the double type

                  const string& sparam) // event parameter of the string type

  {

   m_dialog.ChartEvent(id,lparam,dparam,sparam);

  }

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

//| Refreshes the symbol quotes data                                 |

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

bool RefreshRates()

  {

//--- 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);

  }

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

//| Check Freeze and Stops levels                                    |

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

void FreezeStopsLevels(double &freeze,double &stops)

  {

//--- check Freeze and Stops levels

   /*

   SYMBOL_TRADE_FREEZE_LEVEL shows the distance of freezing the trade operations

      for pending orders and open positions in points

   ------------------------|--------------------|--------------------------------------------

   Type of order/position  |  Activation price  |  Check

   ------------------------|--------------------|--------------------------------------------

   Buy Limit order         |  Ask               |  Ask-OpenPrice  >= SYMBOL_TRADE_FREEZE_LEVEL

   Buy Stop order          |  Ask               |  OpenPrice-Ask  >= SYMBOL_TRADE_FREEZE_LEVEL

   Sell Limit order        |  Bid               |  OpenPrice-Bid  >= SYMBOL_TRADE_FREEZE_LEVEL

   Sell Stop order         |  Bid               |  Bid-OpenPrice  >= SYMBOL_TRADE_FREEZE_LEVEL

   Buy position            |  Bid               |  TakeProfit-Bid >= SYMBOL_TRADE_FREEZE_LEVEL

                           |                    |  Bid-StopLoss   >= SYMBOL_TRADE_FREEZE_LEVEL

   Sell position           |  Ask               |  Ask-TakeProfit >= SYMBOL_TRADE_FREEZE_LEVEL

                           |                    |  StopLoss-Ask   >= SYMBOL_TRADE_FREEZE_LEVEL

   ------------------------------------------------------------------------------------------



   SYMBOL_TRADE_STOPS_LEVEL determines the number of points for minimum indentation of the

      StopLoss and TakeProfit levels from the current closing price of the open position

   ------------------------------------------------|------------------------------------------

   Buying is done at the Ask price                 |  Selling is done at the Bid price

   ------------------------------------------------|------------------------------------------

   TakeProfit        >= Bid                        |  TakeProfit        <= Ask

   StopLoss          <= Bid                        |  StopLoss          >= Ask

   TakeProfit - Bid  >= SYMBOL_TRADE_STOPS_LEVEL   |  Ask - TakeProfit  >= SYMBOL_TRADE_STOPS_LEVEL

   Bid - StopLoss    >= SYMBOL_TRADE_STOPS_LEVEL   |  StopLoss - Ask    >= SYMBOL_TRADE_STOPS_LEVEL

   ------------------------------------------------------------------------------------------

   */

   double coeff=(double)InpFreezeCoefficient;

   if(!RefreshRates() || !m_symbol.Refresh())

      return;

//--- FreezeLevel -> for pending order and modification

   double freeze_level=m_symbol.FreezeLevel()*m_symbol.Point();

   if(freeze_level==0.0)

      if(InpFreezeCoefficient>0)

         freeze_level=(m_symbol.Ask()-m_symbol.Bid())*coeff;

//--- StopsLevel -> for TakeProfit and StopLoss

   double stop_level=m_symbol.StopsLevel()*m_symbol.Point();

   if(stop_level==0.0)

      if(InpFreezeCoefficient>0)

         stop_level=(m_symbol.Ask()-m_symbol.Bid())*coeff;

//---

   freeze=freeze_level;

   stops=stop_level;

//---

   return;

  }

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

//| Trailing                                                         |

//|   InpTrailingStop: min distance from price to Stop Loss          |

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

void Trailing()

  {

   if(InpTakeProfitBuy==0 && InpTakeProfitSell==0)

      return;

//---

   double net_price_buy=0.0,net_price_sell=0.0;

   CalculationNetPrice(net_price_buy,net_price_sell);

//---

   double freeze=0.0,stops=0.0;

   FreezeStopsLevels(freeze,stops);

   double max_levels=(freeze>stops)?freeze:stops;

//---

   m_dialog.DisplayingText(DoubleToString(net_price_buy,Digits()),DoubleToString(net_price_sell,Digits()),DoubleToString(max_levels,Digits()));

   if(net_price_buy==0.0 && net_price_sell==0.0 && PositionsTotal()==0)

      return;

   /*

   SYMBOL_TRADE_FREEZE_LEVEL shows the distance of freezing the trade operations

      for pending orders and open positions in points

   ------------------------|--------------------|--------------------------------------------

   Type of order/position  |  Activation price  |  Check

   ------------------------|--------------------|--------------------------------------------

   Buy Limit order         |  Ask               |  Ask-OpenPrice  >= SYMBOL_TRADE_FREEZE_LEVEL

   Buy Stop order          |  Ask               |  OpenPrice-Ask  >= SYMBOL_TRADE_FREEZE_LEVEL

   Sell Limit order        |  Bid               |  OpenPrice-Bid  >= SYMBOL_TRADE_FREEZE_LEVEL

   Sell Stop order         |  Bid               |  Bid-OpenPrice  >= SYMBOL_TRADE_FREEZE_LEVEL

   Buy position            |  Bid               |  TakeProfit-Bid >= SYMBOL_TRADE_FREEZE_LEVEL

                           |                    |  Bid-StopLoss   >= SYMBOL_TRADE_FREEZE_LEVEL

   Sell position           |  Ask               |  Ask-TakeProfit >= SYMBOL_TRADE_FREEZE_LEVEL

                           |                    |  StopLoss-Ask   >= SYMBOL_TRADE_FREEZE_LEVEL

   ------------------------------------------------------------------------------------------

   */

   for(int i=PositionsTotal()-1; i>=0; i--) // returns the number of open positions

      if(m_position.SelectByIndex(i))

         if(m_position.Symbol()==m_symbol.Name())

           {

            double price_current = m_position.PriceCurrent();

            double price_open    = m_position.PriceOpen();

            double stop_loss     = m_position.StopLoss();

            double take_profit   = m_position.TakeProfit();

            double ask           = m_symbol.Ask();

            double bid           = m_symbol.Bid();

            //---

            if(m_position.PositionType()==POSITION_TYPE_BUY)

              {

               if(net_price_buy>0.0)

                 {

                  double new_take_profit=net_price_buy+m_take_profit_buy;

                  if(new_take_profit-price_current>=max_levels || take_profit==0.0)

                     if(!CompareDoubles(take_profit,new_take_profit,m_symbol.Digits(),m_symbol.Point()))

                       {

                        if(!m_trade.PositionModify(m_position.Ticket(),stop_loss,m_symbol.NormalizePrice(new_take_profit)))

                           if(InpPrintLog)

                              Print(__FILE__," ",__FUNCTION__,", ERROR: ","Modify BUY ",m_position.Ticket(),

                                    " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                                    ", description of result: ",m_trade.ResultRetcodeDescription());

                        if(InpPrintLog)

                          {

                           RefreshRates();

                           m_position.SelectByIndex(i);

                           PrintResultModify(m_trade,m_symbol,m_position);

                          }

                        continue;

                       }

                 }

               else

                 {

                  if(take_profit>0.0) // delete Take Profit

                    {

                     if(!m_trade.PositionModify(m_position.Ticket(),stop_loss,0.0))

                        if(InpPrintLog)

                           Print(__FILE__," ",__FUNCTION__,", ERROR: ","Modify BUY ",m_position.Ticket(),

                                 " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                                 ", description of result: ",m_trade.ResultRetcodeDescription());

                     if(InpPrintLog)

                       {

                        RefreshRates();

                        m_position.SelectByIndex(i);

                        PrintResultModify(m_trade,m_symbol,m_position);

                       }

                     continue;

                    }

                 }

              }

            if(m_position.PositionType()==POSITION_TYPE_SELL)

              {

               if(net_price_sell>0.0)

                 {

                  double new_take_profit=net_price_sell-m_take_profit_sell;

                  if(price_current-new_take_profit>=max_levels || take_profit==0.0)

                     if(!CompareDoubles(take_profit,new_take_profit,m_symbol.Digits(),m_symbol.Point()))

                       {

                        if(!m_trade.PositionModify(m_position.Ticket(),stop_loss,m_symbol.NormalizePrice(new_take_profit)))

                           if(InpPrintLog)

                              Print(__FILE__," ",__FUNCTION__,", ERROR: ","Modify SELL ",m_position.Ticket(),

                                    " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                                    ", description of result: ",m_trade.ResultRetcodeDescription());

                        if(InpPrintLog)

                          {

                           RefreshRates();

                           m_position.SelectByIndex(i);

                           PrintResultModify(m_trade,m_symbol,m_position);

                          }

                       }

                 }

               else

                 {

                  if(take_profit>0.0) // delete Take Profit

                    {

                     if(!m_trade.PositionModify(m_position.Ticket(),stop_loss,0.0))

                        if(InpPrintLog)

                           Print(__FILE__," ",__FUNCTION__,", ERROR: ","Modify SELL ",m_position.Ticket(),

                                 " Position -> false. Result Retcode: ",m_trade.ResultRetcode(),

                                 ", description of result: ",m_trade.ResultRetcodeDescription());

                     if(InpPrintLog)

                       {

                        RefreshRates();

                        m_position.SelectByIndex(i);

                        PrintResultModify(m_trade,m_symbol,m_position);

                       }

                    }

                 }

              }

           }

  }

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

//| Print CTrade result                                              |

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

void PrintResultModify(CTrade &trade,CSymbolInfo &symbol,CPositionInfo &position)

  {

   Print("File: ",__FILE__,", symbol: ",symbol.Name());

   Print("Code of request result: "+IntegerToString(trade.ResultRetcode()));

   Print("code of request result as a string: "+trade.ResultRetcodeDescription());

   Print("Deal ticket: "+IntegerToString(trade.ResultDeal()));

   Print("Order ticket: "+IntegerToString(trade.ResultOrder()));

   Print("Volume of deal or order: "+DoubleToString(trade.ResultVolume(),2));

   Print("Price, confirmed by broker: "+DoubleToString(trade.ResultPrice(),symbol.Digits()));

   Print("Current bid price: "+DoubleToString(symbol.Bid(),symbol.Digits())+" (the requote): "+DoubleToString(trade.ResultBid(),symbol.Digits()));

   Print("Current ask price: "+DoubleToString(symbol.Ask(),symbol.Digits())+" (the requote): "+DoubleToString(trade.ResultAsk(),symbol.Digits()));

   Print("Broker comment: "+trade.ResultComment());

   Print("Freeze Level: "+DoubleToString(symbol.FreezeLevel(),0),", Stops Level: "+DoubleToString(symbol.StopsLevel(),0));

   Print("Price of position opening: "+DoubleToString(position.PriceOpen(),symbol.Digits()));

   Print("Price of position's Stop Loss: "+DoubleToString(position.StopLoss(),symbol.Digits()));

   Print("Price of position's Take Profit: "+DoubleToString(position.TakeProfit(),symbol.Digits()));

   Print("Current price by position: "+DoubleToString(position.PriceCurrent(),symbol.Digits()));

  }

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

//| Calculation Net Price                                            |

//| Formula for \"Breakeven\" is provided                            |

//|  Andrei Fandeev https://www.mql5.com/ru/users/andreifan"         |

//|  in: https://www.mql5.com/ru/forum/220911/page2#comment_6105972" |

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

void CalculationNetPrice(double &net_price_buy,double &net_price_sell)

  {

   double total_price_multiply_volume_buy    = 0.0;

   double total_volume_buy                   = 0.0;

   net_price_buy                             = 0.0;

   int count_buys                            = 0;

   double total_price_multiply_volume_sell   = 0.0;

   double total_volume_sell                  = 0.0;

   net_price_sell                            = 0.0;

   int count_sells                           = 0;

   double breakeven_price=0.0;

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

           {

            if(m_position.PositionType()==POSITION_TYPE_BUY)

              {

               total_price_multiply_volume_buy+=m_position.PriceOpen()*m_position.Volume();

               total_volume_buy+=m_position.Volume();

               count_buys++;

              }

            else

              {

               total_price_multiply_volume_sell+=m_position.PriceOpen()*m_position.Volume();

               total_volume_sell+=m_position.Volume();

               count_sells++;

              }

           }

//---

   if(total_price_multiply_volume_buy!=0 && count_buys>1)

      net_price_buy=total_price_multiply_volume_buy/total_volume_buy;

   if(total_price_multiply_volume_sell!=0 && count_sells>1)

      net_price_sell=total_price_multiply_volume_sell/total_volume_sell;

   if(total_volume_buy-total_volume_sell!=0)

      breakeven_price=(total_price_multiply_volume_buy-total_price_multiply_volume_sell)/

                      (total_volume_buy+total_volume_sell*-1);

//---

   return;

  }

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

//| Compare doubles                                                  |

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

bool CompareDoubles(double number1,double number2,int digits,double points)

  {

   if(MathAbs(NormalizeDouble(number1-number2,digits))<=points)

      return(true);

   else

      return(false);

  }

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

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