Using a custom indicator in an EA

Back to topics list To post a new topic, please log in or register
avatar
3
jaypnarayan 2009.02.03 08:50
 

Hello Experts,

I am relatively new in using expert advisors, and I need your help in learning it better. I am trying to learn how to use custom indicators in EA.

I downloaded a custom indicator "parabolic_sub.mq4" from this site. I copied it to my experts/indicator folder and I compiled it. When I drag this custom indicator from my navigator to the chart, it correctly shows psar values.

When I call it from my EA, it always gives me zero. This is how I call it in a for loop

double psar[6];

For (i = 0; i <= 5; i++)

{

psar[i] = iCustom(NULL,0,"parabolic_sub",0.02,0.2,i);

print(psar[i]); <== It always seems to print "0".

}

I don't know why it doesn't print actual psar values. I appreciate your help. I am also attaching the custom indicator I am using.

Regards,

Jay

Attached files:
  parabolicosub.mq4  (7.44 KB)
 
Aaron’s Profit Suit REVIEW BINARY NEED TO KNOW THE TRUTH
Aaron’s Profit Suit – Breakthrough Money-Making Software! Millions of dollars pass through the trading Industry every second of every day and you are missing out in a huge way. With Aaron’s Profit Suit system YOU will earn 50K+ per month! This brand new software is generating INSANE results within just a few seconds! This is NEW, FRESH.
avatar
857
fbj 2009.02.03 22:19 #
 

you did:

psar[i] = iCustom(NULL,0,"parabolic_sub",0.02,0.2,i);

.............................................................................^

you need:

iCustom(NULL,0,"parabolic_sub",0.02,0.2,<MODE>,<SarBuffer[index]>);

.................................................................^^^^^^

must be "Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions." the indicator uses: "SetIndexBuffer(0, SarBuffer);"

.

iCustom(NULL,0,"parabolic_sub",0.02,0.2,<MODE>,<SarBuffer[index]>);

and------------------------------------------------------------^^^^^^^^^^^^

must be actual "Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago)." iow, if you use ,2 that is going to return to you SarBuffer[2]

.

eg:

psar[i] = iCustom(NULL,0,"parabolic_sub",0.02,0.2,0,shift);

shift is the index into the index buffer "SarBuffer[]"

.

your code loops 6 times - to load your psar[0..5] array.

.

your code MUST decide what values it wants from the indicators SarBuffer[] each time iCustom() called

IF it is SarBuffer[0..5] then ok... just do above replacing shift for i

.

ending up with:

psar[i] = iCustom(NULL,0,"parabolic_sub",0.02,0.2,0,i);

.

have-a-go... maybe it will work for you ;)

 
avatar
3
jaypnarayan 2009.02.05 02:08 #
 
fbj wrote >>

you did:

psar[i] = iCustom(NULL,0,"parabolic_sub",0.02,0.2,i);

.............................................................................^

you need:

iCustom(NULL,0,"parabolic_sub",0.02,0.2,<MODE>,<SarBuffer[index]>);

.................................................................^^^^^^

must be "Line index. Can be from 0 to 7 and must correspond with the index used by one of SetIndexBuffer functions." the indicator uses: "SetIndexBuffer(0, SarBuffer);"

.

iCustom(NULL,0,"parabolic_sub",0.02,0.2,<MODE>,<SarBuffer[index]>);

and------------------------------------------------------------^^^^^^^^^^^^

must be actual "Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago)." iow, if you use ,2 that is going to return to you SarBuffer[2]

.

eg:

psar[i] = iCustom(NULL,0,"parabolic_sub",0.02,0.2,0,shift);

shift is the index into the index buffer "SarBuffer[]"

.

your code loops 6 times - to load your psar[0..5] array.

.

your code MUST decide what values it wants from the indicators SarBuffer[] each time iCustom() called

IF it is SarBuffer[0..5] then ok... just do above replacing shift for i

.

ending up with:

psar[i] = iCustom(NULL,0,"parabolic_sub",0.02,0.2,0,i);

.

have-a-go... maybe it will work for you ;)

Thank You so much! It does work like a champ

Back to topics list  

To add comments, please log in or register