Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1955

 
Can someone please help me i turned off autotrading and trades keep getting made and they are all losing and my account is getting drained and Oanda wont get back to me
 
oandapandasd #:
Can someone please help me i turned off autotrading and trades keep getting made and they are all losing and my account is getting drained and Oanda wont get back to me
Are you running on a VPS or just on your own PC? If VPS you'd need to remove EAs then synchronize. 
 

hello

My name is nelson I am new programmer I was asking if it possible to make Depth of market indicator using mql4. if there is any please help with that.

 
Nelson3056 #: hello My name is nelson I am new programmer I was asking if it possible to make Depth of market indicator using mql4. if there is any please help with that.

Not possible on MQL4! Consider moving to MT5.

 
Fernando Carreiro #:

Not possible on MQL4! Consider moving to MT5.

OK THANK YOU SIR

 

Hello! Can you tell me why my  integer 'Prevent Order' is not being revalued to '0' in the bottom section? Everything else works fine.


   double LinePrice      = iMA(NULL, 0, 1,    0, MODE_LWMA, PRICE_WEIGHTED, 0);
   double LineAxis       = iMA(NULL, 0, 10/3, 0, MODE_LWMA, PRICE_WEIGHTED, 0);
   double LineCeiling    = iMA(NULL, 0, 10/3, 0, MODE_LWMA, PRICE_HIGH + (PRICE_HIGH / 3000), 0);
   double LineFloor      = iMA(NULL, 0, 10/3, 0, MODE_LWMA, PRICE_LOW  - (PRICE_LOW  / 3000), 0);
   double NeutralCeiling = iMA(NULL, 0, 70/3, 0, MODE_LWMA, PRICE_HIGH + (PRICE_HIGH / 3000), 0);
   double NeutralFloor   = iMA(NULL, 0, 70/3, 0, MODE_LWMA, PRICE_LOW  - (PRICE_LOW  / 3000), 0);
   static int PreventOrder = 0;

//--------------------------------
//Orders

   //-Send Order Outside of Neutral and Prevent New Order
   if((OrdersTotal() == 0) && (PreventOrder == 0))
   {
      if(LineFloor   > NeutralCeiling)
      {
         if(LinePrice > LineAxis)
            {  OrderSend(_Symbol, OP_BUY,  0.01, Ask, 0, 0, 0, NULL, 0, 0, clrRed);   }
      }
      if(LineCeiling < NeutralFloor  )
      {
         if(LinePrice < LineAxis)
            {  OrderSend(_Symbol, OP_SELL, 0.01, Bid, 0, 0, 0, NULL, 0, 0, clrViolet);}
      }
      PreventOrder = 1;
   }
   
   //-Close Order on Crossover
//   if((OrdersTotal() == 1)
//   {
//      if((OrderType() == OP_BUY)  && (LinePrice < LineAxis))
//      {  CeaseOrder();}
//      if((OrderType() == OP_SELL) && (LinePrice > LineAxis))
//      {  CeaseOrder();}
//   }

   //-Close Order in Neutral and Allow New Order
   if((LineAxis < NeutralCeiling) && (LineAxis > NeutralFloor))
   {  CeaseOrder(); PreventOrder = 0;}
 
TeoDeo #:

Hello! Can you tell me why my  integer 'Prevent Order' is not being revalued to '0' in the bottom section? Everything else works fine.


Do not double post!

I have deleted your other topic.

 
TeoDeo #:! Can you tell me why my  integer 'Prevent Order' is not being revalued to '0' in the bottom section? 
   double LineCeiling    = iMA(NULL, 0, 10/3, 0, MODE_LWMA, PRICE_HIGH + (PRICE_HIGH / 3000), 0);
  1. You are using a LWMA period of three.
              On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 programming forum (2012)
              build 2504 & 2506 Bug - General - MQL5 programming forum - Page 2 #17 (2020)

  2. The ENUM_APPLIED_PRICE PRICE_HIGH is two. Two+two/3000 =two=PRICE_HIGH

  3. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

 
Hey there I'd like to purchase Trader advisor for a friend, his birthday is coming and id like to surprise him with 1year rental how do i purchase it for him? Thank you! 
 

Hello!

I'm trying to write a function that allows for trading within 5 min before the candle close (on D1).

After hours of head scratching, I noticed that Strategy tester is NOT evaluating all ticks toward the end of the candle close. As an example, see this transition from 1/4/21 to 1/5/21. I use Tick-level data downloaded from Dukascopy.

    0   12:22:26.043    2021.01.04 22:00:00  sandbox_QA EURUSD,Daily: Alert: === trade_window_start=86100 time_in_candle=79200 sec_in_day=86400
    0   12:22:26.043    2021.01.05 00:00:00  sandbox_QA EURUSD,Daily: Alert: === trade_window_start=86100 time_in_candle=0 sec_in_day=86400

24 hrs is 86400 seconds, so I want to start trading window after the 86100 th sec (5 min before candle close), but the latest recorded tick was "79200", so it doesn't work.

Here's the code to replicate the issue and I'd appreciate your help! Thanks :)

    void OnTick()
      {
       bool trading_window = isWithinTradeHours();
       return;
      }
     
    bool isWithinTradeHours()
      {
       int time_in_candle = int(TimeCurrent()-Time[0]);
       int sec_in_day = 24 * 60 * 60;
       int trade_window_start = sec_in_day - (5 * 60); // 5min before candle close
       
       // print every 100 sec to reduce the size of the log
       if((time_in_candle % 100) == 0)
         {
          Alert("=== trade_window_start=", trade_window_start, " time_in_candle=", time_in_candle, " sec_in_day=", sec_in_day);
          Sleep(100);
         }
     
       if((time_in_candle > trade_window_start))
         {
          Alert("====== Trading Time: ", TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS), " Time in candle:", int(TimeCurrent()-Time[0]));
          Sleep(100);
          return true;
         }
       else
         {
          return false;
         }
      }


I'm running with "Every Tick":

Reason: