[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 68

 
Stells:

Good afternoon.

Question how to test or whose results are more reliable ?

In the Expert Advisor the H1 period is clearly prescribed everywhere.

I am testing on m1 on open - clear loss.

I have tested it on H1 with all ticks going up.

The problem is that the stops are small - just a few points. Profits are large.

If the EA has explicit control over the opening of a new bar and it only works when a new bar opens, then you can test on the opening of a new bar. Otherwise, only ticks. Moreover, the stops are small and they will obviously be blown away at the opening of a new bar, because on M1 a bar can catch your stop in a few pips in a minute. Test all ticks on M1.
 
artmedia70:
If the EA has explicit control over the opening of a new bar and it only works when a new bar opens, then you can test on the opening of a new bar. Otherwise, only ticks. Moreover, the stops are small and they will obviously be blown away at the opening of a new bar, because on M1 a bar can catch your stop in a few pips in a minute. Test all ticks on M1.

how will (in theory) all ticks differ from H1 ?
 

Hello! Please help me to understand the code, what I'm doing wrong. I'm new to programming. I've read my mql4 tutorial and looked through a lot of Expert Advisor codes, but i still can't find the answers to my questions. I have a terminal with 5 digits, ECN account, variable spread + commission. The Expert Advisor is the easiest, it opens sell order when the fast МА crosses the slow МА from top to bottom and vice versa when the fast МА crosses the slow МА from bottom to top. In fact the TS is much more complex, I just don't have all basic functions working properly yet and cannot properly test it, let alone optimize it, I decided not to complicate the code with redundant calculations. Here is the code of the Expert Advisor itself.

#define MAGICMA  20050610
extern string text1              ="===========================MoneyManagment===========================";
extern double Lots               = 0.1;
extern string text2              ="======================Simple_Close_settings=========================";
extern double TakeProfit         = 100;
extern double StopLoss           = 100;
extern double Bezubitok          = 30; //Расстояние, через которое пройдёт цена от открытия сделки в "+", чтобы перенести СтопЛос в безубыток
extern string text3              = "===================TrailingStopLoss_settings=======================";
extern double Trailing           = 100; //Расстояние, через которое будет подтягиватся СтопЛос к текущей цене
extern double Slippage           = 3; // Допуск проскальзования цены при открытии и закрытии сделок
extern string text4              = "===================Indicator_Trade_System_settings=================";
extern int    Fast_EMA_Period    = 8;
extern int    Slow_EMA_Period    = 21;




//+------------------------------------------------------------------+
//| Calculate open positions                                         |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
  {
   int buys=0,sells=0;
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
        {
         if(OrderType()==OP_BUY)  buys++;
         if(OrderType()==OP_SELL) sells++;
        }
     }
//---- return orders volume
   if(buys>0) return(buys);
   else       return(-sells);
  }

//+------------------------------------------------------------------+
//| Check for open order conditions                                  |
//+------------------------------------------------------------------+
int CheckForOpen()
  {
   double X1,X2,X3,X4;
   int ticket;

   
   X1=iMA(NULL,0,Fast_EMA_Period,0,MODE_EMA,PRICE_CLOSE,1);
   X2=iMA(NULL,0,Slow_EMA_Period,0,MODE_EMA,PRICE_CLOSE,1);
   X3=iMA(NULL,0,Fast_EMA_Period,0,MODE_EMA,PRICE_CLOSE,2);
   X4=iMA(NULL,0,Slow_EMA_Period,0,MODE_EMA,PRICE_CLOSE,2);
//----
if(Volume[0]>1) return;
  {   
      //ENTRY Ask(buy, long) 
      if (X3<=X4 && X1>X2)
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,",",MAGICMA,0,White);
        }
      //ENTRY Bid (sell, short)
      if (X3>=X4 && X1<X2)
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,",",MAGICMA,0,Red);
        }
  }
//----
  }
//+------------------------------------------------------------------+
//| Check for TrailingStop                                           |
//+------------------------------------------------------------------+
void CheckForTrailing()
 {

     if (Trailing>0) for(int i=0; i<=OrdersTotal();i++) 
     {
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
           if (OrderMagicNumber()==MAGICMA && OrderSymbol()==Symbol()) 
           {
            if (OrderType()==OP_BUY && Bid-OrderOpenPrice()>Trailing*Point && Bid-OrderStopLoss()>Trailing*Point)
            OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Trailing*Point,OrderTakeProfit(),0,CLR_NONE);
            if (OrderType()==OP_SELL && OrderOpenPrice()-Ask>Trailing*Point && OrderStopLoss()-Ask>Trailing*Point)
            OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Trailing*Point,OrderTakeProfit(),0,CLR_NONE);
           }
        }
}
//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+
void CheckForClose()
  {
   double X1,X2,X3,X4;
//---- go trading only for first tiks of new bar
   if(Volume[0]>1) return;
//---- get Moving Average 
   X1=iMA(NULL,0,Fast_EMA_Period,0,MODE_EMA,PRICE_CLOSE,1);
   X2=iMA(NULL,0,Slow_EMA_Period,0,MODE_EMA,PRICE_CLOSE,1);
   X3=iMA(NULL,0,Fast_EMA_Period,0,MODE_EMA,PRICE_CLOSE,2);
   X4=iMA(NULL,0,Slow_EMA_Period,0,MODE_EMA,PRICE_CLOSE,2);
//----
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)        break;
      if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
      //---- check order type 
     
      if(OrderType()==OP_BUY)
        {
         if(Bid>=(OrderOpenPrice()+TakeProfit*Point)||Bid<=(OrderOpenPrice()-StopLoss*Point))OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
         break;
        }
        
      if(OrderType()==OP_SELL)
        {
         if(Ask<=(OrderOpenPrice()-TakeProfit*Point)||Ask>=(OrderOpenPrice()+StopLoss*Point)) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
         break;
        }
     }
//----
  }



//+------------------------------------------------------------------+
//| Start function                                                   |
//+------------------------------------------------------------------+
void start()
  {
   if(Bars<25 || IsTradeAllowed()==false) 
     return (0);
   if (AccountFreeMargin()<(100*Point*Lots))
     {
      Print("Стоп! Недостаточно средств для продолжения торговли. Свободная маржа = ", AccountFreeMargin());
      return(0);  
     }
      
   if(Trailing>0) CheckForTrailing();  
     
      
//---- calculate open orders by current symbol
   if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
   else                                    CheckForClose();
   
 
   

   return(0);
  }
//+------------------------------------------------------------------+

Maybe somebody can answer my questions:

1. When I open an order, I keep nulls in OrderSend where parameters Stopplos and TakeProfit should be; at an attempt to put other numbers there, the expert doesn't open deals; I checked if I can manually open a deal and immediately set SL and TP, what may be the problem?

2. I do not understand why I set TP, SL and TS of 100 pips, although trades are closed not multiple of these pips, even taking into account the spread. Maybe my order closing function does not work? How can I limit loss in this case, originally set SL, and how do I get it to follow price only in + direction?

3. My brokerage company has Stop Level=100 pips, how can I set virtual TP and SL, so that I could set levels lower than the Stop Level, like at manual closing of positions? (Pips in Ecn accounts is not prohibited).

4. Is it possible to do the following, and if it is possible: to make a reverse close and simultaneously close by the SL and TP with a transfer to Breakeven (depending on which event happens first)? I tried to do it, but in the tester it opens one position and does not close it until the end of the test, but only collects swaps). Either one of them works.

Thanks in advance to all who will answer!

 

Good afternoon ...

Just one question

Let's take a fractal on Daily... How to find the price which ends the formation of this fractal, say on H1 .... It is desirable that on the price appears arrow...

 
Cmu4:
Gentlemen, how does an EA connect to a specific server and port? Is it even possible?
So, are there no experts on the subject here?
 
Cmu4:
Gentlemen, how does an EA connect to a specific server and port? Is it even possible?

What does it mean to connect to a socket? Or to read information via http?
 
Hello.I have a simple and probably stupid question. Cana strategy tester make mistakes...What methods do you have for testing your strategies?..Thank you.
 

Just one question

Let's take a fractal on Daily... How to find the price which ends the formation of this fractal, say on H1 .... It is desirable that on the price appears arrow...

 

Good afternoon!

Question about special functions: init(), start(), deinit().

As you know, including from the tutorial, in order to terminate (exit) this special function, you MUST COMPLETELY add the

Return operator (for example, in conditional operator IF-ELSE).

What do the return values mean then? For example: Return(0) and possibly some other integer (Return(1));

 

Good afternoon all!

Please help me to edit a little the indicator "FX5_Divergence_V2.1".

I am working with 3 screens. The indicator in the window is displayed with its name and some other values and they make it hard to see the indicator. Often because of these figures I cannot see indicator nodes and it is difficult to compare them (circled in yellow on the screenshot).

(Please help me to correct the indicator so that only the indicator name is displayed, without all other digits)

Indicator and screenshot in appendix.


Thanks in advance to anyone who can help)


Reason: