You seem to be calculating values for ma5, ma10, ma30 and your iADX stuff always using bar 0 . . . even when processing the historical bars . . . it might work for the current bar but not for any bars to the left.
Hi,
Yes I'm calculating whether ma 5, > ma 10 > ma30. if true, gives a 1, else return 0. I wanted the indicator to show me a one or zero . but it seems to be stucked at one.
Same case as with the iADX..shouldn't the chart be updated with every tick?
Hi,
Yes I'm calculating whether ma 5, > ma 10 > ma30. if true, gives a 1, else return 0. I wanted the indicator to show me a one or zero . but it seems to be stucked at one.
Same case as with the iADX..shouldn't the chart be updated with every tick?
not exactly i've modified the code and what you're showing is extmapbuffer3 right?
I wrote that to test my code.. What i really want is for it to show the state of my mafilter and trend-strength
It should show either 1 or 0.. attached is modified code
//+------------------------------------------------------------------+ //| trendrojak indicator.mq4 | //| Copyright © 2011, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 Red //--- buffers int ExtMapBuffer1[]; int ExtMapBuffer2[]; double ExtMapBuffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++){ ExtMapBuffer1[i]=mafilter (i); ExtMapBuffer2[i]=trendstrength (i); //ExtMapBuffer3[i]=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,i); Print ("mafilter state is ",mafilter (i)); } //---- //---- return(0); } int mafilter (int shiftma) { double ma5,ma10,ma30; ma5= iMA (NULL,0,5,0,MODE_EMA,PRICE_MEDIAN,shiftma); ma10= iMA (NULL,0,10,0,MODE_EMA,PRICE_MEDIAN,shiftma); ma30= iMA (NULL,0,30,0,MODE_EMA,PRICE_MEDIAN,shiftma); //Print ("ma5 is " ,ma5); if (ma5 >ma30 && ma10>ma30) { return(1); //trend intact } //end if else { return (0);//trend change } //end else } //end mafilter int trendstrength(int shift) { // iADX( string symbol, int timeframe, int period, int applied_price, int mode, int shift) if (iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,shift) > 25){ if (iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,shift) >iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,shift-1)) { return (1); //trend picking up strength }//end if }//endif else { return (0); }//end else }//end trendstrength //+------------------------------------------------------------------+
not exactly i've modified the code and what you're showing is extmapbuffer3 right?
I wrote that to test my code.. What i really want is for it to show the state of my mafilter and trend-strength
Oh yes raptor!
Looks actually like what I'm trying to achieve. DOn't mind sharing with me how you did it?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I've written an indicator to test out the trigger for my EA . But something is wrong with it as it seems that my indicator buffer are only stuck at 1 level.
Hope some kind souls could help to point out the problem in this Indicator.