Add Custom Indicator to Expert Advisor - page 2

 
WhooDoo22:



I am going to plow through the mql4 book to solve this problem. I am thankful for everyone's comments!


Thanks again.

 
WhooDoo22:

Thank you for your post RaptorUK.

I didn't recognize your ID i was just trying to help a little, hence the links. :-)
 
WhooDoo22:

Ok, this is what I am thinking folks...

// is this format correct according to you dabbler?

int start()

{

haOpen = iCustom(NULL,0,"HeikenwAshi",Red,White,Red,White,2,1);

haClose = iCustom(NULL,0,"HeikenwAshi",Red,White,Red,White,3,1);


if (haOpen[2] > haClose[1]) {

{

OrderSend(Symbol(),OP_SELL,1,Bid,30,Bid+500*Point,Bid-500*Point,"My order #WTF",54321,0,Red);

}}

Not quite. The result of iCustom is a single value, not an array

int start()

{

haOpen = iCustom(NULL,0,"HeikenwAshi",Red,White,Red,White,2,1);

haClose = iCustom(NULL,0,"HeikenwAshi",Red,White,Red,White,3,1);

if( haOpen > haClose ){

OrderSend(Symbol(),OP_SELL,1,Bid,30,Bid+500*Point,Bid-500*Point,"My order #WTF",54321,0,Red);

}

On that other Heiken Ashi thread he had almost the same code!

And this is Nathan's code

      if(Hour() == StartHour) // Time to put your orders
      {
         double haOpen = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,2,1);
         double haClose = iCustom(NULL,0,"Heiken_Ashi_Smoothed",2,6,3,2,3,1);
         
         if(haOpen < haClose) 
         { 
            cmd = 0; price = Ask; colour = Green; stoploss = Bid - SL*Point; takeprofit = Ask + TP*Point; 
         }
         
         if(haOpen > haClose)
         {
            cmd = 1; price = Bid; colour = Red; stoploss = Ask + SL*Point; takeprofit = Ask - TP*Point;
         }
   
         if(cmd != 2)
         {
            OrderSend(Symbol(), cmd, Lots, price, slippage, stoploss, takeprofit, NULL, magic, 0, colour) ;
            return;
         }
      }

Almost identical!

 
RaptorUK:
I didn't recognize your ID i was just trying to help a little, hence the links. :-)

Thank you for the links!
 
dabbler:

Not quite. The result of iCustom is a single value, not an array

On that other Heiken Ashi thread he had almost the same code!

And this is Nathan's code

Almost identical!


Thank you!

I don't understand why there is six (6) values or variables (not sure what they are called). Maybe Mode or Shift? (according to documentation). Monkey nuggets :)

Example:

haOpen = iCustom(NULL,0,"HeikenwAshi",Red,White,Red,White,2,1);

Is this because there is a total of four (4) parameters: Open,Close,High,Low. And a total of two (2) colors? (The answer seems obvious, but I want confirmation if possible).

If the above statement is true, why is Red and White used twice? (2x) Is this because the Red and White are representin' (representing) the High,Low,Close, and Open?

I also viewed Nathans post. I offered assistance and will wait for him to upload that custom indicator. (I had that indicator a'while back, but gosh, I can't keep up with indicator files! SOOO MANY!)


Thank you

 
dabbler:

Not quite. The result of iCustom is a single value, not an array

On that other Heiken Ashi thread he had almost the same code!

And this is Nathan's code

Almost identical!


Thank you

Why is the mode value a two (2) in the first declaration?

Why is the mode value a three (3) in the second declaration?

Is this because the haOpen is a "thinner" line, and haClose is a "thicker" line? (I am assuming that numbers two (2) and three (3) represent the thickness of the colored lines).

I am coding as you read this message.


haOpen = iCustom(NULL,0,"HeikenwAshi",Red,White,Red,White,2,1);

haClose = iCustom(NULL,0,"HeikenwAshi",Red,White,Red,White,3,1);
 

BOOM! Its done! https://forum.mql4.com/39078

I uploaded the files to Nathans post so that my code can solve his problem. I think I did a F*ck'n pro job, thanks to babbler and RaptorUK!

TO MQL4 FORUM USERS: If you are struggling with custom indicators, the solution is to follow the directions below...

1. Download the files I created at https://forum.mql4.com/39078 (there are two(2) files.) File one is the expert advisor and file two is Heiken Ashi indicator.

2. Follow the instructions I have provided located on that post in order to successfully use the files in your MetaTrader Terminal.

3. THE END.


Thank you.


-RunnerUp^bitch3s^ out!

 
dabbler:

See these lines

These are the names of the lines on the chart.

Then they are filled

so for the last closed bar ExtMapBuffer3[1] will be haOpen.

That is the data you want, buffers 3 and 4 (which because of a bit of inconsistency will actually be indexed as 2 and 3.

In the iCustom function https://docs.mql4.com/indicators/icustom

you need to set the mode to the index buffer you want

The name of the indicator has to exactly match the name of the mq4/ex4 indicator or it won't work.


Hi,

I'm new to EA programming myself. I'd like to ask why you need to have a shift of 1 in the icustom string

 
sargedessy:

Hi,

I'm new to EA programming myself. I'd like to ask why you need to have a shift of 1 in the icustom string

If you want the value of the Indicator buffer for bar 1 . . then you use 1 as the shift value, if you want the value of the Indicator buffer for bar 10 . . . then you use 10 for the shift value.
Reason: