Oscillator EA Won't make trades Problem

 

I am still somewhat new as a programmer of MQL4. Even though they usually are not profitable, I have wanted to make

an Oscillator type EA. One in which is always in the market either Long or Short. I decided to give it a try. As I expected

it doesn't work, or make any trades. I KNOW it needs more code and maybe some bool code also. I have some good

ideas for indicator combos and parameters. Just need some help on getting it to execute orders and then do a trade in the

opposite direction on the close of the current position.

Thanks,

JimTrader1

Files:
 
  1.    total=OrdersTotal();
       if(total<1) 
    This makes the EA incomparable with any other including itself on other charts or manual trading.
        total=0;
        for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
            OrderSelect(pos, SELECT_BY_POS)                 // Only my orders w/
        &&  OrderMagicNumber()  == magic.number             // my magic number
        &&  OrderSymbol()       == Symbol() ){              // and my pair.
           total++;
        }
    if (total < 1)

  2.          ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,16384,0,Green);
    
    OrderSend missing TP and SL and comment. On 5 digit brokers you must adjust TP, SL, AND SLIPPAGE. On ECN you must open and then set stops.
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
        if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

  3.    for(cnt=0;cnt<total;cnt++)
         {
          OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
          if(OrderType()<=OP_SELL &&   // check for opened position 
             OrderSymbol()==Symbol())  // check for symbol
    
    You MUST count down when closing orders in the presense of multiple orders (multiple charts) The <=OP_SELL is needed only if the EA opens pending orders. Always test return codes. Always filter by magic number. Use form like #1
  4.                  OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
    
    AND slippage (#2) Always test return codes.
 
WHRoeder:
  1. This makes the EA incomparable with any other including itself on other charts or manual trading.
  2. OrderSend missing TP and SL and comment. On 5 digit brokers you must adjust TP, SL, AND SLIPPAGE. On ECN you must open and then set stops.
  3. You MUST count down when closing orders in the presense of multiple orders (multiple charts) The <=OP_SELL is needed only if the EA opens pending orders. Always test return codes. Always filter by magic number. Use form like #1
  4. AND slippage (#2) Always test return codes.

Thank you WHRoeder.
Reason: