An EA that needs its BOSOM to be functional - - - -

 
In viewing the following programming, I need it to:

1. Determine the first CLOSED Martingale trade since the last profit that has first attained PeakLots 
(the highest lots  allowed via a user setting), save its Ticket and TYPE (Buy or Sell) 
in a variable set, PRINT THAT INFO (ONCE-only, if possible) in the Tester Journal,
and then via the logic following that, all known as BOSOM (Buy Or Sell Only Martingale), 
either ALLOW or DISALLOW (not just switch the signal like Stop and Reverse) any other trades trying 
to occur until profit occurs via user settings of 
      MOPP (M'gale OPPosite (Causes all trades after the 1st @ PeakLots to be the OPPOSITE TYPE of it)) 
OR 
      MSAME (M'gale SAME (Causes all trades after the 1st @ PeakLots to be the SAME  TYPE as it))
...until a M'gale profit occurs.

For examples' sakes, MOPP is more noticeable on-chart and the 
need for it is more frequent - to have MSAME available along with it completes 
the ensemble, though;

Line #s of associated, pertinent logic are on the left; 

225:  extern bool       Martingale=true;
226:  extern double  PeakLots=.16;
257:  extern bool       MOPP=false;
258:  extern bool       MSAME=false;
446:   int BUYONLY;
447:   int SELLONLY;

450 :  int SecondWind;

***SecondWind is an indication for any additional logic created that informs one that Lots is 
@ PeakLots for any trades trying to occur, and could be used as such;

it is merely mentioned here for reference;

467-469:
            
            if(Lots>=PeakLots){
            SecondWind = 1;
            }

473:   if(Martingale)CalculateMartingale(); Balance=AccountBalance();

613:   && BOSOM (OP_BUY)   *Logic requests from here if OK to continue-on with the trade;
630:   && BOSOM (OP_SELL)  *Logic requests from here if OK to continue-on with the trade;

***What is supposed to happen is the BOSOM logic must do what has been described at the top:

***There may be logic at the front end here of BOSOM that is unnecessary at all - it was copied from another part of the EA;

Feel free, of course, to modify it or create a new regime entirely to accomplish our goal;
I believe that 99% of this should be accomplishable right within BOSOM itself, as a go-to-
and-return-a-reply function, just like Martingale or Trailing stop, FROM lines 613 and 630;

2126 THROUGH 2216:

bool BOSOM(int op_type)
 {
      datetime time_latest_tpM = 0, time_phaseM = EMPTY_VALUE;
      int order_typeM;
      int ticketM = -1;
      int iM;
    
    for (iM = 0; iM < OrdersHistoryTotal(); iM++)
    {
      OrderSelect(iM, SELECT_BY_POS, MODE_HISTORY);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderProfit()<0 && OrderLots()==PeakLots)
       {
         if (OrderComment() == "New")

>>>Determine the first trade since the last profit that has first attained PeakLots 
        (the highest lots  allowed via a user setting)<<<

           {
             time_phaseM = OrderOpenTime();
             ticketM = OrderTicket();
             order_typeM = OrderType();

>>>save its Ticket and TYPE (Buy or Sell) in a variable set<<<

             Print("      CLOSED RT      ",ticketM,"     ",order_typeM, "     ", OrderLots());
        
>>>PRINT THAT INFO ONCE in the Tester Journal<<<
          
           }
        }
    }
        
>>>and then via the logic following that, either ALLOW or DISALLOW any other trades trying to occur until
profit occurs via user settings of MOPP (M'gale Opposite) OR MSAME (M'gale Same);<<<

            if(MOPP || (!MOPP && !MSAME))   //>>>MOPP must only allow the OPPOSITE-TYPE trades until profit;
            {
            if(order_typeM == OP_BUY && OrderLots()==PeakLots && OrderProfit()<0)
            {
            BUYONLY=1; //Print("MOPP>>>SO, SELL ONLY!!!");
            }
            else 
            if(order_typeM==OP_SELL && OrderLots()==PeakLots && OrderProfit()<0)
            {
            SELLONLY=1; //Print("MOPP>>>SO,BUY ONLY!!!");
            }
            if 
            (BUYONLY==1 && op_type==OP_SELL)
            {
            return true;
            }
            else if 
            (SELLONLY==1 && op_type==OP_BUY)
            {
            return true;
            }
            if(BUYONLY==0 && SELLONLY==0)
            {
            return true;
            }
//////////////////////////THE CLINCHER:            
            else if(!MOPP) 
            {
            return true;
            }
            return false;
            }
            
/////////////////////////////////////////////////////////////////////////////////////////////////////
            if(MSAME || (!MSAME && !MOPP))   //>>>MSAME must only allow the SAME-TYPE trades until profit;
            {
            if(order_typeM == OP_BUY && OrderLots()==PeakLots && OrderProfit()<0)
            {
            BUYONLY=1; //Print("MSAME>>>SO, BUY ONLY!!!");
            }
            else 
            if(order_typeM==OP_SELL && OrderLots()==PeakLots && OrderProfit()<0)
            {
            SELLONLY=1; //Print("MSAME>>>SO, SELL ONLY!!!");
            }
            if 
            (BUYONLY==1 && op_type==OP_BUY)
            {
            return true;
            }
            else if 
            (SELLONLY==1 && op_type==OP_SELL)
            {
            return true;
            }
            if(BUYONLY==0 && SELLONLY==0)
            {
            return true;
            }
///////////////////////////THE CLINCHER:           
            else if(!MSAME) 
            {
            return true;
            } 
            return false;
            }
}

I HAVE tried for months to get this to work, but the main problem was that it printed 
incessantly to the Journal and even if i COULD see the results of my experimentation, 
the print result still stayed on the FIRST PeakLots trade forever, even if OTHER FIRST
PeakLots trades occurred after the one in-question. 
***Every time a profit occurs, the next PeakLots trade will be the First PeakLots trade that 
     we go by for the others to be controlled by (from its TYPE);

Here's an example of how it needs to work;

1. Martingale trading-along;

2. PeakLots is reached (the EA is SET to immediately go from .01 to .16,

   whereas in real trading , it would be set for .01, .02, .04, etc., up to .16);

3. First Peaklots trade @ .16 is logged-in as such;

4. Other PeakLots trades occur, whose TYPE are determined by MOPP or MSAME through BOSOM;

5. Profit occurs eventually, hopefully sooner using this method;

6. M'gale lines 2405 - 2417 set everything back to initial settings;

    Lots=InitialLots;
    TakeProfit=origTakeProfit;
    StopLoss=origStopLoss;
    Multiplier=origMultiplier;
    SecondWind=0;
    BUYONLY=0;
    SELLONLY=0;

These two below I have bleeped-out in the EA because i am not sure yet whether to falsify them 
at that point in time that we profit - there's no sense in them being false or it will only work once:

//MSAME=false; 
//MOPP=false;

at least, until we can get BOSOM to work appropriately, and if i am NOT using Martingale
as-described for some reason, then they would have to be false at some point therein.

I'd be appreciating 'safe passage' here because i have spent a lot of time legitimately trying to get it to work
and have had help from a developer whom tried several times as well, so, I'm looking forward to 
a positive result from this, so i can be closer to completion and profits! Thank you in-advance!---yobwen

PS---the attached EA is set to default to the task at-hand, so, no .set file should be needed---
You'll thank me!

The Time Frame is 1H, EUUS; 

5-1-18 through 5-31-18 are good test dates;

For testing, though, MOPP or MSAME will need to be set for true for the desired end result,
which is:  a switching to either the  SAME type or the OPPOSITE type of the PeakLots trades 
(.16) until profit;

---Thank You in-advance---yobwen 


 
  1. yobwen:
    I need it to: 
    You haven't stated a problem, you stated a want.
    You have only four choices:
    1. Search for it,
    2. Beg at
    3. learn to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
    4. or pay (Freelance) someone to code it.
    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
              No free help
              urgent help.

  2. It "printed incessantly" because you attached it to a chart. Run it in the debugger.


 

As expected, I rolled around in the mine field and...hey, maybe that's the only way to get through it!

This is where we all end up once we're at our wits' end otherwise.

Okay, I apparently yet unbeknownstedly misrepresented my EA in that this 'BOSOM' part of it is my attempt at 

programming it and the main problem with it is that I cannot get it to only represent to me (via the Journal) 

which trade the EA is determining to be the first one of a series of them that has hit PeakLots;

I did use the Code button, but perhaps the split-up code for explanation made it appear otherwise.

Every PeakLots trade is printed in the Journal, cumulatively, for the whole Tester run;

If i had just the one to print at each start of a group of them, I could say with BOSOM's logic to allow or disallow 

others of the same or opposite type via MOPP or MSAME until profit is attained sooner with this method.

I'd 'like' to take your advice otherwise and please do reply so that I know whazzup,

but I had to at least say that I had tried several avenues to attain my goal---I'll know next time, if I live through this time---yobwen

PS---to make matters worse, if you or anyone embarks on this,

Line 2138 needs bleeping: //if (OrderComment() == "New")---otherwise, nothing from BOSOM prints. Odd. Thanks---