Problem With Indicator - How Can I make it Autorefresh

 

Hi, 


I have an indicator that shows the net wick for the candle, the problem is that it does not autorefresh and to do so I need to change the timeframe


The code is the following, please let me know what to do to change it please

#property indicator_separate_window



#property indicator_buffers 4



#property indicator_color1 GreenYellow

#property indicator_color2 Black

#property indicator_color3 Silver

#property indicator_color4 Silver



//---- external variables

extern bool ShowAtr = false;

extern int AtrPeriod = 14;

extern double  kAtr = 0.62;



extern bool ShowNetWick = true;





//---- buffers



double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

double ExtMapBuffer4[];

//+------------------------------------------------------------------+



//| Custom indicator initialization function |



//+------------------------------------------------------------------+



int init()



{



//---- indicators



SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexBuffer(0,ExtMapBuffer1);



SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexBuffer(1,ExtMapBuffer2);

if (ShowAtr)

{

SetIndexStyle(2,DRAW_LINE);

SetIndexBuffer(2,ExtMapBuffer3);



SetIndexStyle(3,DRAW_LINE);

SetIndexBuffer(3,ExtMapBuffer4);

}

string short_name = "DRT VSAWick";



IndicatorShortName(short_name);



//----



return(1);



}



//+------------------------------------------------------------------+



//| Custor indicator deinitialization function |



//+------------------------------------------------------------------+



int deinit()



{



//----



//----



return(0);



}



//+------------------------------------------------------------------+



//| Custom indicator iteration function |



//+------------------------------------------------------------------+



int start()



{



int counted_bars=IndicatorCounted();



//---- check for possible errors



if (counted_bars<0) return(-1);



//---- last counted bar will be recounted



if (counted_bars>0) counted_bars--;



int pos=Bars-counted_bars;







//---- main calculation loop

double dResult1;

double dResult2;

double dResult3;

double dResult4;

while(pos>=0)



{

// if (iOpen(NULL, 0, pos) > iClose(NULL, 0, pos)){   

//    dResult1 = iHigh(NULL, 0, pos) - iOpen(NULL, 0, pos);

//   }  //downbar

// if (iOpen(NULL, 0, pos) <= iClose(NULL, 0, pos)){   

   dResult1 = iHigh(NULL, 0, pos) - iClose(NULL, 0, pos);

//    }  //upbar

// if (iOpen(NULL, 0, pos) > iClose(NULL, 0, pos)){

   dResult2 = iLow(NULL, 0, pos) - iClose(NULL, 0, pos);

//    }  //downbar

// if (iOpen(NULL, 0, pos) <= iClose(NULL, 0, pos)){

//    dResult2 = iLow(NULL, 0, pos) - iOpen(NULL, 0, pos);

//   }  //upbar

if (ShowAtr){

   dResult3 = iATR(NULL,0,AtrPeriod, pos)*kAtr ;

   dResult4 = (0 - iATR(NULL,0,AtrPeriod, pos)*kAtr );



   ExtMapBuffer3[pos]= dResult3 ;

   ExtMapBuffer4[pos]= dResult4 ;



   }



 if (ShowNetWick)

   {

      double dResultNet =  dResult1 +dResult2;

      if (dResultNet>0) {  //dResult1= dResultNet;

                           ExtMapBuffer1[pos]= dResultNet ;

                         }

      else                 ExtMapBuffer2[pos]= dResultNet ;

   }

  else

   {

   ExtMapBuffer1[pos]= dResult1 ;

   ExtMapBuffer2[pos]= dResult2 ;

   }

   



pos--;



}



//----



return(0);



}



//+------------------------------------------------------------------+
 

Hi,

As i checked it's working well and no need to be refreshed,What's your problem exactly?

 
Frag8383: the problem is that it does not autorefresh and to do so I need to change the timeframe
  1. You don't need to change TF. You need to fix your broken code.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  3.       if (dResultNet>0) {  //dResult1= dResultNet;
                               ExtMapBuffer1[pos]= dResultNet ;
                             }
          else                 ExtMapBuffer2[pos]= dResultNet ;
    Buffers 1 & 2 are histograms — draws from one price to another. You must set both buffers each time. Perhaps the other should be zero.
 
William Roeder:
  1. You don't need to change TF. You need to fix your broken code.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  3. Buffers 1 & 2 are histograms — draws from one price to another. You must set both buffers each time. Perhaps the other should be zero.

I Have edited the first post, 


I dont have programming skills I see what you mean but I do not know how to change it 

Please could you help me


Thanks

Kind regards

 
So what is your exact problem?You want to modify the formula?
 
Mehrdad Jeddi:
So what is your exact problem?You want to modify the formula?

That is whatWlliam Roeder says that I need to do for the indicator to refresh properly, if you see above he mentions what to do

 

The OP is not a programmer, he clarified he does not have skills for coding, but he also said he understood what has to be done (the concept of what needs to be done)


I understand the OP want's/[is asking] someone here to do it for him. 

 
rrocchi:

The OP is not a programmer, he clarified he does not have skills for coding, but he also said he understood what has to be done (the concept of what needs to be done)


I understand the OP want's/[is asking] someone here to do it for him. 

Thanks for the clarification

That is exactly the point

 
Noneone is able to do the small modification of the code?
 
Frag8383: Noneone is able to do the small modification of the code ?
There are lots of people here "able to do the small modification of the code." None want to be a slave for you.
  1. MT4: Learn to code it.
    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
  2. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum
We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help
          urgent help.
 
Frag8383:
Noneone is able to do the small modification of the code ?

To be honest with you, I won't even look at your code.

There are big areas of white space, why so many blank lines?

Lots of commented out lines

Make your code easier to read and somebody may help you.

Reason: