set cd[i] and cu[i] to EMPTY_VALUE at the start of the loop?
replace PERIOD_H1 with 0 so indicator works on the attached chart?
It is still only showing up arrows, no down arrows:
//+------------------------------------------------------------------+ //| 100_200MAs_Alert.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_chart_window double CrossUp[]; double CrossDown[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY); SetIndexArrow(0, 233); SetIndexBuffer(0, CrossUp); SetIndexStyle(1, DRAW_ARROW, EMPTY); SetIndexArrow(1, 234); SetIndexBuffer(1, CrossDown); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- double MA100 = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, 0); double MA200 = iMA(NULL, 0, 200, 0, MODE_SMA, PRICE_CLOSE, 0); if ( iClose(NULL, 0, 1) < MA100 && iClose(NULL, 0, 2) >= MA100 && GlobalVariableGet(Symbol()+"MAAlert") < iTime(NULL,0,0) ) { Alert(Symbol()+" bearish"); GlobalVariableSet(Symbol()+"MAAlert", iTime(NULL,0,0)); } if ( iClose(NULL, 0, 1) > MA100 && iClose(NULL, 0, 1) <= MA100 && GlobalVariableGet(Symbol()+"MAAlert") < iTime(NULL,0,0) ) { Alert(Symbol()+" bullish"); GlobalVariableSet(Symbol()+"MAAlert", iTime(NULL,0,0)); } int limit, i, counter; //int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i = 0; i <= limit; i++) { CrossUp[i] = EMPTY_VALUE; CrossDown[i] = EMPTY_VALUE; MA100 = iMA(NULL, 0, 100, 0, MODE_SMA, PRICE_CLOSE, i); //MA200 = iMA(NULL, PERIOD_H1, 200, 0, MODE_SMMA, PRICE_CLOSE, i+1); if (iClose(NULL, 0, i) < MA100 && iClose(NULL, 0, i+1) >= MA100) {CrossDown[i] = Close[i];} if (iClose(NULL, 0, i) > MA100 && iClose(NULL, 0, i+1) <= MA100) {CrossUp[i] = Close[i];} } return(0); } //+------------------------------------------------------------------+
SanMiguel: It is still only showing up arrows, no down arrows:
Hi SanMiguel,
I compared your code with another indicator and it looks like you need to set your Buffers to 2. You have no Buffers set and it defaults to 1.
I also added color and width to make it easier to see. You can adjust them as you need.
#property indicator_color1 Aqua#property indicator_width1 3
#property indicator_color2 Magenta
#property indicator_width2 3
Hope this helps,
Robert
any ideas why it needs to be recompiled on every restart for it to work?
SanMiguel:
any ideas why it needs to be recompiled on every restart for it to work?
did you install in "\program files" on vista/win7
any ideas why it needs to be recompiled on every restart for it to work?

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The arrows here are only shown in one direction. Any ideas where the error is?