I wrote an indicator and the problem is that I can't draw moving average (Buf_2), here is the code:
Help me to understand what's the problem?
And why would it be drawn if you don't enter the loop after //average and i<0 otherwise you won't come out of the previous loop
i++;// поставьте здесь увеличение на один и всё заработает или присвойте i=0; напрямую ноль//====================================================================// averageint n=0;while( i>=0){//----while( n<= average){
Buf_2[ i]= Buf_1[ i- n];
n++;}
i--;//----}//----return(0);}//+------------------------------------------------------------------+
Sorry for the intrusion, I have already asked this question, but do not get the answer( Anyway, during the week, nothing has moved on
Can you tell me how to write a function placing a pending order?
What should I put instead of Bid or Ask? I need a pending order at High of one of the candlesticks. I get this value and how should I enter it into the function? This price may not be in the trade flow. I wonder if you could put out the code for putting a pending order and, more importantly, where to get its setting price from!
I am writing an indicator, the essence of which is as follows: if a candle is bullish, the indicator line is up, bearish down. well, volume is added to all this (so that each candle has a volume weight). And the second line is a moving average of the current line
#property indicator_separate_window#property indicator_buffers 2#property indicator_color1 Lime#property indicator_color2 Redexternint average=14;//---- buffersdouble Buf_1[], Buf_2[];double sum_b;//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init(){//---- indicatorsSetIndexStyle(0,DRAW_LINE);SetIndexBuffer(0, Buf_1);SetIndexStyle(1,DRAW_LINE);SetIndexBuffer(1, Buf_2);
sum_b=0.0;//----return(0);}//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit(){//----//----return(0);}//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int start(){int i,
Counted_bars=IndicatorCounted();int n=0;//----//====================================================================// график тела с объемом
i=Bars- Counted_bars-1;// Индекс первого непосчитанногоwhile( i>=0){//----if(Close[ i]>Open[ i]){
sum_b = sum_b +(Close[ i]-Open[ i])*Volume[ i];
Buf_1[ i]= sum_b;}if(Close[ i]<Open[ i]){
sum_b = sum_b -(Open[ i]-Close[ i])*Volume[ i];
Buf_1[ i]= sum_b;}if(NormalizeDouble(Close[ i],Digits)==NormalizeDouble(Open[ i],Digits)){
Buf_1[ i]= Buf_1[ i-1];}// average while( n<= average){
Buf_2[ i]= Buf_1[ i- n];
n++;}
i--;//----}//====================================================================//----return(0);}//+------------------------------------------------------------------+
problems: the main line draws peaks when a doji is formed, and the moving average is not drawn?
I am writing an indicator, the essence of which is as follows: if a candle is bullish, the indicator line is up, bearish down. well, volume is added to all this (so that each candle has a volume weight). And the second line is the moving average of the current line
problems: the main line draws peaks during doji formation and the moving average is not drawn?
The block of ifs can be replaced with a more efficient
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Dear forum users!
I wrote an indicator and the problem is that I can't draw moving average (Buf_2), here is the code:
Help me to understand what's the problem?And why would it be drawn if you don't enter the loop after //average and i<0 otherwise you won't come out of the previous loop
Good afternoon)
Sorry for the intrusion, I have already asked this question, but do not get the answer( Anyway, during the week, nothing has moved on
Can you tell me how to write a function placing a pending order?
What should I put instead of Bid or Ask? I need a pending order at High of one of the candlesticks. I get this value and how should I enter it into the function? This price may not be in the trade flow. I wonder if you could put out the code for putting a pending order and, more importantly, where to get its setting price from!
For example (example of setting a buy stop) :
(it is not at all necessary for the set price to be in the quote stream in order to set a pending order.
you may dance with the current price or take any price, as long as you adhere to the stop level from CURRENT PRICE TO THE STOP PRICE)
( 'EURUSD - Trends, Forecasts & Consequences' )
Instead of
double priceBUY=..... ....
enter your formula
I am writing an indicator, the essence of which is as follows: if a candle is bullish, the indicator line is up, bearish down. well, volume is added to all this (so that each candle has a volume weight). And the second line is a moving average of the current line
problems: the main line draws peaks when a doji is formed, and the moving average is not drawn?I am writing an indicator, the essence of which is as follows: if a candle is bullish, the indicator line is up, bearish down. well, volume is added to all this (so that each candle has a volume weight). And the second line is the moving average of the current line
problems: the main line draws peaks during doji formation and the moving average is not drawn?The block of ifs can be replaced with a more efficient
[i + 1] - since the index arrays are numbered from right to left. Now the candlesticks with zero bodies will be processed correctly.
With the middle line buf_2 from the code it is not clearat all what the author wanted.
The if-value block can be replaced with a more efficient one
[i + 1] - because index arrays are numbered from right to left. Now the candlesticks with zero body will be processed correctly.
With the middle line buf_2 from the code it is not clearat all what the author wanted.
wanted it to be a moving average with a period of 14, based on the value of the indicator
wanted it to be a moving average with a period of 14, plotted against the value of the indicator
Then it goes like this:
Just look at this thread.
Or read task 27 in Kovalev's textbook. There are code examples and a detailed explanation of how it works.