molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming http://www.molanis.com/forum/ |
|
heiken ashi custom indicator http://www.molanis.com/forum/viewtopic.php?f=14&t=651 |
Page 1 of 2 |
Author: | paulhyland [ Sun Nov 20, 2011 6:30 am ] |
Post subject: | heiken ashi custom indicator |
Would anyone be kind enough to offer some help - i'm trying to build an EA that uses the custom indicator Heiken Ashi as one of the 'TA' blocks. I just need to identify when the candle changes colour - for example when the Heiken Ashi candle is blue then buy. when it changes to red then close the position. I have imported Heiken Ashi into the 'iCustom' indicator but am struggling to find the correct mode to use (I believe there are 5 for this indicator in total). I have tried to represent a blue Heiken Ashi candle with the following arrangement: Heiken Ashi (mode 3) higher than Heiken Ashi (mode 0) here im trying to say "the Close is higher than the Open, so therefore the candle is blue" Does anyone know if im using the correct mode's, or if there is a more sensible way to do this? Ive spent some time looking through the forums already, but I don't have enough experience or knowledge to be able to apply the solutions to some of the other problems mentioned. Many thanks to anyone who can help. |
Author: | molanisfx [ Sun Nov 20, 2011 5:24 pm ] |
Post subject: | Re: heiken ashi custom indicator |
There are many Heiken Ashi on the internet. Please post yours to take a look. |
Author: | paulhyland [ Mon Nov 21, 2011 8:36 am ] |
Post subject: | Re: heiken ashi custom indicator |
//+------------------------------------------------------------------+ //| Heiken_Ashi.mq5 | //| Copyright 2009, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "2009, MetaQuotes Software Corp." #property link "http://www.mql5.com" //--- indicator settings #property indicator_chart_window #property indicator_buffers 5 #property indicator_plots 1 #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_color1 DodgerBlue, Red #property indicator_label1 "Heiken Ashi Open;Heiken Ashi High;Heiken Ashi Low;Heiken Ashi Close" //--- indicator buffers double ExtOBuffer[]; double ExtHBuffer[]; double ExtLBuffer[]; double ExtCBuffer[]; double ExtColorBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ExtOBuffer,INDICATOR_DATA); SetIndexBuffer(1,ExtHBuffer,INDICATOR_DATA); SetIndexBuffer(2,ExtLBuffer,INDICATOR_DATA); SetIndexBuffer(3,ExtCBuffer,INDICATOR_DATA); SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX); //--- IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //--- sets first bar from what index will be drawn IndicatorSetString(INDICATOR_SHORTNAME,"Heiken Ashi"); //--- sets drawing line empty value PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); //--- initialization done } //+------------------------------------------------------------------+ //| Heiken Ashi | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total,const int prev_calculated, const datetime &Time[], const double &Open[], const double &High[], const double &Low[], const double &Close[], const long &TickVolume[], const long &Volume[], const int &Spread[]) { int i,limit; //--- preliminary calculations if(prev_calculated==0) { //--- set first candle ExtLBuffer[0]=Low[0]; ExtHBuffer[0]=High[0]; ExtOBuffer[0]=Open[0]; ExtCBuffer[0]=Close[0]; limit=1; } else limit=prev_calculated-1; //--- the main loop of calculations for(i=limit;i<rates_total && !IsStopped();i++) { double haOpen=(ExtOBuffer[i-1]+ExtCBuffer[i-1])/2; double haClose=(Open[i]+High[i]+Low[i]+Close[i])/4; double haHigh=MathMax(High[i],MathMax(haOpen,haClose)); double haLow=MathMin(Low[i],MathMin(haOpen,haClose)); ExtLBuffer[i]=haLow; ExtHBuffer[i]=haHigh; ExtOBuffer[i]=haOpen; ExtCBuffer[i]=haClose; //--- set candle color if(haOpen<haClose) ExtColorBuffer[i]=0.0; // set color DodgerBlue else ExtColorBuffer[i]=1.0; // set color Red } //--- done return(rates_total); } //+------------------------------------------------------------------+ |
Author: | molanisfx [ Mon Nov 21, 2011 3:54 pm ] |
Post subject: | Re: heiken ashi custom indicator |
It looks like the mode is 4: SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX); The color is give by numbers, 0.0 for blue and 1.0 for red ExtColorBuffer[i]=0.0; // set color DodgerBlue else ExtColorBuffer[i]=1.0; // set color Red So use mode 4, if the indicator is equal to 0.0 it means blue (in anothe TA do the same for equal to red) |
Author: | paulhyland [ Mon Nov 21, 2011 6:44 pm ] |
Post subject: | Re: heiken ashi custom indicator |
Thanks, but I actually tried that first of all, but got the following error messages in MT5: "Error copying indicator buffer - error: 4807!! EA won't trade this tick or bar" and "Error creating handles for indicators - error 4802!! Restart your EA again" |
Author: | molanisfx [ Tue Nov 22, 2011 9:44 am ] |
Post subject: | Re: heiken ashi custom indicator |
Please post your strategy file - that way I can test the code generation |
Author: | paulhyland [ Wed Nov 23, 2011 10:32 am ] | ||
Post subject: | Re: heiken ashi custom indicator | ||
Attached, thanks
|
Author: | admin [ Wed Nov 23, 2011 5:13 pm ] |
Post subject: | Re: heiken ashi custom indicator |
Odd. It works for me. Try getting the latest mt5 version, the latest version of our software, then recompile the indicator in mt5 and generate the ea again. |
Author: | paulhyland [ Thu Nov 24, 2011 6:58 am ] | ||
Post subject: | Re: heiken ashi custom indicator | ||
OK, iv'e completely removed Molanis EA visual wizard and downloaded the latest version from your site. I have also removed MT5 and downloaded the latest version from metaquotes. I have re-written the trading diagram, validated it, and double checked my metatrader directory. I still get the same two error messages. Please can you take a look, I have attached the trading diagram - Please can you take a look? (I'm beginning to think this Molanis software is just a hoax! - I've never been able to get one to work) thanks
|
Author: | molanisfx [ Thu Nov 24, 2011 8:09 am ] |
Post subject: | Re: heiken ashi custom indicator |
Did you compiled the indicator again with the new mt5? |
Page 1 of 2 | All times are UTC - 5 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |