Heiken Ashi Smoothed on multiple charts?

 

Good day.

First of all thanks a lot to PHY for helping me with my previous post. U rock! He gave me the key to build my first robot! And a semi successful one at that!

https://www.mql5.com/en/users/phy


I would like to know, using the Heiken Ashi Smoothed indicator, how use the indicator on multiple charts? ie. On the 5min up to the 1 month. I want to have an individual HAS indicator for every chart then start playing with them. eg. if 5min and 30min = down(red) then sell.


I've used the below in my first robot, but I assume this is just for the currant chart.


haOpen=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
haClose=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);
haOpen2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,1,0);
haClose2=iCustom(NULL,0,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,0,0);


Is it something to do with the MaPeriod2? (Please see below variables)

extern int MaMetod=2;
extern int MaPeriod=6;
extern int MaMetod2 =3;
extern int MaPeriod2=2;


Thanks for all the input. One day I also would like to start giving input than asking questions.

Files:
 

specify timeframe in call

haOpen=iCustom(NULL, PERIOD_W1, "Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);

 
phy:

specify timeframe in call

haOpen=iCustom(NULL, PERIOD_W1, "Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);


Thanks again, O giving one!

 
phy:

specify timeframe in call

haOpen=iCustom(NULL, PERIOD_W1, "Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);


Good day.


I've figured out how to put the indicator on different time frames, thanks for above info from PHY. Now I've got and very funny error/problem. The expert runs fine, but It seems to be loading the trading data over and over again. This is increasing my pc's memory by about 100meg per tick. I know this can not be right. Please can someone tell me what I"m doing wrong. Thanks again for all your help. :)

Here is the code I've got so far. Plain and simple, shows the up/down of each HAS timeframe.

(I hate to be a newbie, the answer should be obvios)


//+------------------------------------------------------------------+
//| HASJACO.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+


void CreateTextLable
(string TextLableName, string Text, int TextSize, string FontName, color TextColor, int TextCorner, int X, int Y)
{
//---
ObjectCreate(TextLableName, OBJ_LABEL, 0, 0, 0);
ObjectSet(TextLableName, OBJPROP_CORNER, TextCorner);
ObjectSet(TextLableName, OBJPROP_XDISTANCE, X);
ObjectSet(TextLableName, OBJPROP_YDISTANCE, Y);
ObjectSetText(TextLableName,Text,TextSize,FontName,TextColor);
}



double fivemin_haOpen,fivemin_haClose;
double fifteen_min_haOpen,fifteen_min_haClose;
double thirty_min_haOpen,thirty_min_haClose;
double one_hour_haOpen,one_hour_haClose;
double four_hour_haOpen,four_hour_haClose;
double one_day_haOpen,one_day_haClose;
double one_week_haOpen,one_week_haClose;
double one_month_haOpen,one_month_haClose;
int MaMetod=2;
int MaPeriod=6;
int MaMetod2 =3;
int MaPeriod2=2;
color COL1,COL2,COL3,COL4,COL5,COL6,COL7,COL8;





int start()
{
// int counted_bars=IndicatorCounted();
//----


fivemin_haOpen=iCustom(NULL,5,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
fivemin_haClose=iCustom(NULL,5,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);
fifteen_min_haOpen=iCustom(NULL,15,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
fifteen_min_haClose=iCustom(NULL,15,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);
thirty_min_haOpen=iCustom(NULL,30,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
thirty_min_haClose=iCustom(NULL,30,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);
one_hour_haOpen=iCustom(NULL,60,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
one_hour_haClose=iCustom(NULL,60,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);
four_hour_haOpen=iCustom(NULL,240,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
four_hour_haClose=iCustom(NULL,240,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);
one_day_haOpen=iCustom(NULL,1440,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
one_day_haClose=iCustom(NULL,1440,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);
one_week_haOpen=iCustom(NULL,10080,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
one_week_haClose=iCustom(NULL,10080,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);
one_month_haOpen=iCustom(NULL,43200,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,2,0);
one_month_haClose=iCustom(NULL,43200,"Heiken_Ashi_Smoothed",MaMetod,MaPeriod,MaMetod2,MaPeriod2,3,0);




//5MIN//
string nametext1="5MIN";
if (fivemin_haOpen < fivemin_haClose)
{
nametext1="5:UP"; //BLUE
COL1=Blue;
}else
{
nametext1="5:DOWN"; //RED
COL1=Red;
}

//FIFTEEN MIN//
string nametext2="15MIN";
if (fifteen_min_haOpen < fifteen_min_haClose)
{
nametext2="15:UP"; //BLUE
COL2=Blue;
}else
{
nametext2="15:DOWN"; //RED
COL2=Red;
}

//////////EXACT SAME THING UNTIL MONTHLY TIME FRAME. DID NOT WANT TO PUT IT ALL IN TO SAME U TIME/////////////

CreateTextLable("label_object1",nametext1,20,"Times New Roman",COL1,0,30,20);
CreateTextLable("label_object2",nametext2,20,"Times New Roman",COL2,0,30,40);
CreateTextLable("label_object3",nametext3,20,"Times New Roman",COL3,0,30,60);
CreateTextLable("label_object4",nametext4,20,"Times New Roman",COL4,0,30,80);
CreateTextLable("label_object5",nametext5,20,"Times New Roman",COL5,0,30,100);
CreateTextLable("label_object6",nametext6,20,"Times New Roman",COL6,0,30,120);
CreateTextLable("label_object7",nametext7,20,"Times New Roman",COL7,0,30,140);
CreateTextLable("label_object8",nametext8,20,"Times New Roman",COL8,0,30,160);






//----
return(0);
}
//+------------------------------------------------------------------+

 

I there.

I ran the backtest from the 1'st of JAN and the problem was "solved"!?.. Strange. I've now finished an initial robot, and put it on an demo account with 10 pairs. The problem I now have is that it's suppose to make a trade per curancy pair, but it only makes one trade at an time. It it not suppose to make 1 trade per cur pair? Am I missing something?

So for each cur pair when conditions are met a buy/sell should be made? I've checked the other pairs, the conditions are met, but the trades does not initiate?

Please help.

Tnx.

if (m5==m15&&m30==h1&&m5==h4)
{
updown=m5;

if(OrdersTotal()==0)
{
if (Ballance!=0.0)
{
if (Ballance>AccountBalance())
{
LOT=Multi*LOT;
CreateTextLable("label_object11","LOSS",20,"Times New Roman",Green,0,30,220);
}
else
{
LOT=MLOT;
CreateTextLable("label_object11","NO LOSS",20,"Times New Roman",Green,0,30,220);
}
}
Ballance=AccountBalance();
if (updown==1)
{
nTicket=OrderSend(Symbol(),OP_BUY,LOT,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"HA Order",Magic,0,Green);
}
if (updown==0)
{
nTicket=OrderSend(Symbol(),OP_SELL,LOT,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"HA Order",Magic,0,Green);
}

}

}

 

You only take a trade when there are no trades -- if(OrdersTotal() == 0)

Change your logic.

 
phy:

You only take a trade when there are no trades -- if(OrdersTotal() == 0)

Change your logic.

Thanks for the reply. Should have done my homework before posting.

 
Blooper1980:

Thanks for the reply. Should have done my homework before posting.


Are you sure the open and close values are correct? I am calling iCustom using from an indicator and from an EA and getting different values when the same parameters are passed.

Larene

 

I figured it out. I am getting the directions on multiple time frames. Here is my EA.

Files: