One Trade per Trend

#1
Hello Coders,

I am trying to implement that my EA is just performing one Trade per Trend direction change.
I did a simple approach, but this is not really working. Maybe someone could have a look and advise?

Code: Select all

input int   i_MaximumOpenedOrders = 1;

datetime GetLastOrderOpenTime(void)
{
    datetime last_open_time = 0;
    int total_order = OrdersTotal();
    for (int i = total_order - 1; i >= 0; i--)
    {
        if (OrderSelect (i, SELECT_BY_POS, MODE_TRADES))
        {
            if ((Symbol() == OrderSymbol()) && (0 == OrderMagicNumber()))
            {
                if (OrderOpenTime() > last_open_time)
                {
                    last_open_time = OrderOpenTime();
                }
            }
        }
    }
    return (last_open_time);
}

//Open Sell 
ticket=OrderSend(Symbol(),OP_SELL,NewLot,NormalizeDouble(Bid,Digits),3*P,SL,TP,"HyDramaBot",MagicNumber,0,Red)<i_MaximumOpenedOrders&&(GetLastOrderOpenTime() < Time[0]);
                
Thank you in advance!


  1. Similar Topics

    1. Dashboard Direction Trend

      2 Replies 3163 Views

      by MayaxatL, Tue Sep 29, 2020 12:33 am in Trading Systems

      2 Replies
      3163 Views
    2. Can anybody fix the Waddah Attar Trend EA, please?

      0 Replies 1308 Views

      by LadyAmira, Sun Nov 01, 2020 11:05 pm in MT4 Indicators

      0 Replies
      1308 Views
    3. Trend Lock System

      2 Replies 12330 Views

      by menber100, Sat Aug 22, 2020 8:50 am in Coding Help

      2 Replies
      12330 Views

Return to “Coding Help”