int i=Bars-counted_bars-1; while(i>=0) { double LowAddition= 30*Point; double HiAddition = iHigh(Symbol(),TimeFrame1,i)+ (30*Point); //======================================================================== //time frame eval TimeFrameRef=iTime(Symbol(),TimeFrame1,i); BarShift=iBarShift(Symbol(),TimeFrame2,TimeFrameRef);The i and while(i) are the chart's bar index. HiAddition is bogus if TimeFrame1 != Period(). TimeFrameRef is bogus if TimeFrame1 != Period(), and BarShift will be.
int i=Bars-counted_bars-1; while(i>=0) { int iTF1 = iBarShift(Symbol(),TimeFrame1,Time[i]), iTF2 = iBarShift(Symbol(),TimeFrame2,Time[i]); double LowAddition= 30*Point; double HiAddition = iHigh(Symbol(),TimeFrame1,iTF1)+ (30*Point); //======================================================================== //time frame eval //TimeFrameRef=iTime(Symbol(),TimeFrame1,i); //Use iTF2 BarShift=iBarShift(Symbol(),TimeFrame2,TimeFrameRef);
WHRoeder:
The i and while(i) are the chart's bar index. HiAddition is bogus if TimeFrame1 != Period(). TimeFrameRef is bogus if TimeFrame1 != Period(), and BarShift will be.
What you write makes sense. Thank you. My other problems I believe are centered around my lack of understanding of IndicatorCounted, counted_bars etc. I will research further to see what I can find.
BTW .. I have searced for an understandable explanation for (SetIndexStyle(0,DRAW_ARROW,EMPTY);) What does EMPTY do? If I remove it, I get the same results.
Again thank you for the time you have spent .... it has been very helpful..
What you write makes sense. Thank you. My other problems I believe are centered around my lack of understanding of IndicatorCounted, counted_bars etc. I will research further to see what I can find.
BTW .. I have searced for an understandable explanation for (SetIndexStyle(0,DRAW_ARROW,EMPTY);) What does EMPTY do? If I remove it, I get the same results.
Again thank you for the time you have spent .... it has been very helpful..
EMPTY value means that the style will not be changed.
I don't know how I missed that. I am very sorry to have bothered you. Thank you very much.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This code should only place arrows when an ma cross has occurred. I am testing as I build the code. the statement >>> if (FastMAValueTF1 > SlowMAValueTF1 && PrevFastMAValueTF1 < PrevSlowMAValueTF1) should indicate if a cross has occurred... It doesn't seem to work that way... advice?? //+------------------------------------------------------------------+ //| MTFMACross_v1.mq4 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 2 //Buy signal #property indicator_color1 White #property indicator_width1 1 #property indicator_style1 STYLE_SOLID //Sell signal #property indicator_color2 Yellow #property indicator_width2 1 #property indicator_style2 STYLE_SOLID //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ extern int TimeFrame1 = 5; extern int TimeFrame2=15; extern int FastMA = 5; extern int SlowMA = 20; double FastMAValueTF1=0; double SlowMAValueTF1=0; double PrevFastMAValueTF1=0; double PrevSlowMAValueTF1=0; double StochValueTF1=0; double PrevStochValueTF1=0; double FastMAValueTF2=0; double SlowMAValueTF2=0; double PrevFastMAValueTF2=0; double PrevSlowMAValueTF2=0; double StochValueTF2=0; double PrevStochValueTF2=0; double UpArrow[]; double DownArrow[]; datetime TimeFrameRef; int BarShift=0; int init() { //---- 2 allocated indicator buffers SetIndexBuffer(0,UpArrow); SetIndexBuffer(1,DownArrow); //---- drawing parameters setting SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,217); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,218); //---- 0 value will not be displayed SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); //---- displaying in DataWindow SetIndexLabel(0,"UpArrow"); SetIndexLabel(1,"DownArrow"); //---- initialization done Print (Symbol()); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if(Bars<=100) {return(0);} int i=Bars-counted_bars-1; while(i>=0) { double LowAddition= 30*Point; double HiAddition = iHigh(Symbol(),TimeFrame1,i)+ (30*Point); //======================================================================== //time frame eval TimeFrameRef=iTime(Symbol(),TimeFrame1,i); BarShift=iBarShift(Symbol(),TimeFrame2,TimeFrameRef); //========================================================================== //MA points FastMAValueTF1=iMA(Symbol(),0,FastMA,TimeFrame1,MODE_EMA,PRICE_CLOSE,i); SlowMAValueTF1=iMA(Symbol(),0,SlowMA,TimeFrame1,MODE_EMA,PRICE_CLOSE,i); PrevFastMAValueTF1=iMA(Symbol(),TimeFrame1,FastMA,0,MODE_EMA,PRICE_CLOSE,i+1); PrevSlowMAValueTF1=iMA(Symbol(),TimeFrame1,SlowMA,0,MODE_EMA,PRICE_CLOSE,i+1); //Stoch Points one tf StochValueTF1=iStochastic(Symbol(),TimeFrame1,5,3,2,MODE_SMA,0,0,i); PrevStochValueTF1=iStochastic(Symbol(),TimeFrame1,5,3,2,MODE_SMA,0,0,i+1); //========================================================================= //stoc points one tf StochValueTF2=iStochastic(Symbol(),TimeFrame2,5,3,2,MODE_SMA,0,0,BarShift); PrevStochValueTF2=iStochastic(Symbol(),TimeFrame2,5,3,2,MODE_SMA,0,0,BarShift+1); //=========================================================================== if (FastMAValueTF1 > SlowMAValueTF1 && PrevFastMAValueTF1 < PrevSlowMAValueTF1) { //moving up UpArrow[i]=iLow(Symbol(),TimeFrame1,i)-LowAddition ; } if (FastMAValueTF1 < SlowMAValueTF1 && PrevFastMAValueTF1 > PrevSlowMAValueTF1) { DownArrow[i]=iHigh(Symbol(),TimeFrame1,i)+LowAddition; } i--; } //---- //---- return(0); } //+------------------------------------------------------------------+