Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 414

 
bergkamp.:

after exiting the start it will continue trading after the signal changes ?

and how is the action different ? this and that


In the second case the start() function returns zero, in the first one nothing is returned.
 
khorosh:

In the second case, the start() function returns zero; in the first case, it returns nothing.

oops, oops. A big misconception, which leads to finding errors where none exist.

The function returns some undefined number, it may well return 0, though not for sure.

So do not confuse the man. Otherwise, he will get into trouble and will not be glad.

 
bergkamp.:

after exiting the start it will continue trading after the signal changes ?

and how is the action different ? this and that

Not different for a system call (by tick). It is important to call start() on its own. And that's if the return value is important.
 
sergeev:

oops, oops. A big misconception, which leads to finding errors where none exist.

The function returns some undefined number, it may well return 0, though not for sure.

So don't confuse the man. Otherwise he'll get hurt and won't be happy.

Probably never used value of function "start". I thought so because usually what is in brackets at return() is the return value for the function, and if there is no value, then nothing. But "start" is not an ordinary function, but a special one, maybe that's why there may be some deviations.
 
khorosh:
return() in brackets is the return value for the function and nothing if there is no value.

No and no!

don't teach newbies nonsense.


int F1() { return; }

int F2() { }

int a=F1(), b=F2();

Print(a);

Print(b);


-----

Thank God for adding strict mode

 
  1. Hello, advise how to implement a condition in the correlation indicator that displays in the main window 2 currency pairs in the lines from a certain date in time, so that the second correlated pair will continue to be displayed on the chart in real time, and not only until the indicator is attached to the chart, for example, in the main window of the euro to continue to display the pounddollar. The standard construction of the indicator (by bar) is not suitable because of the constant re-rating.
  2. #property indicator_chart_window
    #property indicator_buffers 2


    extern datetime startDate = 1389107200;
    extern int period = 1;
    extern int priceType = MODE_CLOSE;
    extern int shift = 0;
    extern int mode = MODE_EMA;
    extern string addSymbol = "GBPUSD";
    extern color curSymbolColor = Red;
    extern color addSymbolColor = Aqua;

    int drawBars = 0;
    int addBars = 100;
    double a[], b[], c[];

    // ----
    int init(){
    IndicatorBuffers(3);
    SetIndexBuffer(0,a);
    SetIndexBuffer(1,b);
    SetIndexBuffer(2,c);
    SetIndexStyle(0,DRAW_LINE,EMPTY,EMPTY,curSymbolColor);
    SetIndexStyle(1,DRAW_LINE,EMPTY,EMPTY,addSymbolColor);
    drawBars = iBarShift(NULL,0,startDate);
    if (iClose(addSymbol,0,0) == 0) addSymbol = "";
    drawBars += period + addBars;
    }

    // ----
    int start(){
    int bars = 0, i = 0, si = 0, pos = 0;
    static double delta = 0;

    bars = IndicatorCounted();
    if (bars < 0) return(-1);
    i = Bars - bars - 1;

    if (i > drawBars) i = drawBars;
    si = i;

    while (i > 0){
    if (i < drawBars - period - addBars){
    a[i] = iMA(NULL,0,period,shift,mode,priceType,i);
    }
    pos = iBarShift(addSymbol,0,Time[i]);
    c[i] = price(addSymbol,0,priceType,pos);
    i--;
    }
    si -= period + addBars + 1;
    i = si;

    while(i > 0){
    b[i] = iMAOnArray(c,0,period,shift,mode,i);
    if (i == si){
    delta = b[i] - a[i];
    }
    b[i] -= delta;
    i--;
    }
    }

    //----
    double price(string symb,int tf, int type, int i){
    double p = 0;
    if (symb=="0") symb = Symbol();

    switch(type){
    case MODE_OPEN :
    p = iOpen(symb,tf,i); break;
    case MODE_LOW :
    p = iLow(symb,tf,i); break;
    case MODE_HIGH :
    p = iHigh(symb,tf,i); break;
    case MODE_CLOSE :
    p = iClose(symb,tf,i); break;
    }
    return(p);
    }
 
It is simply possible for the indicator to refresh automatically, e.g. every 2-3 minutes.
 

Please help, I don't know what topic to write in.

I have an Expert Advisor, I need to add to it the ability to multiply the next lot won by 2:

1. Risk

2. Profit

3. Stoploss

4. StartTime

5. Lot size

6. If the lot is closed positively

7. Number of subsequent multiplied lots (1, 2, 3 or 4)

7.1 Multiplied won lot (each 2, by X)

7.2 The multiplied won lot (each 3 by X)

7.3 A multiplied won lot (each 4 by X) 7.4 A multiplied won lot (each 3 by X) 7.5 A multiplied won lot (each 4 by X) 7.6.

7.4 Multiplied won lot (each 5 by X)

X - changeable value (If X=0 then the lot is not multiplied)

Example 1:

If bet 0.03 = played in +, the next bet is 0.06

If bet 0.06 = played in +, the next bet is 0.09

If bet 0.09 = did not play in the +, then the next bet is standard 0.03

Example 2:

If bet 0.03 = played in +, the next bet is 0.06

If bet 0.06 = did not play in +, the next bet is 0.03

If bet 0.03 = played in +, then the next bet standard 0.06

etc.

Here is the EA itself. I would be very grateful for your help.

Files:
 
Hello!
Is there a function in the "Kim" function that calculates the profit margin of the last open order?

I have not found it, now I am puzzling over a homemade function to calculate the profit margin of the last open order.
 
Link_x:
Hello!
Is there such a function in the "Kim" function that calculates the amount of profit from the last open order?

I haven't found it, now I'm puzzling over a homemade function that calculates the profit margin of the last open order.


OrderProfit()

If you need exactly the last order opened, then go through all orders and choose the one, which time is the latest, then use the above function, which will return to you the net profit of this order