[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 452

 
Vinin:

But the indicator header also needs to be edited. All buffers should be able to store the value

And it would be nice to calculate the history, but it is of course a matter of taste. And to work with objects more correctly. On each tick objects with the same names are created (or create an error).

I fixed the header.

with a buffer:

     UP_1Buffer[0] = uitog1v;
     UP_2Buffer[0] = uitog2v;
     UP_3Buffer[0] = uitog3v;
     DOWN_1Buffer[0] = ditog1v;
     DOWN_2Buffer[0] = ditog2v;
     DOWN_3Buffer[0] = ditog3v;

Got it.

Thank you very much for the help.


As for your suggestions, I'd like to make them, but I can't do them myself, unfortunately.

 
artmedia70:

Try to put into words what you have written here:

Personally, at the very first glance I found your conundrum: If one is not equal to one, then close the order...

I did not look at the rest after that...

SZY and don't try, don't even think, that it is possible to write a good EA in one cycle...

Here is the idea:

Market entry point : at any time, if there are no pending, much less open positions.

The robot opens 2 pending positions, with equal distance in pips from the current price (this is a custom variable PriceDistance).

The pending orders both with the same TP, SL, TS (as in the mirror image of the current price.

And both for the same time (in perspective the "TimeStop" variable).

All....

In practice: previous positions are closed (either both with expiration time, or on the SL or TP - it does not matter), the terminal is released, immediately after that the same positions are opened with the same parameters, but, starting from the current price, in a new range. Further on, according to the cycle.

The idea is primitive, 100% pluator, but I plan to move in this direction and connect it to other signals, for example Volumes at certain values at certain timeframes....

That's why I need the software in a hurry....

So I set myself the task of writing it...

 
Good evening! Wrote the simplest construct here, to calculate the available profit, on each tick. Well, it doesn't work! I looked at it for 10 minutes, ate the code with my eyes. I don't see any error. Here's the code.
//----
        double Profit;
for ( i=OrdersTotal();i>0;i--){ OrderSelect(i-1,SELECT_BY_POS );

if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()&&OrderType( ) ==OP_SELL ||
      
 OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol()&&OrderType( ) ==OP_BUY){
 
  
 Profit=Profit+OrderProfit( ) ;Alert ("i ", i ," Profit ", Profit);}}
 
 
//----
The magic number's right. I checked it four times. The brackets, everything I could think of to look at, everything seems to be right. Maybe I am writing/comparing wrong order? I looked at the reference. Help me please! I cannot do it without you! Can you tell me what could be wrong?
 
And you know, separately all three conditions work!!!
 double Profit;
for ( i=OrdersTotal();i>0;i--){ OrderSelect(i-1,SELECT_BY_POS );

if( OrderType( ) ==OP_SELL ){Alert ("i ", i ," OP_SELL ", Profit);}

if( OrderSymbol()==Symbol()){Alert ("i ", i ," Symbol() ", Profit ,Symbol(), OrderSymbol());}

if( OrderMagicNumber( )==2000  ) {Alert ("i ", i ," OrderMagicNumber( ) ", Profit , OrderMagicNumber( ));}



if( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()&&OrderType( ) ==OP_SELL ||
      
 OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol()&&OrderType( ) ==OP_BUY){
 
  
 Profit=Profit+OrderProfit( ) ;Alert ("i ", i ," Profit ", Profit);}}
I'm shocked and confused!!!
 
dkfl.zrjdktdbx:
Good evening! I have written a simple construction for calculating available profit on each tick. Well, it doesn't work! I looked at it with my eyes for 10 minutes. I don't see the error. Magik's code is right. I checked it four times. The brackets, everything I could think of, everything seems to be right. Maybe I am writing/comparing wrong order? I looked at the reference. Help me please! I cannot do it without you! Can you tell me what could be wrong?


A few brackets are missing.

double Profit=0;
for ( i=OrdersTotal();i>0;i--){ OrderSelect(i-1,SELECT_BY_POS );

if( ( OrderMagicNumber( )==2000 &&OrderSymbol()==Symbol()&&OrderType( ) ==OP_SELL ) ||
      
( OrderMagicNumber( )==1000 &&OrderSymbol()==Symbol()&&OrderType( ) ==OP_BUY ) ){
 
  
 Profit=Profit+OrderProfit( ) ;Alert ("i ", i ," Profit ", Profit);}}
 

This seems to be the case. Although it's better to keep it simple.

double Profit=0;
for ( i=OrdersTotal();i>0;i--){ 
   OrderSelect(i-1,SELECT_BY_POS );
   if(OrderSymbol()==Symbol()) {
      if( OrderMagicNumber( )==2000 && OrderType( ) ==OP_SELL )  Profit+=OrderProfit( );
      if( OrderMagicNumber( )==1000 && OrderType( ) ==OP_BUY  )  Profit+=OrderProfit( );
   }
   Alert ("i ", i ," Profit ", Profit);
}
 

I have this question - in MT4: ( 2/3*9 == 2*9/3) ?

         Comment(
            "\n",
            "\n", "2/3*9        = ", 2/3*9,
            "\n", "2*9/3        = ", 2*9/3,
            "\n",
         "\n" );


Thank you!

 
chief2000:

I have this question - in MT4: ( 2/3*9 == 2*9/3) ?


Thanks!


What's the point?

Check with a calculator - you will find out.

See the documentation - how expressions are calculated.

You should at least read a textbook...

"It is easy to see that the order of calculating expressions in a program is similar to the order of similar calculations in mathematics, but differs in calculating types of values of intermediate expressions, which significantly affects the final result of the calculations. In particular (in contrast to rules accepted in mathematics), the order of operands in an expression is of no small importance. To show this, let's take a little example. Problem 6: Calculate the values of expressions A/B*C and A*C/B for integers A, B and C.


Intuitively, it is expected that the result of calculations in both cases will be the same. However, this is only true for real numbers. When calculating the values of expressions composed of integer operands, the intermediate result is very important. In such a case, the sequence of operands is of fundamental importance:

int A = 3; // Значение целого типа
int B = 5; // Значение целого типа
int C = 6; // Значение целого типа
int Res_1 = A/B*C; // Результат 0 (ноль)
int Res_2 = A*C/B; // Результат 3 (три)

Let us trace the process of calculating the expression A/B*C:

1. First (from left to right) the value of expression A/B will be calculated. According to the above rules the value of expression (3/5) will be integer value 0 (zero).

2. Calculate the expression 0*C (zero multiplied by C). The result is integer value 0 (zero).

3. The overall result (value of Res_1 variable) is an integer value of 0 (zero).

Now let's see how events develop when calculating the expression A*C/B.

1. Calculating A*C. The value of this expression is integer 18 (3*6=18).

2. Calculation of the expression 18/B. The answer is obvious: (18/5) after discarding the fractional part, the result will be an integer 3 (three).

The total result (value of Res_2) is integer 3 (three).

This example shows a small fragment of program that calculates the values of variables of integer type. If we replace these variables with constants, but use the same values, the final result will be the same. When calculating expressions, in which integers are used, you should be very careful with the contents of program lines. Otherwise, an error may occur in the program, which is very hard to detect later (especially in large programs). This problem does not occur in case of calculations, in which only real numbers are involved. However, if you use operands of different types in a complex expression, the final result may depend entirely on a randomly generated fragment containing division of integers.

The concept and general properties of operators are discussed in the section Operators, and the chapter Operators reveals the eigenproperties of each operator."

 
Is FileFlush the same as saving a file?
 
Roman.:


What's the problem?

Check with a calculator - you'll find out.

I checked - both Casio and even the Microsoft calculator say that 2/3*9=6.


 
chief2000:

Checked - both Casio and even the Microsoft calculator say 2/3*9=6.



Well. What's the problem?