[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 70

 

Help in solving the problem. I may have already annoyed everyone here, but please help. If the flag on the previous bar is 1 it is allowed to draw the arrow down. After it is drawn, we set a new flag equal to -1. In the other side on the contrary. But what I do wrong. No arrows without comments. All arrows with comments.

flag[i] = flag[i+1];             
  if (// flag[i] == 1 && 
//в вниз           
       ma13_0 > ma55_0 && macd[0] >= macd[1] && macd[1] >= macd[2] && macd[2] >= macd[3] && cci15_0 > 50 && cci170_0 > 0)
  {
       S[i] = High[i]+point*Point;                
       flag[i] = -1 ; // флаг показывает нормально пока закоментировано        
  }        
  if (// flag[i] == -1 && 
//в верх          
       ma13_0 < ma55_0 && macd[0] <= macd[1] && macd[1] <= macd[2] && macd[2] <= macd[3] && cci15_0 < 50 && cci170_0 < 0)
  {
       B[i] = Low[i]-point*Point;                
       flag[i] = 1 ;//флаг показывает нормально пока закоментировано         
   }
 
granit77:
I don't know. Sergeev knows, he said it seems to be right. I would also like to see how to write it correctly.
I just corrected it a little, so that it would show something.
- I put the indicator in a separate window, then you can put it back

- macd[] array was hanging in the air, made it an indicator, increased accuracy
- locked your complex condition for the opening, put a simple one for adjustment
- changed the condition for the flag, at least it works.

Then you can gradually introduce conditions, you will immediately see where the bug is.

Thank you. I'll have a look. While I was writing the previous post you posted yours.
 
100yan:

HELP! Please tell me, if I close part of a position (eg order for 1 lot, and close 0.5 lot) OrderClose ticket should change? My tester says it does... How to avoid it? Below is a piece of closing code...

There is no way to avoid it. It's the DC changing the ticket. You are essentially reopening with another volume, hence the new ticket. Therefore, keep your own orders record and after partial closing of a position, remember about its new ticket for further work. You can also provide some kind of identification of partially closed positions for correct further monitoring by the Expert Advisor.
 
artmedia70:
There is no way to avoid it. This is the DC changing the ticket. You are essentially reopening a position with a different volume, hence the new ticket. Therefore, keep your own orders record and after partial closing of a position, memorize its new ticket for further work. You can also provide some kind of identification of partially closed positions for correct further monitoring by the Expert Advisor.

Thank you! Does the MagicNumber change?
 
gince:
Made a temporary drawing of flag[] buffer - it's empty, why? Where is my mistake?

your error is that flag[i+1] is not initialized.

so the comparison flag[i]==1 and flag[i]==-1 will never execute!

 
100yan:

Thank you! Does the MagicNumber change?
no
 
100yan:

Thank you! Does the MagicNumber change?
The MagicNumber does not change in this case, unless the EA code provides for it.
 
DhP:
The MagicNumber does not change in this case, unless this is provided for in the EA code.
is it possible to do this ???? please show me how it can be done
 
sergeev:
yes??? and this can be envisaged ???? please show how it can be done
When a position is partially closed, you can change the magik. I am sure you can write this easily.
 
sergeev:

your error is that flag[i+1] is not initialized.

so the comparison flag[i]==1 and flag[i]==-1 will never execute!

My understanding is that I don't have initialized flag[i+1] setting. If so, where and how to do it ?

If I set 1, then when I start the indicator, it (the indicator) will wait for the change.

flag[i+1]= 1;//начальная установка

for(int i=limit-1;i>=0;i--){ 
   flag[i] == flag[i+1];   
   if ( flag[i] == 1  &&   
        условие продажи){              
       Продажа[i] = High[i]+point*Point; 
       flag[i] == -1 ;
    }                     
    if (flag[i] == - 1  &&     условие покупки){          
              Покупка[i] = Low[i]-point*Point; 
              flag[i] == 1 ;}
    }
}    
Reason: