Frozen Market Watch?

 

Hello MQL4 forum,

Monday, Dec 24, 2012, 6:25 pm. Market Watch reads, 19:59:59. As far as I can recall, the FOREX trading week begins sunday and ends friday. I've connected My MT4 terminal to demo, live, default and different servers with 76/1 kb ratio server connection, but the market watch still does not move nor the currencies.

What is going on?

Thank you.

 
WhooDoo22:

Hello MQL4 forum,

Mon.Dec 24, 2012, 6:25 pm. Market Watch reads, 19:59:59. As far as I can recall, the FOREX trading week begins sunday and ends friday. I've connected My MT4 terminal to demo, live, default and different servers with 76/1 kb ratio server connection, but the market watch still does not move nor the currencies.

What is going on?

What is going on ?  Christmas.  Merry Christmas. :-)
 
WhooDoo22:

Hello MQL4 forum,

Mon.Dec 24, 2012, 6:25 pm. Market Watch reads, 19:59:59. As far as I can recall, the FOREX trading week begins sunday and ends friday. I've connected My MT4 terminal to demo, live, default and different servers with 76/1 kb ratio server connection, but the market watch still does not move nor the currencies.

What is going on?

Thank you.

******* Merry Christmas *******

-hope everyone's enjoying their day off, and spending time with their love ones.

 

I would not even have known it was Christmas if you both didn't post responses.

Merry Christmas MQL4 community.

Thank you.

 

Time to bring this exercise to an end . . . here is my code,  criticise, discuss, ask questions all you like. 

//place one market order for 0.1 lots with no TP or SL on GBPUSD,  one on USDJPY and one on EURUSD . . . 
//    forget the order in which you placed these Orders

//without any consideration of the order in which the trades were placed and assuming no prior knowledge 
//  of the number of orders placed write some code that will find the correct ticket number for the order placed on USDJPY

//print the ticket number to the log in the form  "Ticket number for USDJPY =   "

//then use the ticket number to select the order,  then modify it so that it has a TP & SL and finally close it. 

extern double TakeProfit = 400;   //  number of points TP is plced away from entry price 
extern double StopLoss = 400;     //  number of points SL is plced away from entry price 
extern int Slippage = 10;

int start()
   {
   int PositionIndex;    //  <-- this variable is the index used for the loop
   int Direction;
   double UJPoint;       //  point value for USDJPYi

   UJPoint = MarketInfo("USDJPYi", MODE_POINT);     // gets the point value for USDJPYi

   for(PositionIndex = OrdersTotal() - 1; PositionIndex >= 0 ; PositionIndex --)  //  <-- for loop to loop through all Orders . .   COUNT DOWN TO ZERO !
      {
      if( ! OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES) ) continue;   // <-- if the OrderSelect fails advance the loop to the next PositionIndex

      Direction = ( ( -2 * OrderType() ) + 1 );                                 //  for a Sell = -1 for a Buy = 1

      if( OrderSymbol() == "USDJPYi"          // <-- does the Order's Symbol match USDJPYi ? 
         && ( OrderType() == OP_BUY           // <-- is the Order a Buy Order ? 
         ||   OrderType() == OP_SELL ) )      // <-- or is it a Sell Order ?
         {
         Print("Ticket number for USDJPYi = ", OrderTicket());      //  print the ticket number
      
         if(! OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - ( StopLoss * Direction * UJPoint), OrderOpenPrice() + ( TakeProfit * Direction * UJPoint ), 0 ) )
            {
            Print("Order Modify failed, order number: ", OrderTicket(), " Error: ", GetLastError(), " SL: ", DoubleToStr(OrderOpenPrice() - 
            ( StopLoss * Direction * UJPoint), Digits), 
            " TP: ", DoubleToStr(OrderOpenPrice() + ( TakeProfit * Direction * UJPoint ), Digits) );
         
            continue;                                                             // don't close the order if the Modify fails
            }
         
         if ( ! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage ) )               // <-- try to close the order
            Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError() );  // <-- if the Order Close failed print some helpful information 
         
         }  // end of if( OrderSymbol() == "USDJPY"
         
      } //  end of for loop
   
   } // end of start
 

Simon, just by eyeballin' this, it seems to be a very similar method I am also using. There are some differences, but overall, it is doing the same thing as the code below. The code below uses no functions for modification of the USDJPY order's TP,SL, and closing the order, BUT ;) if the order is currently selected, all the rest is straight forward.

int start()
  {
   
   int i;

   if((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)&&(OrderSymbol()=="USDJPY"))
   
     OrderPrint();      
     
     else i++;
   
 // Print(GetLastError());
 
Comment("i = " ,i);

   return(0);
  }

The only problem is this code only increases variable i by 1, the "i++;" does not continue increasing i until the OrderSymbol() function is "USDJPY".

Question: Why is the "i++;" increasing i's value one time only?

https://www.mql5.com/en/forum/142641/page6

I am also working on this, but I would appreciate your feedback also.

Thank you.

 
WhooDoo22:

Simon, just by eyeballin' this, it seems to be a very similar method I am also using. There are some differences, but overall, it is doing the same thing as the code below. The code below uses no functions for modification of the USDJPY order's TP,SL, and closing the order, BUT ;) if the order is currently selected, all the rest is straight forward.

The only problem is this code only increases variable i by 1, the "i++;" does not continue increasing i until the OrderSymbol() function is "USDJPY".

Question: Why is the "i++;" increasing i's value one time only?

https://www.mql5.com/en/forum/142641/page6

I am also working on this, but I would appreciate your feedback also.

Thank you.

As I said a few days ago . .  you need a loop,  you can use a for loop or a while loop,  essentially they are the same . . but you need a loop . . .  the fact you still haven't used one suggests you need to read up on them and practice  . . .
 

Hello MQL4 comunity,

I was doing a little reading on for and while loops. Many posts have been made stating Volume I uses unnecessary "{ }" (braces). I believe I now understand correct use of braces. I will provide an example of correct use of braces AND explanation.

// Example: while loop.

while(k<n)
  {
   y=y*x;
   k++;
  }

Explanation: It seems braces are used when multiple operations are included in a function call. If there is a single operation contained within the function call, there is no need for braces. I'll keep this in mind and await response from the community for confirmation of this rediscovery.

Thank you.

 
WhooDoo22:

Hello MQL4 comunity,

I was doing a little reading on for and while loops. Many posts have been made stating Volume I uses unnecessary "{ }" (braces). I believe I now understand correct use of braces. I will provide an example of correct use of braces AND explanation.

Explanation: It seems braces are used when multiple operations are included in a function call. If there is a single operation contained within the function call, there is no need for braces. I'll keep this in mind and await response from the community for confirmation of this rediscovery.

Essentially you are correct,  just one point to bear in mind,  while is not a function it is an Operator  
 
WhooDoo22:

Hello MQL4 comunity,

I was doing a little reading on for and while loops. Many posts have been made stating Volume I uses unnecessary "{ }" (braces). I believe I now understand correct use of braces. I will provide an example of correct use of braces AND explanation.

Explanation: It seems braces are used when multiple operations are included in a function call. If there is a single operation contained within the function call, there is no need for braces. I'll keep this in mind and await response from the community for confirmation of this rediscovery.

Thank you.

while is more an operator than a function call. However, I think you mean the right thing. Checkt this https://book.mql4.com/operators/while it gives you confirmation.

 

Simon, I appreciate your post. Thank you.

Phil, I'll read this page of the book. Thank you.

Thank you.