[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 279

 

If you know, there are two lines, one following the new highs in a series of candlesticks, the other following the lows. When the distance between the lines is more than 50 a vertical line should be drawn. The vertical line needs a coordinate - time. How can I draw the time when the distance between the lines will be more than 50? I can't think of anything.

I wanted to draw the vertical line using ObjectCreate... If it can be done without time, what should be used?
 
waitra >> :

Could there be a function that simply detects that "there are no orders in the EA history yet"? - That would be enough.

I don't know. Maybe someone here can tell us ?

I think we should try to modify Kim's function. This one:

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru            |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                  |
//|  Описание : Возвращает количество позиций.                |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                            |
//|    sy - наименование инструмента   (""   - любой символ,  |
//|                                     NULL - текущий символ)          |
//|    op - операция                   (-1   - любая позиция)       |
//|    mn - MagicNumber                (-1   - любой магик)               |
//+----------------------------------------------------------------------------+
int NumberOfPositions(string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), kp=0;
  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) kp++;
          }}}}}  return( kp);}

I.e., instead of MODE_TRADES, take MODE_HISTORY - i.e. the order is selected among closed and deleted orders.

Then (change the name of f-i) :

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru            |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                  |
//|  Описание : Возвращает кол-во ордеровиз истории счета  |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                           |
//|    sy - наименование инструмента   (""   - любой символ, |
//|                                     NULL - текущий символ)        |
//|    op - операция                   (-1   - любая позиция)       |
//|    mn - MagicNumber                (-1   - любой магик)             |
//+----------------------------------------------------------------------------+
int NumberOfPos_HISTORY (string sy="", int op=-1, int mn=-1) {
  int i, k=OrdersTotal(), kp=0;
  if ( sy=="0") sy=Symbol();
  for ( i=0; i< k; i++) {
    if (OrderSelect( i, SELECT_BY_POS, MODE_HISTORY )) {
      if (OrderSymbol()== sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if ( op<0 || OrderType()== op) {
            if ( mn<0 || OrderMagicNumber()== mn) kp++;
          }}}}}  return( kp);}

Try it, - will it work or not ?

 

Good afternoon, friends.


Please advise me on this.


For example, I need to open a position up when a "price candle" has crossed a moving average.

So far, I only know how to classify signals when a candlestick closed/opened above/below the moving average...

( iMA( .....) >Close[1] or iMA(....) >Open[0] )

How can I enter when the current candle is already above/below the MA, instead of waiting for the current one to close and the next one to open, if it is already above/below the MA?


Thank you very much in advance.

 
Morzh09 >> :

Good afternoon, friends.


Please advise me on this.


For example, I need to open a position up when a "price candle" has crossed a moving average.

So far, I only know how to classify signals when a candlestick closed/opened above/below the moving average...

( iMA( .....) >Close[1] or iMA(....) >Open[0] )

How can I enter when the current candle is already above/below the MA, instead of waiting for the current one to close and the next one to open, if it is already above/below the MA?


I do not know what to do with it.

How do you like it?

iMA(....) >Open[0] ? - zero is the current candle.

 
rid >> :

What's not to like:

iMA(....) >Open[0] ? - zero is the current candlestick

it is true, but, for example, there are cases when, after opening under the MA, the price then (usually on the news) breaks the MA in a long candle and goes up, down....

If we use my criteria of opening, we may miss such moves...

So, I would like to open a position if the price is currently above/below the average, rather than waiting for this one to close and the next candle to open.

 

This could be :

if (  iMA(.... .... , 1) >Close[1]  && iMA(.... ... , 0) < Open[0]  ) // продажа

(If the MA on the previous bar is greater than the close price of the previous bar and the MA on the current bar becomes less than the open price of the current bar, then sell)

 

I've been messing around for two days and can't figure it out. I took the code from Kovalev's tutorial and tried to open a buy order and got the answer "Error 130".

Code

nt f_Open_Ord(int Tip)
{
int Ticket, // Order number
MN; // MagicNumber

double SL, // StopLoss (relative price value)
TP; // TakeProf (relative price value)
//--------------------------------------------------------------- 3 --
while(g_Mas_Tip[Tip]==0) // As long as .
{ //...no success
if (SL<g_Level_new) // if less than allowed...
SL=(g_Level_new+20); // ... then allowable
if (TP<g_Level_new)
// If less than allowable...
TP=(g_Level_new+20); // .then allowable
MN=TimeCurrent(); // Simple MagicNumber
f_Inform(13,Tip); // Message on attempt to open
if (Tip==0) // Let's open Buy
{
SL=Bid - SL*Point; // StopLoss (price)
SL=NormalizeDouble(SL,Digits);
TP=Bid + TP*Point; // TakeProfit (price)
TP=NormalizeDouble(TP,Digits);
Ticket=OrderSend(Symbol(),0,g_Lots_New,Ask,5,1.46500,1.47500,",MN);
err=GetLastError();
Comment("error number ",err);
if (Ticket>0) f_Inform(4);
//if (Ticket<0) f_Inform(25)

Code reworked.Everything works correctly.I think the error is not in the code. DC-Broco/.

 

Sorri, that was hasty. The values 1.46500 and 1.47500 in the OrderSend function should be changed to SL and TP respectively

 
VNG писал(а) >>

Sorri, that was hasty. The values 1.46500 and 1.47500 in the OrderSend function must be replaced with SL and TP, respectively

What do SL and TP equal? If it is zero, as in the code above, everything is correct. An error should be generated

 

Stops are taken from the global variable g_Level_new, which is calculated as g_Level_new=MarketInfo(Symbol(),MODE_STOPLEVEL )

Reason: