MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Copy experienced traders' deals with Trading Signals

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)
 
Visual Optimization of Indicator and Signal Profitability

Visual Optimization of Indicator and Signal Profitability

This article is a continuation and development of my previous article "Visual Testing of Profitability of Indicators and Alerts". Having added some interactivity to the parameter changing process and having reworked the study objectives, I have managed to get a new tool that does not only show the prospective trade results based on the signals used but also allows you to immediately get a layout of deals, balance chart and the end result of trading by moving virtual sliders that act as controls for signal parameter values in the main chart.

avatar
856
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