Hull variation 2 EA

 

Hello guys,

I am new to MQL4 programming.

I started an EA using the indicator Slope Direction Line Modified.

I checked the EA in very old post https://www.mql5.com/en/forum/178852

https://c.mql5.com/forextsd/forum/49/slopedirectionline_v3_1.mq4 SlopeDirectionLine_v3.mq4.

Test on EURUSD M5, M15, M30 and H1 but not opened any order. It takes a lot to open a new bar

Following the recommendation of Mladen I am using the indicator Hull variation 2

Now I'm trying to use the indicator Hull variation 2

I'm starting with an example that in a post mladen

current = iCustom(NULL,0,"HMA Color nrp", HMA_period,HMA_PriceType,HMA_Method,0,0);

previous = iCustom(NULL,0,"HMA Color nrp", HMA_period,HMA_PriceType,HMA_Method,0,1);

while(true)

{

if (current > previous)

{

... green code;

break;

}

if (current < previous)

{

... red code;

break;

}

yellow code; break

}

I'm trying the code below

//Entry_Logic

//Culclate Indicator

double Hull_Up = iCustom(NULL,0,"Hull variation 2", HMAPeriod,HMAPrice,HMADivisor,0,0);; //Uptrend of Previous Bar Blue Up

double Hull_Dn = iCustom(NULL,0,"Hull variation 2", HMAPeriod,HMAPrice,HMADivisor,0,1); //Dntrend of Previous Bar Red Down

// Buy and Sell Open

double MyPoint=Point;

if(Digits==3 || Digits==5) MyPoint=Point*10;

if(TotalOrdersCount()==0 && AllowTradesByTime()==True)

{

int result=0;

if(Hull_Up > Hull_Dn) // Here is your open buy rule

{

result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,Comentario,MagicNumber,0,Blue);

}

if(Hull_Up < Hull_Dn) // Here is your open Sell rule

{

result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,Comentario,MagicNumber,0,Red);

}

}

return(0);

}

In the EA Hull_Variation_RB_EA.mq4 attached the order is opening only once after it is closed does not open a new one.

Many orders open in the right direction indicator but are negative and lose a lot of money.

Attached SLOPE EA that has the same problem and does not close the orders by the indicator.

Could anyone help me to improve this EA?

Thank you.

Rogério

 

Hi mladen, You have any examples of how to use the Hull variation 2 in EA?

Thank you,

Rogério

 
borgesr:
Hi mladen, You have any examples of how to use the Hull variation 2 in EA?

Thank you,

Rogério

Rogério

It can be used like any other custom indicator : use the iCustom() call in order to retrieve the information form the indicator that is needed for your EA

 

Mladen,

I tried the code below but unfortunately does not work properly.

//Entry_Logic

//Culclate Indicator

double Hull_Up = iCustom(NULL,0,"Hull variation 2", HMAPeriod,HMAPrice,HMADivisor,0,0);; //Uptrend of Previous Bar Blue Up

double Hull_Dn = iCustom(NULL,0,"Hull variation 2", HMAPeriod,HMAPrice,HMADivisor,0,1); //Dntrend of Previous Bar Red Down

Regards,

Rogério

 
borgesr:
Mladen,

I tried the code below but unfortunately does not work properly.

//Entry_Logic

//Culclate Indicator

double Hull_Up = iCustom(NULL,0,"Hull variation 2", HMAPeriod,HMAPrice,HMADivisor,0,0);; //Uptrend of Previous Bar Blue Up

double Hull_Dn = iCustom(NULL,0,"Hull variation 2", HMAPeriod,HMAPrice,HMADivisor,0,1); //Dntrend of Previous Bar Red Down

Regards,

Rogério

Rogério

You are missing the first parameter of Hull variation 2 indicator (the TimeFrame) - you can not omit the parameters from the start

Also, the simplest way to do that is to use it like this ("trend" buffer already has all you need for trend determination) :

// Up trend if hull trend == 1

// Down trend if hull trend == -11

double hull_trend = iCustom(NULL,0,"Hull variation 2","", HMAPeriod,HMAPrice,HMADivisor,3,0);;

 

Mladen Thanks for the quick response

Sorry for the basic questions but I am still learning MQL.

In this case you could use the code below?

// Up trend if hull trend == 1

// Down trend if hull trend == -11

double hull_trend = iCustom(NULL,0,"Hull variation 2","", HMAPeriod,HMAPrice,HMADivisor,3,0);

// Buy and Sell Open

double MyPoint=Point;

if(Digits==3 || Digits==5) MyPoint=Point*10;

if(TotalOrdersCount()==0 && AllowTradesByTime()==True)

{

int result=0;

if(hull_trend == 1) // Here is your open buy rule

{

result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,Comentario,MagicNumber,0,Blue);

}

if(hull_trend == 2) // Here is your open Sell rule

{

result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,Comentario,MagicNumber,0,Red);

}

}

Thank you,

Rogério

 
borgesr:
Mladen Thanks for the quick response

Sorry for the basic questions but I am still learning MQL.

In this case you could use the code below?

// Up trend if hull trend == 1

// Down trend if hull trend == -11

double hull_trend = iCustom(NULL,0,"Hull variation 2","", HMAPeriod,HMAPrice,HMADivisor,3,0);

// Buy and Sell Open

double MyPoint=Point;

if(Digits==3 || Digits==5) MyPoint=Point*10;

if(TotalOrdersCount()==0 && AllowTradesByTime()==True)

{

int result=0;

if(hull_trend == 1) // Here is your open buy rule

{

result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,Comentario,MagicNumber,0,Blue);

}

if(hull_trend == 2) // Here is your open Sell rule

{

result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,Comentario,MagicNumber,0,Red);

}

}

Thank you,

Rogério

Rogério

First of all I am assuming that you want a new order only when the trend changes

For that case use a code like this :

int barToTest = 1; // Or use 0 for a still opened bar

double hull_trend_current = iCustom(NULL,0,"Hull variation 2","", HMAPeriod,HMAPrice,HMADivisor,3,barToTest);

double hull_trend_previous = iCustom(NULL,0,"Hull variation 2","", HMAPeriod,HMAPrice,HMADivisor,3,barTotest+1);

//

//

// open order only if trend changes

//

//

if (hull_trend_current != hull_trend_previous)

{

if (hull_trend_current == 1).... // code for buy handling

if (hull_trend_current == -1).... // code for sell handling

}

That should do the basic Hull trend handling

 

Mladen Thanks a lot for the help.

I adjusted the robot with his example but it does not open any order.

I am sending you the Hull_Variation_RB_EA.mq4 attached.

I checked in an article post your other interesting indicator HMA slope Color nrp & mtf & alerts + arrows 2.01.mq4 believe it is good to use in conjunction with Hull Variation.

Thank you.

Rogério

 
borgesr:
Mladen Thanks a lot for the help.

I adjusted the robot with his example but it does not open any order.

I am sending you the Hull_Variation_RB_EA.mq4 attached.

I checked in an article post your other interesting indicator HMA slope Color nrp & mtf & alerts + arrows 2.01.mq4 believe it is good to use in conjunction with Hull Variation.

Thank you.

Rogério

Rogério

They are the same (both indicators are Hull averages - not a good idea to use two indicators that are coming from the same type of calculation as if they different in any type of signal confirmation)

 

Mladen Thanks a lot for the help.

I adjusted the EA with his example but it does not open any order.

I am sending you the Hull_Variation_RB_EA.mq4 attached.

Could you give me another indicator to work together with the Hull Variation?

Thank you,

Rogério

 
borgesr:
Mladen Thanks a lot for the help.

I adjusted the EA with his example but it does not open any order.

I am sending you the Hull_Variation_RB_EA.mq4 attached.

Could you give me another indicator to work together with the Hull Variation?

Thank you,

Rogério

This is what I get after a couple of minutes of back-testing (so it works) :

Files:
test.jpg  335 kb