code help for opening and closing position OnTick - MT5

 

Hi All

If someone could help me achieve the below it would be great;

In Ontick() I have some indicators,

1. when indicators generate Open Signal I want to book a trade and create a position

2. When indicators generate Close Signal I want to close position.


Please help

 
algo7134:

Hi All

If someone could help me achieve the below it would be great;

In Ontick() I have some indicators,

1. when indicators generate Open Signal I want to book a trade and create a position

2. When indicators generate Close Signal I want to close position.


Please help


Example: Get_Rich_or_Die_Trying_GBP - open positions

   if(total<InpMaxPositions)
     {
      if(up>down && (22+InpAdditionalHour==str1.hour || 19+InpAdditionalHour==str1.hour) && str1.min<5)
        {
         if(RefreshRates())
            OpenBuy(m_symbol.Bid()-ExtStopLoss,m_symbol.Ask()+ExtTakeProfit); // open positions
        }
      else if(up<down && (22+InpAdditionalHour==str1.hour || 19+InpAdditionalHour==str1.hour) && str1.min<5)
        {
         if(RefreshRates())
            OpenSell(m_symbol.Ask()+ExtStopLoss,m_symbol.Bid()-ExtTakeProfit);  // open positions
        }
     }