MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Find Out Why Virtual Hosting is Better than VPS

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)
 
SOMETHING TO READ - How 23 Novice Investors Became Overnight Millionaires
The Complete TurtleTrader: How 23 Novice Investors Became Overnight Millionaires by Michael W. Covel What happens when ordinary people are taught a system to make extraordinary money? Richard Dennis made a fortune on Wall Street by investing according to a few simple rules. Convinced that great trading was a skill that could be taught to anyone, he made a bet with his partner and ran a classified ad in the Wall Street Journal looking for novices to train.
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