Off-topic posts - page 96

 

Hi, 

I am new to MT5.  I am not inquiring about specific brokers, or trying to get recommendations.  I want to respect the above wishes, but I am curious about something.  Not so long ago I installed MT5 on my machine.  I clicked on file - webtrader,  and it took me to a site where it looked alive, prices were moving, trades could be made,  and there was a $100,000 demo account.  I was kind of having fun practicing on it.  I went there today and it looked like it had been cut off, and had brecieved no data since midnight last night.

I couldn't see any broker name, but I am curious, was it actually a broker, or a temporary service for practice provided by MT5.  No broker names need be mentioned here, I am just trying to figure out what just happened,  Any thoughts within the guidelines of this thread would be appreciated.

Cheers.

 
Slobbergirkin56 #:

Hi, 

I am new to MT5.  I am not inquiring about specific brokers, or trying to get recommendations.  I want to respect the above wishes, but I am curious about something.  Not so long ago I installed MT5 on my machine.  I clicked on file - webtrader,  and it took me to a site where it looked alive, prices were moving, trades could be made,  and there was a $100,000 demo account.  I was kind of having fun practicing on it.  I went there today and it looked like it had been cut off, and had brecieved no data since midnight last night.

I couldn't see any broker name, but I am curious, was it actually a broker, or a temporary service for practice provided by MT5.  No broker names need be mentioned here, I am just trying to figure out what just happened,  Any thoughts within the guidelines of this thread would be appreciated.

Cheers.

The market closes for most instruments on Friday night and opens again on Sunday night.

 

Thanks, I forgot it was a Saturday.

cheers.

 
Hamza59 #:nI want to Modify my SL ,TP and Pending Order Price to the Moving Average Price.I
  1. Don't hijack other threads for your off-topic post. Next time, make your own, new, thread.

  2. Examples are in the documentation.

  3. Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    We can't see your broken code.

    Always post all relevant code (using Code button) or attach the source file.

 
Good afternoon guys . I have the following code in mql5 that is not working as expected . The code is supposed to open trades on 2 setups , namely the big shadow and the kangaroo tail . here is how the setups are formed 1 Big shadow : it is a candle that engulfs the previous candle and has the lowest low or high of the previous 7 bars . when it is a bullish candle it closes in the top fifth of the candle and when it is a bearish candle it closes in the bottom fifth of the candle . 2 : kangaroo tail : it open and closes in the top third of the candle , when the candle is bullish and close and opens in the bottom third of the candle when the candle is bearish. well the type of the trade ie buy or sell, is determined by one condition, the high or low . If the candle has the lowest low of the previous 7 candles , trade is a buy .However if the candle has the highest high of previous 7 candles , it is a sell trade . Finally , the setup candle has to be on a support and resistance zone and have a body size that is half of the candle's range . I coded all this and it doesnt open trades on the correct candles . It looks like the EA is opening trades randomly during the test. why does this happen ?



#property copyright "Copyright 2023, DAVID BUTA"
#include <Trade/Trade.mqh>

CTrade trade;
input ENUM_TIMEFRAMES tf = PERIOD_CURRENT;
input string expire = "03:00";
input ENUM_APPLIED_PRICE pr = PRICE_CLOSE;
 double zones [] = {102.839,134.560,126.212,119.395,122.873,110.074,105.622,108.462,107.042,115.933,111.364,
                         112.043,124.640,121.182,117.662,132.729,123.775,128.715,114.053,104.511,109.226,116.932,120.298,118.628,
                         127.912,131.377,112.887,105.042,103.962,102.100,103.398,115.243,125.355,121.679,107.633,106.390
                        };
int bars ;
int barstotal;
datetime expires = StringToTime(expire);
int OnInit()
  {
  Print(expires);
for (int i = 0; i < ArraySize(zones); i++)
    {
        double level = zones[i];
        string objName = "zone" + DoubleToString(level, 4);

        // Create horizontal line object
        ObjectCreate(0, objName, OBJ_HLINE, 0, 0, level);

        // Set line color to red
        ObjectSetInteger(0, objName, OBJPROP_COLOR, clrRed);
    }
   barstotal = iBars(_Symbol,tf);
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {


  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   bars = iBars(_Symbol,tf);
   
     

      double low1 = iLow(_Symbol,tf,1);
      double low2 = iLow(_Symbol,tf,2);
      double high1 = iHigh(_Symbol,tf,1);
      double high2 = iHigh(_Symbol,tf,2);
      double close1 = iClose(_Symbol,tf,1);
      double open1 = iOpen(_Symbol,tf,1);

      double low_index = iLowest(_Symbol,tf,MODE_LOW,7,1);
      double high_index = iHighest(_Symbol,tf,MODE_HIGH,7,1);
      double range = high1 - low1;
      range = NormalizeDouble(range,3);
      double top_third = high1 - (0.3 * range);
      top_third = NormalizeDouble(top_third,3);
      double bottom_third = low1 + (0.3 * range);
      bottom_third = NormalizeDouble(bottom_third,3);
      double top_5th = high1 - (range * 0.5);
      top_5th = NormalizeDouble(top_5th,3);
      double bottom_5th = low1 + (range * 0.5);
      bottom_5th = NormalizeDouble(bottom_5th,3);

      double range_value = range  / 2;
      range_value = NormalizeDouble(range_value,3);
      
    
      double money = 1.0;
      if( newBar()){ // big shadow setup description starts
                     if((close1 > open1 || close1 < open1) && money != 0)  // bullish or bearish
        {
         double body = close1 > open1 ? close1 - open1 : open1 - close1; // bullish ? then body is that value
         bool candle_type_bullish = close1 > open1 ? true : false; // true is bullish , false is bearish
         if(low1 < low2 && high1 > high2) // engulfs
           {
            if(body > range_value) // not a weakie
              {
               if(low_index == 1  && at_zone(high1,low1)) // highest low value of the previous 7 candles, starting from
                 {
                  if(candle_type_bullish == true && close1 >= top_5th)
                    {
                     BUY_STOP(money,high1,low1);
                    }
                  else
                     if(candle_type_bullish == false && close1 <= bottom_5th)
                       {
                        BUY_STOP(money,high1,low1);

                       }

                     else
                        if(high_index == 1 && at_zone(high1,low1))
                          {
                           if(candle_type_bullish == true && close1 >= top_5th)
                             {
                              SELL_STOP(money,low1,high1);
                             }
                           else
                              if(candle_type_bullish == false && close1 <= bottom_5th)
                                {

                                 SELL_STOP(money,low1,high1);
                                }
                          }
                 }// big setup description shadow ends
              }
           }
        }





      else // kangaroo tail setup description  description starts
         if((close1 >= top_third && open1 >= top_third) ||(close1 <= bottom_third && open1 <= bottom_third))  // bullish or bearish kt
           {
            if(low_index == 1  && at_zone(high1,low1))
              {
               if(close1 < high2 && close1 > low2 && open1 < high2 && open1 > low2) // original kt setup, within range
                 {
                  BUY_STOP(money,high1,low1);

                 }
              }
            else
               if(high_index == 1 && at_zone(high1,low1))
                 {
                  if(close1 < high2 && close1 > low2 && open1 < high2 && open1 > low2)
                    {
                     SELL_STOP(money,low1,high1);
                    }

                 }// kangaroo tail  setup description ends
           
      //+------------------------------------------------------------------+
     }}
   else
      trail_position(high1,low1,range);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool at_zone(double high,double low)// this function proves whether the setup is on a support and resistance zone or not
  {
   int v = 0;
   for(int i=0; i< ArraySize(zones); i++)
     {
      if(high > zones[i] && low < zones[i])   // INCLUDE THE PIPS FOR SLIPPAGE, as well as the indication values
        {
         v +=1;
        }
     }
   if(v > 1)
     {
      return true;
     }
   else
      return false;
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double calclots(double riskpercent,double sldistance)  // sldistance is the range in pips
  {

   double ticksize = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE);
   double tickvalue = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE);
   double lotstep = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
   if(ticksize == 0 || tickvalue == 0 || lotstep == 0)
     {
      return 0;
     }

   double riskmoney = AccountInfoDouble(ACCOUNT_BALANCE) * riskpercent / 100;
   double moneylotstep = (sldistance / ticksize) * tickvalue * lotstep ;
   if(moneylotstep == 0){return 0;}
   double amount = MathFloor(riskmoney / moneylotstep) * lotstep;
   return amount;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void trail_position(double high,double low,double range)
  { range = NormalizeDouble(range,1);
   double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
   bid = NormalizeDouble(bid,3);
   double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   ask = NormalizeDouble(ask,3);
   for(int i = PositionsTotal() - 1 ; i >= 0; i--)
     {
      ulong posTicket = PositionGetTicket(i);
      if(PositionSelectByTicket(posTicket))
     {
      double posSL = PositionGetDouble(POSITION_SL);
         double posTP = PositionGetDouble(POSITION_TP);
         if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
           {
            double tp1 = high + (range * 1.5);
            if(ask > tp1)
              {
               double tp2 = high + (range * 2.5);
               trade.PositionModify(posTicket,tp1,tp2);
              }

           }
         else
            if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
           { 
            double tp1 = low - (range * 1.5);
               if(bid < tp1)
                 {
                  double tp2 = low - (range * 2.5);
                  trade.PositionModify(posTicket,tp1,tp2);
                 }
              }
        }
     }


  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BUY_STOP(double amount,double entry,double loss)
  { entry = entry + 0.002;
   trade.BuyStop(amount,entry,_Symbol,loss,0.0,ORDER_TIME_GTC,expires,"buy");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SELL_STOP(double amount,double entry,double loss)
  { entry = entry - 0.002;
   trade.SellStop(amount,entry,_Symbol,loss,0.0,ORDER_TIME_GTC,expires,"sell");
  }
//+------------------------------------------------------------------+
bool newBar(){
static int lastbarcount = 0;
if(Bars(_Symbol,PERIOD_CURRENT) > lastbarcount){
lastbarcount= Bars(_Symbol,PERIOD_CURRENT);
return true;
}
else return false;
}
 
datetime expires = StringToTime(expire);

That is not an assignment; it's initialization of a common (globally declared), or static variable(s) with a constant. They work exactly the same way in MT4/MT5/C/C++.

  1. They are initialized once on program load.

  2. They don't update unless you assign to them.

  3. In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).

    MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:

    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

  4. Unlike indicators, EAs are not reloaded on chart change, so you must reinitialize them, if necessary.
              external static variable - MQL4 programming forum #2 (2013)

 
William Roeder #:

That is not an assignment; it's initialization of a common (globally declared), or static variable(s) with a constant. They work exactly the same way in MT4/MT5/C/C++.

  1. They are initialized once on program load.

  2. They don't update unless you assign to them.

  3. In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).

    MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:

    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

  4. Unlike indicators, EAs are not reloaded on chart change, so you must reinitialize them, if necessary.
              external static variable - MQL4 programming forum #2 (2013)

why does the EA still open trades during testing ? 

 
Hi All,I tried to add a second stochastic to someone else's stochastic alert indicator but can't get it to display the second the second stochastic. Can anyone help ?.
 

When I sign up for the platform's introductory account, it asks me for the password, and when I type a code and save it, it says the password is wrong. Help us to complete the rest of the settings.

 
@انور شمسان سعيد #: When I sign up for the platform's introductory account, it asks me for the password, and when I type a code and save it, it says the password is wrong. Help us to complete the rest of the settings.

It is difficult to understand your question.

Are you referring to a trading account or the MQL5 website community account?

Can you show a screenshot?

Reason: