Trailing iMA Panel

Author: Copyright © 2021, Vladimir Karputov
Price Data Components
Series array that contains tick volumes of each bar
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites
Trailing iMA Panel
ÿþ//+------------------------------------------------------------------+

//|                                           Trailing iMA Panel.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.000"

//---

#include <Trade\PositionInfo.mqh>

#include <Trade\Trade.mqh>

#include <Trade\SymbolInfo.mqh>

//---

CPositionInfo  m_position;                   // object of CPositionInfo class

CTrade         m_trade;                      // object of CTrade class

CSymbolInfo    m_symbol;                     // object of CSymbolInfo class

//---

#include <Controls\Dialog.mqh>

#include <Controls\Button.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)

//--- for buttons

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

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

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

//| Class CControlsDialog                                            |

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

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

class CControlsDialog : public CAppDialog

  {

private:

   CButton           m_button_pause_start;            // the button object

   //--- input parameters

   ushort            m_trailing_frequency;            // Trailing, in seconds (< "3" -> only on a new bar)

   double            m_trailing_stop;                 // Trailing Stop           -> double, in points

   ulong             m_deviation;                     // Deviation, in points (1.00045-1.00055=10 points)

   bool              m_all_magic;                     // Trailing All Magic

   ulong             m_only_magic;                    // Trailing Only Magic number (if 'Trailing All Magic' -> false)

   bool              m_position_magic;                // Use Magic number from position



   //---

   int               m_handle_iMA;                    // variable for storing the handle of the iMA indicator

   bool              m_print_log;                     // Print log

   ulong             m_magic;                         // Trailing Panel: Magic number



public:

                     CControlsDialog(void);

                    ~CControlsDialog(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);

   //--- init

   int               Init(const ushort Inp_TrailingFrequency,

                          const ushort Inp_TrailingStop,

                          const ulong  Inp_Deviation,

                          const bool   Inp_AllMagic,

                          const ulong  Inp_OnlyMagic,

                          const bool   Inp_PositionMagic,

                          const int    Inp_handle_iMA,

                          const bool   Inp_PrintLog,

                          const ulong  Inp_Magic);

   //--- chart event handler

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

   //--- panel tick function

   void              OnTickPanel(void);



protected:

   //--- create dependent controls

   bool              CreateButtonPauseStart(void);

   //--- handlers of the dependent controls events

   void              OnClickButtonPauseStart(void);

   //--- refreshes the symbol quotes data

   bool              RefreshRates();

   //--- check Freeze and Stops levels

   void              FreezeStopsLevels(double &freeze,double &stops);

   //--- indicator trailing

   void              TrailingIndicator(const int handle, const int buffer_num);

   //--- get value of buffers

   bool              iGetArray(const int handle,const int buffer,const int start_pos,const int count,double &arr_buffer[]);

   //--- compare doubles

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

   //--- print CTrade result

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

   //---

   double            m_adjusted_point;          // point value adjusted for 3 or 5 points

   datetime          m_last_trailing;           // "0" -> D'1970.01.01 00:00';

   datetime          m_prev_bars;               // "0" -> D'1970.01.01 00:00';



  };

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

//| Event Handling                                                   |

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

EVENT_MAP_BEGIN(CControlsDialog)

ON_EVENT(ON_CLICK,m_button_pause_start,OnClickButtonPauseStart)

EVENT_MAP_END(CAppDialog)

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

//| Constructor                                                      |

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

CControlsDialog::CControlsDialog(void) :

   m_trailing_frequency(10),

   m_trailing_stop(25),

   m_deviation(10),

   m_all_magic(true),

   m_only_magic(200),

   m_position_magic(false),

   m_print_log(false),

   m_magic(24571336)

  {

  }

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

//| Destructor                                                       |

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

CControlsDialog::~CControlsDialog(void)

  {

  }

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

//| Create                                                           |

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

bool CControlsDialog::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(!CreateButtonPauseStart())

      return(false);

//--- succeed

   return(true);

  }

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

//| Init                                                             |

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

int CControlsDialog::Init(const ushort Inp_TrailingFrequency,

                          const ushort Inp_TrailingStop,

                          const ulong  Inp_Deviation,

                          const bool   Inp_AllMagic,

                          const ulong  Inp_OnlyMagic,

                          const bool   Inp_PositionMagic,

                          const int    Inp_handle_iMA,

                          const bool   Inp_PrintLog,

                          const ulong  Inp_Magic)

  {

   m_trailing_frequency = Inp_TrailingFrequency;

   m_deviation          = Inp_Deviation;

   m_all_magic          = Inp_AllMagic;

   m_only_magic         = Inp_OnlyMagic;

   m_position_magic     = Inp_PositionMagic;

   m_handle_iMA         = Inp_handle_iMA;

   m_print_log          = Inp_PrintLog;

   m_magic              = Inp_Magic;

//---

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

     {

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

      return(INIT_FAILED);

     }

   RefreshRates();

//---

   m_trade.SetExpertMagicNumber(m_magic);

   m_trade.SetMarginMode();

   m_trade.SetTypeFillingBySymbol(m_symbol.Name());

   m_trade.SetDeviationInPoints(m_deviation);

//---

   m_trailing_stop         = (double)Inp_TrailingStop    * m_symbol.Point();

//---

   /*if(MQLInfoInteger(MQL_TESTER))

     {

      bool res=false;

      while(!res)

         res=m_trade.Buy(0.01);

     }*/

//---

   return(INIT_SUCCEEDED);

  }

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

//| Expert tick function                                             |

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

void CControlsDialog::OnTickPanel(void)

  {

   if(m_button_pause_start.Pressed())

      return;

//---

   if(m_trailing_frequency>=3) // trailing no more than once every 3 seconds

     {

      datetime time_current=TimeCurrent();

      if(time_current-m_last_trailing>10)

        {

         TrailingIndicator(m_handle_iMA,0);

         m_last_trailing=time_current;

        }

     }

//--- we work only at the time of the birth of new bar

   datetime time_0=iTime(m_symbol.Name(),Period(),0);

   if(time_0==m_prev_bars)

      return;

   m_prev_bars=time_0;

   if(m_trailing_frequency<3) // trailing only at the time of the birth of new bar

      TrailingIndicator(m_handle_iMA,0);

  }

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

//| Create the "Close all" button                                    |

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

bool CControlsDialog::CreateButtonPauseStart(void)

  {

//--- coordinates

   int x1=INDENT_LEFT;

   int y1=INDENT_TOP;

   int x2=x1+BUTTON_WIDTH;

   int y2=y1+BUTTON_HEIGHT;

//--- create

   if(!m_button_pause_start.Create(m_chart_id,m_name+"ButtonPauseStop",m_subwin,x1,y1,x2,y2))

      return(false);

   if(!m_button_pause_start.Text("Start"))

      return(false);

   if(!Add(m_button_pause_start))

      return(false);

   m_button_pause_start.Locking(true);

//--- succeed

   return(true);

  }

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

//| Event handler                                                    |

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

void CControlsDialog::OnClickButtonPauseStart(void)

  {

   bool pressed=m_button_pause_start.Pressed();

   if(m_button_pause_start.Pressed())

      m_button_pause_start.Text("Pause");

   else

      m_button_pause_start.Text("Start");

  }

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

//| Refreshes the symbol quotes data                                 |

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

bool CControlsDialog::RefreshRates()

  {

//--- refresh rates

   if(!m_symbol.RefreshRates())

     {

      if(m_print_log)

         Print(__FILE__," ",__FUNCTION__,", ERROR: ","RefreshRates error");

      return(false);

     }

//--- protection against the return value of "zero"

   if(m_symbol.Ask()==0 || m_symbol.Bid()==0)

     {

      if(m_print_log)

         Print(__FILE__," ",__FUNCTION__,", ERROR: ","Ask == 0.0 OR Bid == 0.0");

      return(false);

     }

//---

   return(true);

  }

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

//| Check Freeze and Stops levels                                    |

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

void CControlsDialog::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=1.0;

   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(coeff>0.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(coeff>0.0)

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

//---

   freeze=freeze_level;

   stops=stop_level;

//---

   return;

  }

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

//| Indicator trailing                                               |

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

void CControlsDialog::TrailingIndicator(const int handle, const int buffer_num)

  {

   double freeze=0.0,stops=0.0;

   FreezeStopsLevels(freeze,stops);

   /*

   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

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

   */

   if(handle==INVALID_HANDLE)

      return;

   double array_buffer[];

   ArraySetAsSeries(array_buffer,true);

   int start_pos=0,count=3;

   if(!iGetArray(handle,buffer_num,start_pos,count,array_buffer))

      return;

   int m_bar_current=0;

//--- indicator trailing: no 'Trailing Stop' and no 'Trailing Step'

   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() && m_position.Magic()==m_magic)

           {

            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(array_buffer[m_bar_current]>price_open)

                  if(stop_loss<array_buffer[m_bar_current] && !CompareDoubles(stop_loss,array_buffer[m_bar_current],m_symbol.Digits(),m_symbol.Point()))

                     if(price_current-array_buffer[m_bar_current]>=freeze && (take_profit-bid>=freeze || take_profit==0.0))

                        if(price_current-m_trailing_stop>=array_buffer[m_bar_current]) // (min distance from price to Stop Loss)

                          {

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

                                                      m_symbol.NormalizePrice(array_buffer[m_bar_current]),

                                                      take_profit))

                              if(m_print_log)

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

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

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

                           if(m_print_log)

                             {

                              RefreshRates();

                              m_position.SelectByIndex(i);

                              PrintResultModify(m_trade,m_symbol,m_position);

                             }

                           continue;

                          }

              }

            else

              {

               if(array_buffer[m_bar_current]<price_open)

                  if((stop_loss>array_buffer[m_bar_current] && !CompareDoubles(stop_loss,array_buffer[m_bar_current],m_symbol.Digits(),m_symbol.Point())) || stop_loss==0.0)

                     if(array_buffer[m_bar_current]-price_current>=freeze && ask-take_profit>=freeze)

                        if(price_current+m_trailing_stop<=array_buffer[m_bar_current]) // (min distance from price to Stop Loss)

                          {

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

                                                      m_symbol.NormalizePrice(array_buffer[m_bar_current]),

                                                      take_profit))

                              if(m_print_log)

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

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

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

                           if(m_print_log)

                             {

                              RefreshRates();

                              m_position.SelectByIndex(i);

                              PrintResultModify(m_trade,m_symbol,m_position);

                             }

                          }

              }

           }

  }

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

//| Get value of buffers                                             |

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

bool CControlsDialog::iGetArray(const int handle,const int buffer,const int start_pos,

                                const int count,double &arr_buffer[])

  {

   bool result=true;

   if(!ArrayIsDynamic(arr_buffer))

     {

      if(m_print_log)

         PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__);

      return(false);

     }

   ArrayFree(arr_buffer);

//--- reset error code

   ResetLastError();

//--- fill a part of the iBands array with values from the indicator buffer

   int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer);

   if(copied!=count)

     {

      //--- if the copying fails, tell the error code

      if(m_print_log)

         PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d",

                     __FILE__,__FUNCTION__,count,copied,GetLastError());

      //--- quit with zero result - it means that the indicator is considered as not calculated

      return(false);

     }

   return(result);

  }

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

//| Compare doubles                                                  |

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

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

  {

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

      return(true);

   else

      return(false);

  }

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

//| Print CTrade result                                              |

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

void CControlsDialog::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()));

  }

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

//| Global Variables                                                 |

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

CControlsDialog ExtDialog;

//--- input parameters

input group             "Trailing settings"

input ushort               InpTrailingFrequency = 3;           // Trailing, in seconds (< "3" -> only on a new bar)

input ushort               InpTrailingStop      = 25;          // Trailing Stop (min distance from price to Stop Loss, in points

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

input bool                 InpAllMagic          = true;        // Trailing All Magic

input ulong                InpOnlyMagic         = 200;         // Trailing Only Magic number (if 'Trailing All Magic' -> false)

input bool                 InpPositionMagic     = false;       // Use Magic number from position

input group             "MA Trailing"

input int                  Inp_MA_ma_period     = 12;          // MA Trailing": averaging period

input int                  Inp_MA_ma_shift      = 0;           // MA Trailing": horizontal shift

input ENUM_MA_METHOD       Inp_MA_ma_method     = MODE_SMA;    // MA Trailing": smoothing type

input ENUM_APPLIED_PRICE   Inp_MA_applied_price = PRICE_CLOSE; // MA Trailing": type of price

input group             "Additional features"

input bool                 InpPrintLog          = false;       // Trailing Panel: Print log

input ulong                InpMagic             = 24571336;    // Trailing Panel: Magic number

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

//| Expert initialization function                                   |

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

int OnInit()

  {

//--- create handle of the indicator iMA

   int handle_iMA=iMA(Symbol(),Period(),Inp_MA_ma_period,Inp_MA_ma_shift,

                      Inp_MA_ma_method,Inp_MA_applied_price);

//--- if the handle is not created

   if(handle_iMA==INVALID_HANDLE)

     {

      //--- tell about the failure and output the error code

      PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d",

                  Symbol(),

                  EnumToString(Period()),

                  GetLastError());

      //--- the indicator is stopped early

      return(INIT_FAILED);

     }

//--- create application dialog

   if(!ExtDialog.Create(0,"Trailing Panel",0,40,40,170,111))

      return(INIT_FAILED);

   int init=ExtDialog.Init(InpTrailingFrequency,

                           InpTrailingStop,

                           InpDeviation,

                           InpAllMagic,

                           InpOnlyMagic,

                           InpPositionMagic,

                           handle_iMA,

                           InpPrintLog,

                           InpMagic);

   if(init!=INIT_SUCCEEDED)

      return(init);

//--- run application

   ExtDialog.Run();

//---

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

//--- destroy dialog

   ExtDialog.Destroy(reason);

  }

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

//| Expert tick function                                             |

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

void OnTick()

  {

   ExtDialog.OnTickPanel();

  }

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

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

  {

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

  }

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

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