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

 
Or maybe it's better to define him by his magician? Then it's very simple...
 

Please advise,

In order to calculate the number of continuous events (e.g. the number of bars in a series in which the close is higher than the open and vice versa), I could only come up with the following:

int a=0, b=0;

if(Close[i]>Open[i])
    {
        a++;
        Buffer[i] = _____??????_________;
    }
if(Close[i]<Open[i])
    {
        b--;
        Buffer[i] = _____??????_________;
    }

Two questions (if the above makes sense): (1) how to reset the counter reading if the continuous series has stopped; and (2) how to correctly write Buffer[i] - i.e. how can I "see" the result itself?

I.e., if the indicator for a particular bar shows "-3", it means that this is the third bar in a row which closed below the opening; if the next bar after it closes above the opening, the indicator will show "1" ......

 
artmedia70:

In the global variables set the initial value of the lot:

There we assign this value to the variable, which will pass the lot value to the position opening function:

After closing the position we will check it for profitability/loss:

The function itself, thanks to Igor Kim...







One more question:

I got the following order for some reason. The next order is equal to the initial lot multiplied by 2, i.e. 1 lost (0.01) 2 lost (0.02) 3 lost (0.02) 4 won (0.02)

and I wanted 1 lost (0.01) 2 lost (0.02) 3 lost (0.04),

And one more thing:

Please advise whether you can do the following (and if you can please write how) :

1 in the code to prescribe the orders and their sizes in turn, so that if the previous order was unprofitable the next one would open, until you get a profit, and then everything from the beginning. Example:

1 Lot 0.01

2 Lot 0.01

3 Lot 0.02

....

15 Lot 1.0

Thank you in advance

Boris.

 
Can anyone tell me what my error is (question and code on page 693 )?
 
One more thing: Thank you very much, Tolik! Your code was the best fit!
 
Azerus:

Give me a hint,


What I would do is this. If I were to catch a series of the last four bars, then

if(Close[0]>Open[0]&&Close[1]>Open[1]&&Close[2]>Open[2]&&Close[3]>Open[3])
...
 
Necron:
Can someone tell me what my mistake is ( question and code on page 693 )?


Try replacing

if (OrderStopLoss()<pp-(TStop.Buy+TrailingStep-1)*po||OrderStopLoss()==0)

to

if (OrderStopLoss()>pp-(TStop.Buy+TrailingStep-1)*po||OrderStopLoss()==0)

 
cyclik33:

One more question:

I got for some reason that the subsequent order is equal to the initial lot multiplied by 2. i.e. 1 lost (0.01) 2 lost (0.02) 3 lost (0.02) 4 won (0.02)

and I wanted 1 lost (0.01) 2 lost (0.02) 3 lost (0.04),

And one more thing:

Please advise whether you can do the following (and if you can please write how) :

1 in the code to prescribe the orders and their sizes in turn, so that if the previous order was unprofitable the next one would open, until you get a profit, and then everything from the beginning. Example:

1 Lot 0.01

2 Lot 0.01

3 Lot 0.02

....

15 Lot 1.0

Thank you in advance

Boris.

Show us your code so we don't have to guess
 

Please tell me if I understand correctly that the anchor angle is the window angle and not the object angle.

And they are counted from left to right, from top to bottom. Then how do I correctly anchor the object to the lower left corner? I have it, the object, disappears from the window for some reason.

   ObjectCreate(Name_Obj_Advert, OBJ_LABEL, 0, 0,0);
   ObjectSet   (Name_Obj_Advert, OBJPROP_CORNER, 2);
   ObjectSet   (Name_Obj_Advert, OBJPROP_TIME1, Time[0]);
   ObjectSet   (Name_Obj_Advert, OBJPROP_YDISTANCE, 0);            
   ObjectSet   (Name_Obj_Advert, OBJPROP_COLOR, Color_Advert);
   ObjectSetText(Name_Obj_Advert, String_Advert, Kegl);
 
valenok2003:

Please tell me if I understand correctly that the anchor angle is the window angle and not the object angle.

And they are counted from left to right, from top to bottom. Then how do I correctly anchor the object to the lower left corner? It disappears from the window for some reason.

The anchor angle is the angle from which the position of the object in the window will be calculated. Angles are counted clockwise from left to right. The bottom left corner will be No. 3 (numbering starts from zero).