[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 846

 
serjik77:

Please excuse me if I'm distracting you with a probably stupid question.

I've just started to learn this and have no one to ask for advice.

I have read the manual a few times. I have started an Expert Advisor with the simplest functions, pending orders.

I still do not understand what I have to do to open orders once, and not with every tick.



Insert a function like this

int ChPos( int type_H_L) 
{
// возвращает кол-во позици которые открыты 
   int i;
   int col;
   int count=0 ;
   for( i=0; i < OrdersTotal(); i++)         
   {
      if(OrderSelect(i,SELECT_BY_POS)==true) 
       {                                   
           if(OrderType()==OP_BUY && type_H_L==OP_BUY && OrderMagicNumber()== magic){count++;}
           if(OrderType()==OP_SELL && type_H_L==OP_SELL && OrderMagicNumber()== magic){count++;}
           if(OrderType()==OP_BUYSTOP && type_H_L==OP_BUYSTOP && OrderMagicNumber()== magic){count++;}
           if(OrderType()==OP_SELLSTOP && type_H_L==OP_SELLSTOP && OrderMagicNumber()== magic){count++;}
           
       }
    }   
return(count);
}

In your code, check this way, for example

if ( SignalLine > MainLine && ChPos(OP_BUY)==0 )
      { // если сигнальная линия выше основной и нет длинной позы . то закрыть короткую открыть длинную
         if (ChPos(OP_SELL)>0 ) ClosePosition(OP_SELL) ;
         OpenPosition(OP_BUY)  ;
 
I close unprofitable positions without breaking the equilibrium in the lot by removing TP. Alas, TP=0, although I got a very annoying message in the log:
<br / translate="no"> 2010.09.12 21:34:53 2000.03.06 07:59 money EURUSD,M5: OrderModify error 1

code:

bool notakeprofit()
{   bool ok=true;
    int k=OrdersTotal();
    for (int i=k-1; i >=0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_368)
        {OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(),NormalizeDouble(0,Point), OrderExpiration(), CLR_NONE);
         }
    else;
       // { Print("OrderSelect() error - ",GetLastError()); ok=false;}
    }
return(ok);
}

Due to the need to make sure in the main code that all market orders have TP=0 I control the result of this function - ok, in the code you can see that ok - it only changes when there is an error

HELP MI PLZ! :)

thanks in advance

 
abolk:

In my case, the rule is: "Separate NOT in nouns, adjectives and adverbs, if there is or is meant to be a contradiction" http://www.rusyaz.ru/pr/od07.html - "to do" is NOT - the correct word is " to do" (the highlighted word is a contradiction and is preceded by a hyphen).

you are interpreting the Russian language wrong (!). Separate "not" would be written in the case of:

"to do" is NOT correct, but bad. - it is in this sense that it is understood to be opposed. Look at the examples to the rule.

In your sentence, NOT should be written with a conjunction (paragraph 3 of paragraph 88 on the same page applies):

"to do" is misspelled, " to do" is correct .

 

There is a standard MACD indicator. how is it used to test on history?

is there an example?

 
IgorM:
I lock losing positions so I don't want to break an equilibrium in the position but I have to remove TP, but alas, TP=0, although in my journal it keeps on coming up many times:

code:

Due to the need to make sure in the main code that all market orders have TP=0 I control the result of this function - ok, in the code you can see that ok - only changes when there is an error

HELP MI PLZ! :)

thanks in advance

Maybe not NormalizeDouble(0,Point) but NormalizeDouble(0,Digits)?

 
chief2000:

Maybe not NormalizeDouble(0,Point) but NormalizeDouble(0,Digits)?


Thanks, I found it myself, but it didn't fix error #1

 
IgorM:


Thanks, I found it myself, but it didn't fix error #1.

The first thing I would do is substitute some other number in TP instead of zero (to eliminate the error) to make sure that' s the reason.

 
chief2000:

The first thing I would do is substitute some other number in TP instead of zero (to eliminate the error) to make sure that' s the reason.


it used to work OK until I wrote this function, now I call Kim's function instead of OrderModify():

void ModifyOrder(double pp=-1, double sl=0, double tp=0, datetime ex=0)

the error is gone

 

there is an osma type indicator, the signal is reversed when crossing 0. how do i test it on history?

 
ivandurak:


Insert this function

And in your code, do a check like this

Excuse me, but if I may, one more question?

I am beginning to understand something, but not everything.

Does the first function tell the application how many open orders it has?

Please advise how to make only two pending ones appear permanently,

independently of the triggered ones.

Reason: