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

 
vovander:
what type of value does OrderType() return? Thank you

int OrderType( )
 

I have an external variable extern in my board. If I attach it to two different pairs and change this extern on one of them, it also changes on the other one for some reason(

How to separate them? I found a solution with string parameters - I add a symbol name at the end of the initialization. But what about the integers and dubls?

---

another question about kim's functions.

it has

//| sy - instrument name ( "" - any symbol, |
//| NULL - current symbol) |
//| op - operation ( -1 - any position) |
//| mn - MagicNumber ( -1 - any magik) |
//+----------------------------------------------------------------------------+
void SimpleTrailing(string sy="", int op=-1, int mn=-1)

i.e. if I call SimpleTrailing(), the function works for all pairs

but if I call SimpleTrailing(NULL), then it works only for the one with the owl on its chart?

is it some undocumented feature or what? i couldn't find any reference to NULL in the function.

or is SimpleTrailing(NULL) and SimpleTrailing() the same thing?

 
Omm:

Dummy question. there are extern variables in the board. if i link it to two different pairs and change this extern on one of them, it also changes on the other one for some reason(

I found a solution for string parameters - I append a symbol name to the end of the function during initialization.

---

another question about kim functions.


i.e. if i call SimpleTrailing(), then the function works for all pairs

but if I call SimpleTrailing(NULL), then it works only for the pair with the owl?

is this some undocumented feature or what? i couldn't find any reference to NULL in the function.

or are SimpleTrailing(NULL) and SimpleTrailing() the same thing?

1. You are telling the impossible! - Which means you must be telling something "wrong". I can assume that the EA does not use the identifier - OrderMagicNumber().

2. I looked at the code - something tells me that using SimpleTrailing() will be identical to SimpleTrailing(NULL). It's up to you to check it. And for the function to work with a chart tool, call it as follows: SimpleTrailing (Symbol()).

 

1. this EA http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&func=fileinfo&id=42

Magic is formally there (also in extern for some reason), but I don't understand how to make it work.

I am just trying to add Breakeven and Trawl.

2. the question is solved.

I found it in another f-fi if (sy=="0") sy=Symbol();

I guess the author forgot to add it to this one.

 

What I need is for the Breakeven function https://forum.mql4.com/ru/11287/page55#11315

work only once at a particular position of a particular symbol

What should I tweak in the conservatory?

if(ExistPositions(Symbol() )
{
for (int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if(OrderSymbol()==Symbol() )
MovingInWL(Symbol())

}

}

 

Do you guys have a function. There are several orders of different volume.

For example, order1=0.1, order2=0.2, order3=0.3, order4=0.4 - a total of 1 lot.

At one point in time I need to close part of the orders for the total amount of a certain lot.

For example, I need to close 0.5 lots. So, we need a function that would close order4=0.4 and the remainder, for example, from order3. Or order1, order2 and the remainder from order3.

 
Omm:

What I need is for the Breakeven function https://forum.mql4.com/ru/11287/page55#11315

work only once at a particular position of a particular symbol

What should I fix in the conservatory?

This function has check for single triggering - no need to invent anything:

    if (ExistPositions (Symbol(), -1, Magic))
    {MovingInWL (Symbol(), -1, Magic);}

And MovingInWL() function should be tweaked a bit:

void MovingInWL (string sy = "", int op = -1, int mn = -1)
{
    double po, pp, ld_BU;
    int    i, k = OrdersTotal();
//----
    if (sy = "0") sy = Symbol();
    for (i = k - 1; i >= 0; i--)
    {
        if (!OrderSelect (i, SELECT_BY_POS, MODE_TRADES)) continue;
        if (sy != "") if (OrderSymbol() != sy) continue;
        if (mn >= 0) if (mn != OrderMagicNumber()) continue;
        po = MarketInfo (OrderSymbol(), MODE_POINT);
        if (OrderType() == OP_BUY)
        {
            //---- Это условие выполняется однократно (пока БУ не установлен)
            if (OrderStopLoss() - OrderOpenPrice() < LevelWLoss * po)
            {
                pp = MarketInfo (OrderSymbol(), MODE_BID);
                if (pp - OrderOpenPrice() > LevelProfit * po)
                {
                    ld_BU = NormalizeDouble (OrderOpenPrice() + LevelWLoss * po, MarketInfo (OrderSymbol(), MODE_DIGITS));
                    ModifyOrder (-1, ld_BU, -1);
                    continue;
                }
            }
        }
        else if (OrderType() == OP_SELL)
        {
            //---- Это условие выполняется однократно (пока БУ не установлен)
            if (OrderStopLoss() == 0 || OrderOpenPrice() - OrderStopLoss() < LevelWLoss * po)
            {
                pp = MarketInfo (OrderSymbol(), MODE_ASK);
                if (OrderOpenPrice() - pp > LevelProfit * po)
                {
                    ld_BU = NormalizeDouble (OrderOpenPrice() - LevelWLoss * po, MarketInfo (OrderSymbol(), MODE_DIGITS));
                    ModifyOrder (-1, ld_BU, -1);
                }
            }
        }
    }
//----
}
 

Please help me to change the function, in indicator High Low of weekly candle it looks like this

if (TimeDay(Time[i])!=TimeDay(Time[i+1])
{
if(TimeDayOfWeek(Time[i])==1)

I need High Low of monthly candlestick. Thank you

 

TarasBY, it doesn't work like this.

In e-TFL_V2 I add these two lines to start() and the MovingInWL function itself.

If several positions are open, breakeven is set on only one of them. on every tick it tries to do it again.

As soon as a Breakeven position is closed, it sets it on the next one.

If I've noticed in the first message the breakeven value is the same for all symbols, even though I set different numbers in the EA settings window.

I'm not sure where the check for single triggering is?

p.s. thanks for the corrected function. i'm testing it on 5 digits, but i think most of the kim's functions work anyway.

p.s.s. I ran it for a while. It seemed to work. it was in the MovingInWL bug. thanks again. i've been struggling with it for two days now))

p.s.s. i can't understand why Magic should be moved to external EA parameters?

 
How do I create my own server for Metatrader, i.e. a server to which another person from my mt can connect?
Reason: