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

 

Please help solve the problem.

int n1=.....;

int n2=.....;

M1[i]=iMA(NULL,0,n1,n2,MODE_SMA,PRICE_CLOSE,i);

I display the values of n1 and n2 in the comment, the values are correct, but the mouse is not drawn correctly, not on the entire chart. But if I type in the values of n1 and n2 by hand instead of these variables, everything is drawn as it should be. I do not understand how it is possible when the values of the variables are correct? How can I make the chart be drawn with an offset to the right? Now it is drawn only up to the zero bar, i.e. the current one.

 
Alexandr24:

Please help solve the problem.

int n1=.....;

int n2=.....;

M1[i]=iMA(NULL,0,n1,n2,MODE_SMA,PRICE_CLOSE,i);

I display the values of n1 and n2 in the comment, the values are correct, but the mouse is not drawn correctly, not on the entire chart. But if I type in the values of n1 and n2 by hand instead of these variables, everything is drawn as it should be. I do not understand how it is possible when the values of the variables are correct? How can I make the chart be drawn with an offset to the right? Now it is drawn only up to the zero bar, i.e. the current one.

If n1 is not equal to the value of the TF, then I understand why it is not drawn correctly. But a shift to the right will make n2 plus! Checked!
 
borilunad:
If n1 is not equal to TF value, then I understand why it is not drawn correctly. And shift to the right will make n2 with minus.

I don't understand what TF has to do with it, n1 is the averaging period for calculating the indicator. I have a good idea what to do with it, I'm not sure what to do with it, but I'm not sure what to do with it.

UPD. i put 0 instead of n2 and shift is rendered ok, but n1 is a bit weird :(

 
double  iMA(
   string       symbol,           // имя символа
   int          timeframe,        // таймфрейм
   int          ma_period,        // период - n1    
   int          ma_shift,         // сдвиг средней - n2
   int          ma_method,        // метод усреднения
   int          applied_price,    // тип цены
   int          shift             // сдвиг
   );

That's right! I'm the one who got it wrong, but why wouldn't it work if you're doing it right?!

 
borilunad:

That's right! I'm the one who's wrong, but why can't it work if you're doing it right?!

Yes, I'm also puzzled by this paradox. If I restart the terminal, the wagon is rendered as it should be, but restarting every time is inconvenient.

UPD I solved the problem by pressing right button and selecting "Refresh" from menu, but if I press compile in the code, the drawing is messed up... But that's a trifle, I'll just refresh :))

 
Alexandr24:

I'm also puzzled by this paradox. If I restart the terminal, then the wagon is drawn as it should be, but it's inconvenient to restart every time.

UPD The problem was solved by right-clicking and selecting "Refresh" in the menu, but if I press compile in the code, the wagon is drawn incorrectly... but that's a trifle, I'll just refresh :))

Show me the code, not just bits and pieces
 

Sorted it out myself, thanks for your input :)

 
Greetings, ALL!
I searched on the forum and on the Internet - couldn't find it. That's why I have a question for you:

1. An EA opens (based on crossover with MA) multiple (3) market orders at the same price (e.g. BUY at 1.1180).

Before the MA was crossed, the orders were Buy Stop orders.

2. Then the Expert Advisor should set those three Takeprofit orders to different levels (they are determined only when they intersect the MA, according to the standard Fibo indicator)

Let us assume these levels are as follows:
Ur1 = 1.1200
Ur2 = 1.1220
Ur3 = 1.1240

And now a question:
How to set these defined levels for the open orders?

I've found such a construction on the forum (see below), but I can't think of anything further. If i'm not sure what i'm looking for, i'd rather have some tips on how to do this.
I need another counter? But how? Or will I have to use arrays, majicies, or... ????

double Ur1 = 1.1200
double Ur2 = 1.1220  
double Ur3 = 1.1240
for(int i=OrdersTotal()-1;i>=0;i--) 
{
   if(OrderSelect(i, SELECT_BY_TICKET, MODE_TRADES)==false) continue;
   if(OrderSymbol()!=Symbol()) continue;
      if(OrderType()!=0) continue;
                   
   // вот тут мы можем работать с нашим ордером
   
   if (OrderTicket() = ???? );
 
 bool mod_Buy1 = OrderModify ( OrderTicket(???),OrderOpenPrice (), NULL,Ur1,0,clrNONE);
 bool mod_Buy2 = OrderModify ( OrderTicket(???),OrderOpenPrice (), NULL,Ur2,0,clrNONE);
 bool mod_Buy3 = OrderModify (OrderTicket(???),OrderOpenPrice (), NULL,Ur3,0,clrNONE);


}  

 
vadimvborisov:
How do you place the open Three Orders at these given levels???

1. What prevents you from setting the appropriate TPs for the orders as they are opened?
2. What is this mod_Buy1/2/3 ? - Do you understand the purpose of the above for-cycle?
 

yesatztek, I apologise for the inaccuracy in the description:

1. Because before the intersection with the MA, these were buy-stop orders and Ur1 Ur2 Ur3 are identified only after the price crosses the MA.

2. and respectively the above mentioned for-cycle searches among all buy orders (since there are 3 more sell-stop orders and they crawl on a different MA at each candlestick)