Need an Expert for my Expert

 

Seen below, if all goes well, is an excerpt from my EA wherein the first function is called Oppternate,

(a variation of Alternate, which is of course BUY/SELL/BUY/SELL) which causes any trades occurring WHILE the first of a series

of trades is OPEN to be OPPOSITE the type of the first one of that series, from here on called the RT (Reference Trade); The pattern for 7 trades with a

SELL RT would be (S) B B B B B B. The second function is called Sameternate, wherein the subsequent trades (aka 'SUBS') are to be the SAME type as the RT;

The pattern would be (S) S S S S S S. The opposite RTs in both cases would of course yield the opposite results, and once a RT closes, the SUBS 

go on to their profits or losses, and if a new RT occurs via MA crossings, even amongst any leftover SUBS, the cycle/setting/pattern occurs again, etc.


The problem is that Sameternate, worded ALMOST exactly the same as Oppternate, (except for: (RT_type == op_type) does not function, with merely the need for

the RT's type to match the op_type of the trade that would be the next to occur---They are worded as I had THOUGHT they should have been, of course;

Hence, if the op_type is required to match the RT's type, the EA does not trade or, if i set RT_type to 0 or 1, it produces ONLY that type of trade (0/all BUYs or 1/all SELLs).

I HAVE tried everything, I HAVE paid for programming to be done to get this idea to work (with THEIR programming, there was 'carryover' of trade types between the groups

of them, though, negating any efforts---it is all blanked-out in the EA) - they want to rewrite the entire EA - (no, not yet!) and I DO know how to 'code', but just barely,

to save my life, perhaps...

So, I'd be appreciating 'safe passage' to just see if a kind soul or two might help me---I know, I know, 'no slaves here', but, if I were good enough to do it myself, i would!;


The entire EA is attached if needed, along with a setting to be used for Oppternate by default (THAT works!), to see what I am talking about, right-off-the-bat;

I also tried putting RT_type outside these programs, up top and so on...it must be something simple, upon seeing how simple Oppternate ended up being.

It's irrelevant that this doesn't 'look' profitable - I have 'plans'.


Notes:   There may be a little leftover, irrelevant programming, such as 'datetime' that i left alone for fear of taking a step in the wrong direction;

The position(s) of the functions are at lines 1136 through 1226, including a description there of the problem --- 613 and 630 are the lines from which the BUY and SELL signals

are sent to check these functions. Thank you for any help(!) and, if you see any warnings (there are lots) that could prevent the EA from ever ACTUALLY live trading, please

let me know, no pressure, just sayin'---again, thank you---I'll be here---yobwen

 

8-14-'17 thru 1-15-'18 are good test dates to use; EUUS 1-HR, EVERY TICK


bool Oppternate (int op_type)

{

    if(!Oppternate) return true;

   

    datetime time_latest_tp = 0, time_phase = EMPTY_VALUE;

    int ticket = -1;

    int i;

    int RT_type = -1;



    for (i = 0; i < OrdersTotal(); i++)

    {

        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

        if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic/* && OrderComment() == "New"*/)

        {

            if (OrderOpenTime() > time_latest_tp 

            && OrderOpenTime() < time_phase 

            && OrderComment() == "New")

            {

                time_phase = OrderOpenTime();

                ticket = OrderTicket();

                RT_type = OrderType();

                Print("THIS IS THE RT      ",ticket,"  Order Type   ",OrderType(),"  op_type ",op_type);

            }

        }

    }

            if(Oppternate)

            {

            if 

            (RT_type != op_type)

            {

            return true;

            }

            else

            {

            return false;

            }

      }

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

bool Sameternate (int op_type)

{

    if(!Sameternate) return true;

   

    datetime time_latest_tp = 0, time_phase = EMPTY_VALUE;

    int ticket = -1;

    int i;

    int RT_type = 1;



    for (i = 0; i < OrdersTotal(); i++)

    {

        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

        if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic/* && OrderComment() == "New"*/)

        {

            if (OrderOpenTime() > time_latest_tp 

            && OrderOpenTime() < time_phase 

            && OrderComment() == "New")

            {

                time_phase = OrderOpenTime();

                ticket = OrderTicket();

                RT_type = OrderType();

                Print("THIS IS THE RT      ",ticket,"  Order Type   ",OrderType(),"  op_type ",op_type);

            }

        }

    }

            if(Sameternate)

            {

            if 

            (RT_type == op_type)

            {

            return true;

            }

            else

            {

            return false;

            }

      }

}