# Trail stop stops moving

Let say  we have 2 conditions for trailing: Trail with 300000 points at a defined signal. Else trail 100000 points if previous trade was a loss using martingale.

We have 2 Open Positions at 0.2 lots on diff pairs (Boom1000 and Boom500 and Boom500 hits Sl. On candle open, Boom500 a position with 0.4 and trails with 100000. Now the issue that I have is when the other Boom1000 hits Tp the Trail stop for the Boom500 stops wherever it is and whenever Boom1000 hits take profit

```//+------------------------------------------------------------------+
//|          Signal                                                  |
//+------------------------------------------------------------------+
if(glSignal == SIGNAL_BUY && (co[3] > cc[3] &&co[2] < cc[2] &&cc[1] > cc[2] && co[1] < cc[0] &&cc[3] < co[1]  && co[0] > cc[3]) &&
{
if(glSellTicket > 0)
{
}

{
double openPrice = PositionOpenPrice(glBuyTicket);

if(buyStop > 0 || buyProfit > 0)

glSignal = SIGNAL_NONE;
}
}
//+------------------------------------------------------------------+
//|          if the previous trade was a loss                        |
//+------------------------------------------------------------------+
for(i; i>=0; i--)
{
if(ord && HistoryDealGetString(ticket,DEAL_SYMBOL) == _Symbol  && HistoryDealGetInteger(ticket,DEAL_MAGIC) == Magic_Number && HistoryDealGetInteger(ticket,DEAL_ENTRY) == DEAL_ENTRY_OUT)
{
if(HistoryDealGetDouble(ticket,DEAL_PROFIT) < 0 && cake < Multiply)
{
if(co[0]

&&
{
if(glSellTicket > 0)
{
}

{
double openPrice = PositionOpenPrice(glBuyTicket);

if(buyStop > 0 || buyProfit > 0)

glSignal = SIGNAL_NONE;
}
}

}
}
}
//+------------------------------------------------------------------+
//|         Defined signal trail                                     |
//+------------------------------------------------------------------+
if(Use_Trailing_Stop == true && numTickets > 0 && Magic_Number)
{
for(int i = 0; i < numTickets; i++)
{
Trail.TrailingStop0(tickets[i], Trailing_Stop0, Minimum_Profit0, Step0);

}
}

//+------------------------------------------------------------------+
//|   Previous trade was a loss                                      |
//+------------------------------------------------------------------+
if(Use_Trailing_Stop == true && numTickets > 0  && cake >= Multiply && Magic_Number && (HistoryDealGetString(ticket,DEAL_SYMBOL) == _Symbol))
{
for(int i = 0; i < numTickets; i++)
{
Trail.TrailingStop(tickets[i], Trailing_Stop, Minimum_Profit, Step);

}
}
//+------------------------------------------------------------------+

```
Extract profit down to the last pip
• www.mql5.com
The article describes an attempt to combine theory with practice in the algorithmic trading field. Most of discussions concerning the creation of Trading Systems is connected with the use of historic bars and various indicators applied thereon. This is the most well covered field and thus we will not consider it. Bars represent a very artificial entity; therefore we will work with something closer to proto-data, namely the price ticks.

Use a. IF ELSE condition instead of using TWO separate IFs

Satyam Shivam #:
Use a. IF ELSE condition instead of using TWO separate IFs

That doesnt work..I have tried it before

Satyam Shivam #:
Use a. IF ELSE condition instead of using TWO separate IFs

I tried this...waiting for that scenario  again to happen

``` if(HistoryDealGetInteger(ticket,DEAL_MAGIC) == PositionGetInteger(POSITION_MAGIC) && HistoryDealGetString(ticket,DEAL_SYMBOL) == PositionGetString(POSITION_SYMBOL))
{```