Sequence Conditions

 

how do i sequence conditions within a cycle?

  while(Bars > LastBar)
     {
      if(OrdersTotal()<=10)
         if(Zone1=="sell")//signal 1
         if(Zone2=="sell")//signal 2
            if(signal=="sell") //signal 3
                if(Zone3=="sell")// signal 4
               sell=OrderSend(_Symbol,OP_SELL,0.10,Bid,3,Ask+200,Bid-200,NULL,0,0,Red);    //Volatility Measure
      LastBar=Bars+1;
 
12345abc22:

how do i sequence conditions within a cycle?

I was not sure what you meant exactly, but looking at the code, is it not the same as anding all terms?

For example:

      if(
                (OrdersTotal()<=10)
                &&      (Zone1=="sell") //signal 1
                &&      (Zone2=="sell") //signal 2
                &&      (signal=="sell")  //signal 3
                &&      (Zone3=="sell") //signal 4
	)
                {
            	sell=OrderSend(_Symbol,OP_SELL,0.10,Bid,3,Ask+200,Bid-200,NULL,0,0,Red);    //Volatility Measure
                } 
 
sell=OrderSend(_Symbol,OP_SELL,0.10,Bid,3,Ask+200,Bid-200,NULL,0,0,Red);

You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
    Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).

 
R4tna C #:

I was not sure what you meant exactly, but looking at the code, is it not the same as anding all terms?

For example:

I mean to say: conditions at Zone1 is required before Zone 2 conditions can be met and Zone 1/2 conditions have to be met before zone 3 conditions are considered.

Files:
image.jpg  533 kb
 
12345abc22 #:

I mean to say: conditions at Zone1 is required before Zone 2 conditions can be met and Zone 1/2 conditions have to be met before zone 3 conditions are considered.

Then I guess you want some nested if statements:

   if(OrdersTotal() <= 10)
     {
      if(Zone1 == "sell") //signal 1
        {

         if(Zone2 == "sell") //signal 2
           {

            if(Zone3 == "sell") //signal 3
              {

               if(Zone4 == "sell") // signal 4
                 {
                 
                  // your tasks
                  
                 } //end - if signal 4

              } //end - if signal 3

           }  //end - if signal 2

        } //end - if signal 1
        


Or sequenced checks which would work when in a loop:

   if(OrdersTotal() <= 10)
     {
      if(Zone1 != "sell") //signal 1
        {
        continue;
        }

      if(Zone2 != "sell") //signal 2
        {
        continue;
        }

      if(Zone3 != "sell") //signal 3
        {
        continue;
        }
        
      if(Zone4 != "sell") //signal 4
        {
        continue;
        }

   	//Your tasks
  }


But the earlier "and" statement could work too - would only be true when all conditions are met

Reason: