[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 296

 
forexnew:

How to portray:

/

in string?

For example:

string path=TerminalPath()+"/logs/"+tekTime+".log";

gives an error, and if you remove the slash "/"

string path=TerminalPath()+"logs "+tekTime+".log";

- no error.




Read here and here.

 
ZZZEROXXX:

maybe see what else IsTradeAllowed() returns ?

Could you please help me? I'm trying to build a trend by two points, linked to the bars by N bars ahead from the last point. I.e. incoming - time-price of the first and second point, and N expressed in number of bars ahead (checkbox beam = false). If the second point, assume, lies on bar 1 from the current bar 0, and I have to draw from it 10 bars ahead, how can I calculate the time and price of the bar from the future?

This one works, too, if you happen to hit a busy trade thread by accident while compiling your EA. I'm looking for a way to display in EA comments messages from logs about requests . It seems that practically not many people have asked such a task.
 
PapaYozh:


Read here and here.

Thank you!
 

Can't the esteemed gurus help?

pvm117 20.10.2011 18:26

Good afternoon!

As a first experience I have decided to implement the following algorithm: I can expect a sharp market movement up or down in some time after the Bollinger lines converge into a narrow corridor. In my Expert Advisor, I analyze the state of Bollinger lines and when they are getting very close(Delta pips), we put a pending sell order in the lower direction (at stepOpen pips below the lower line), hoping that the market will suddenly go in that direction. If the market went in another direction, we simply delete this order.

extern double Delta=800.0;              // Ширина канала, которую мы считаем достаточно узкой чтобы ожидать скоро серьезного движения в одну из сторон
extern double StepOpen=150.0;           // Отступ от линии Боллинджера  для открытия отложенного ордера
extern double TP=350.0;                 // Take Profit
extern double SL=400.0;                 // Stop Loss

int start()
  {
   double T1=iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,0);  // верхняя линия Боллинджера
   double T2=iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,0); // нижняя линия Боллинджера
   if ((Ask>T1+StepOpen*Point)&&OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true) OrderDelete(0); // если рынок пошел вверх – то удаляем отложенный ордер
   if (OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true) return(0); // если есть ранее открытый ордер – прекращаем выполнение текущей итерации советника
   if (T1-T2<Delta*Point) {               // если линии Боллинджера сблизились ближе чем на Delta пунктов начинаем операцию открытия ордера
      double PriceOpen=NormalizeDouble(T2-StepOpen*Point,5);  // вычисляем цену открытия
      double StopLoss=NormalizeDouble(T2-StepOpen*Point+SL*Point,5); // вычисляем StopLoss
      double TakeProfit=NormalizeDouble(T2-StepOpen*Point-TP*Point,5); // вычисляем TakeProfit
      OrderSend(Symbol(),OP_SELL,0.1,PriceOpen,5,StopLoss,TakeProfit,0,0,0,Green); //  открываем ордер на продажу
            }
   return(0);
  }
The algorithm works unstable, sometimes opens two orders in a short period of time, constantly gives errors OrderSend Error 130 and OrderSend Error 138, and removing open orders in case the market moves in the other direction does not work at all.

Please, advise us! Thank you!

 
pvm117:

Can't the esteemed gurus help?

pvm117 20.10.2011 18:26

Good afternoon!

As a first experience I have decided to implement the following algorithm: I can expect a sharp market movement up or down in some time after the Bollinger lines converge into a narrow corridor. In my Expert Advisor, I analyze the state of Bollinger lines and when they are getting very close(Delta pips) , we put a pending sell order in the lower direction (at stepOpen pips below the lower line), hoping that the market will suddenly go in that direction. If the market went in another direction, we simply delete this order.

The algorithm works unstable, sometimes opens two orders in short intervals, constantly gives errors OrderSend Error 130 and OrderSend Error 138, and removing open orders in case the market moves in the other direction does not work at all.

Please, advise us! Thanks!

OrderSend(Symbol(),OP_SELL,0.1,PriceOpen,5,StopLoss,TakeProfit,0,0,0,Green); //  открываем ордер на продажу

This is not a pending order, but a market order.

accordingly its opening price must be different and it cannot be deleted (OrderDelete), but only closed

 

Greetings to all connoisseurs and experienced readers of this thread! And just anyone who can help me=)

What is the easiest and "correct" way to achieve periodicity? That is, to simplify, I want to automatically perform some action every 15 minutes.

In my case, it's saving a file to disk with some statistics. Now I have a script that does what I want, and it's literally 20 lines of code. So how do I get those 20 lines to repeat at intervals? As I understood, there are no timers in MQL... Do I need to use an EA that will do some kind of check every tick...?

I hope for your help and tips)

 
Hi, can you tell me if there is any other way to set the timeframe of a multi-currency EA other than in the indicator via M_30 H_1, D_1 and so on?
 
skyjet:
Hi, can you tell me if there is any other way to set the timeframe of a multi-currency EA other than in the indicator via M_30 H_1, D_1 and so on?

What's the problem?
 

Hello.

Here is a question: advise how to use yellow line as a momentum forecast and white line as a OsM forecast on a long uptrend of the upper frame?

It's hard to determine the amplitude between the peaks of the waves, so advise where to dig next ;)


 
Sancho77:

Select the first, out of the open positions.

You need it all to check the distance in pips between the first open position and the last open position among the open positions.

Just a quick rewrite, maybe it'll help? Didn't check...

double PriceOpenFirstPos(string sy="", int op=-1, int mn=-1) {
   datetime t=TimeCurrent();
   double   r=0;
   int      i, k=OrdersTotal();

   if (sy=="0") sy=Symbol();
   for (i=0; i<k; i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==sy || sy=="") {
            if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
               if (op<0 || OrderType()==op) {
                  if (mn<0 || OrderMagicNumber()==mn) {
                     if (OrderOpenTime()<t) {
                        t=OrderOpenTime();
                        r=OrderOpenPrice();
                        }
                     }
                  }
               }
            }
         }
      }
   return(r);
}

Try it this way...