molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Sun Apr 28, 2024 3:23 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: heiken ashi custom indicator
PostPosted: Sun Nov 20, 2011 6:30 am 
Offline

Joined: Tue Jun 14, 2011 5:45 pm
Posts: 17
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.


Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Sun Nov 20, 2011 5:24 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
There are many Heiken Ashi on the internet. Please post yours to take a look.


Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Mon Nov 21, 2011 8:36 am 
Offline

Joined: Tue Jun 14, 2011 5:45 pm
Posts: 17
//+------------------------------------------------------------------+
//| 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);
}
//+------------------------------------------------------------------+


Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Mon Nov 21, 2011 3:54 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
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)


Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Mon Nov 21, 2011 6:44 pm 
Offline

Joined: Tue Jun 14, 2011 5:45 pm
Posts: 17
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"


Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Tue Nov 22, 2011 9:44 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Please post your strategy file - that way I can test the code generation


Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Wed Nov 23, 2011 10:32 am 
Offline

Joined: Tue Jun 14, 2011 5:45 pm
Posts: 17
Attached, thanks


Attachments:
trident.mol5 [20.03 KiB]
Downloaded 1200 times
Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Wed Nov 23, 2011 5:13 pm 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
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.


Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Thu Nov 24, 2011 6:58 am 
Offline

Joined: Tue Jun 14, 2011 5:45 pm
Posts: 17
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


Attachments:
double303.mol5 [15.8 KiB]
Downloaded 1244 times
Top
 Profile  
 
 Post subject: Re: heiken ashi custom indicator
PostPosted: Thu Nov 24, 2011 8:09 am 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Did you compiled the indicator again with the new mt5?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009