I just popped a new idea over night

 

just a small error to fix and then I can keep working on this project.

error is wrong parameter count I feel kinda rusty on this programming

//+------------------------------------------------------------------+
//|                                              Ordering Trades.mq4 |
//|                                         Copyright © 2010, JuPer. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, JuPer."
#property link      "http://www.metaquotes.net"
double LOT = 0.01;
double MAGIC;
double MAGIC2;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   if (OrdersTotal() < 1) OpenNew();          /// <=======================Pops here
   else Checkup();        //////// <=========================Pops Here too
  
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

void OpenNew(int tck)
   {
      tck=OrderSend(Symbol(),OP_BUYSTOP, LOT, Ask+500, 30, 0, 0, MAGIC,"Order", 0, Green);
      OrderModify(tck,OrderOpenPrice(),OrderOpenPrice()-400*Point,OrderOpenPrice()+1000*Point,0,Green);
      tck=OrderSend(Symbol(),OP_SELLSTOP, LOT, Bid-500, 30, 0, 0, MAGIC,"Order", 0, Green);
      OrderModify(tck,OrderOpenPrice(),OrderOpenPrice()+400*Point,OrderOpenPrice()-1000*Point,0,Green);
   }
   
void Checkup(int seek,double profit,int type, int ticket,double tp, int tck)
   {
      for(seek=OrdersTotal()-1;seek >=0;seek--)
         OrderSelect(seek, SELECT_BY_POS);
            {
               ticket = OrderTicket();
               profit = OrderProfit();
               type = OrderType();
               tp = OrderTakeProfit();
               if (type == OP_BUY && profit > 4 && OrdersTotal() < 3 && OrderMagicNumber() == MAGIC)
                  {
                     OrderModify(tck,OrderClosePrice(),OrderOpenPrice()-200*Point,tp,0,Green);
                     NEWBUY();        // <<<<<<<<<<<<<<<<=======================================================Here
                  }
               if (type == OP_SELL && profit > 4 && OrdersTotal() < 3 && OrderMagicNumber() == MAGIC)
                  {
                     OrderModify(tck,OrderClosePrice(),OrderOpenPrice()+200*Point,tp,0,Green);
                     NEWSELL();  //<<===========================================================================Here
                  }
            }
   }

void NEWBUY(int seek,int ticket,int type, int tck)
   {
      for(seek=OrdersTotal()-1;seek >=0;seek--)
         OrderSelect(seek, SELECT_BY_POS);
            {
               ticket = OrderTicket();
               type = OrderType();
               if (type == OP_SELLSTOP)
                  {
                     OrderDelete(ticket);
                  }
            }
      tck=OrderSend(Symbol(),OP_BUY,LOT,Ask,30,0,0,"",MAGIC2,0,Green);
      OrderModify(tck,OrderClosePrice(),Ask-400*Point,Ask+400*Point,0,Green);
   }

void NEWSELL(int seek,int ticket,int type, int tck)
   {
      for(seek=OrdersTotal()-1;seek >=0;seek--)
         OrderSelect(seek, SELECT_BY_POS);
            {
               ticket = OrderTicket();
               type = OrderType();
               if (type == OP_BUYSTOP)
                  {
                     OrderDelete(ticket);
                  }
            }
      tck=OrderSend(Symbol(),OP_SELL,LOT,Bid,30,0,0,"",MAGIC2,0,Green);
      OrderModify(tck,OrderClosePrice(),Bid-400*Point,Bid+400*Point,0,Green);
   }
 

OpenNew(int tck) needs a value passing to it, tck

Checkup(int seek,double profit,int type, int ticket,double tp, int tck) needs 6 values passing to it . . . how else will it get a value for seek, profit, type, etc ?

Ah I see what you have done . . . . you only declare the variables in braces after the function name if you are passing those variables to the Function . . . try this . .


void OpenNew()
   {
     int tck;     //  <------------------------
 
      tck=OrderSend(Symbol(),OP_BUYSTOP, LOT, Ask+500, 30, 0, 0, MAGIC,"Order", 0, Green);
      OrderModify(tck,OrderOpenPrice(),OrderOpenPrice()-400*Point,OrderOpenPrice()+1000*Point,0,Green);
      tck=OrderSend(Symbol(),OP_SELLSTOP, LOT, Bid-500, 30, 0, 0, MAGIC,"Order", 0, Green);
      OrderModify(tck,OrderOpenPrice(),OrderOpenPrice()+400*Point,OrderOpenPrice()-1000*Point,0,Green);
   }
 
You also need to check your return values from your OrderSend and OrderModify and check for errors . . . very important.
 
RaptorUK:
You also need to check your return values from your OrderSend and OrderModify and check for errors . . . very important.


I fixed the OrderSend but everything seems right into my ordermodify but obviously not! I have an error saying Invalid function parameter value on this order

I don't know where it returns me this error but still I have it and I want to fix it. maybe the stoploss is above current price or something like that.

void OpenNew()
   {
      int tck;
      tck=OrderSend(Symbol(),OP_BUYSTOP, LOT, Ask+500*Point, 30, 0, 0, NULL,MAGIC, 0, Green);
      OrderModify(tck,OrderOpenPrice(),OrderOpenPrice()-400*Point,OrderOpenPrice()+1000*Point,0,Green);
      tck=OrderSend(Symbol(),OP_SELLSTOP, LOT, Bid-500*Point, 30, 0, 0, NULL,MAGIC, 0, Green);
      OrderModify(tck,OrderOpenPrice(),OrderOpenPrice()+400*Point,OrderOpenPrice()-1000*Point,0,Green);
   }
 
liquidd:


I fixed the OrderSend but everything seems right into my ordermodify but obviously not! I have an error saying Invalid function parameter value on this order

I don't know where it returns me this error but still I have it and I want to fix it. maybe the stoploss is above current price or something like that.

1) use Print() or Alert() to GetLastError()

2) try OP_BUYLIMIT & OP_SELLLIMIT

3) try to send without SL & TP

 
liquidd:


I fixed the OrderSend but everything seems right into my ordermodify but obviously not! I have an error saying Invalid function parameter value on this order

I don't know where it returns me this error but still I have it and I want to fix it. maybe the stoploss is above current price or something like that.


actually it works witout returning any error I get my error at ordermodify witch is 4051 invalid function parameter

 
liquidd:


actually it works witout returning any error I get my error at ordermodify witch is 4051 invalid function parameter

try OrderSelect();
 
liquidd:
I fixed the OrderSend but everything seems right into my ordermodify but obviously not! I have an error saying Invalid function parameter value on this order
OrderModify(tck,OrderOpenPrice(),OrderOpenPrice()-400*Point,OrderOpenPrice()+1000*Point,0,Green);
  1. You can not use OrderOpenPrice and related functions until AFTER selecting a order. Always test return codes.
        int ticket = OrderSend(...)
        if (ticket < 0)
           Alert("OrderSend failed: ", GetLastError());
        else if (!OrderSelect(ticket, SELECT_BY_POS))
           Alert("OrderSelect failed: ", GetLastError());
        else if (!OrderModify(OrderTicket()...)
           Alert("OrderModify failed: ", GetLastError());
    

  2. 400*Point is 40 pips on a 5 digit broker but 400 pips on a 4 digit broker. Adjust TP, SL, AND slippage.
    //++++ 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 % 2 == 1){      // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    //---- These are adjusted for 5 digit brokers.
    

  3. if (OrdersTotal() < 1) OpenNew()
    This checks if there are no open orders on ANY chart by ANY EA or manual trading. Check for open orders by this EA on this chart.
    int nOrders=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.
        ){
            nOrders++;
        }
    if (nOrders == 0) OpenNew();
    :