little help with my simple EA

 

i want to use lsma_lines indicators (pitchfork) and a Moving average to make a simple ea. to call the indicator i use

"indicator-assigned-name"=iCustom(Symbol(),0,"indicator-name",parameters,0,0);

//---- indicator parameters
IdNum =1;
RPeriod=68;
LineColor=Red;
LineWeight =1;
PriceVal=0;

StDev=1.618;



the problem is that this lsma_lines has 3 lines (3 output) median, reg-lower, and reg-upper, so i tried to do like this


median=iCustom(Symbol(),0,"indicator-name",parameters,0,0);

reg-lower=iCustom(Symbol(),0,"indicator-name",parameters,2,0);

reg-upper=iCustom(Symbol(),0,"indicator-name",parameters,1,0);


i used this numbers according to what i find in lsma_line.mq4

i continued to write the code normally and i have to call separately this 3 output

the ea does some trades but only in one direction, it seems it recognize only the reg-lower line.

i think is a problem due to the right output calling.

i attach lsma_lines.mq4 so if anyone want to give a look and help me :D

Thanks

Files:
lsma_line.mq4  5 kb
 

the ea does some trades but only in one direction, it seems it recognize only the reg-lower line. Try Print() to verify the values of the upper-lines.

 

Try this, and please get back if this is working or not ;.

add #property indicator_buffers 3 on top.

#property indicator_chart_window
#property indicator_buffers 3

do all of this on init ()

   //IndicatorBuffers(3); // <<== make it a comment

   SetIndexBuffer(0, Y1);
   //SetIndexEmptyValue(0, 0); // <<== make it a comment
   SetIndexBuffer(1, Y2);
   //SetIndexEmptyValue(1, 0); // <<== make it a comment
   SetIndexBuffer(2, SD);
   //SetIndexEmptyValue(2, 0); // <<== make it a comment
   
   //SetIndexStyle(0, DRAW_NONE, EMPTY, EMPTY, CLR_NONE) ; //<<== not sure if needed
   //SetIndexStyle(1, DRAW_NONE, EMPTY, EMPTY, CLR_NONE) ; //<<== not sure if needed
   //SetIndexStyle(2, DRAW_NONE, EMPTY, EMPTY, CLR_NONE) ; //<<== not sure if needed
   SetIndexLabel (0, "1");  // <<== add this
   SetIndexLabel (1, "2");  // <<== add this
   SetIndexLabel (2, "3");  // <<== add this

When I check your LSMA code, it does NOT show anything on data window. So do this : shutdown both your MT and MetaEditor. The start MetaEditor first, compile LSMA, and run MT, and see if this show on Data Window.

 
gege79:


median=iCustom(Symbol(),0,"indicator-name",parameters,0,0);

reg-lower=iCustom(Symbol(),0,"indicator-name",parameters,2,0);

reg-upper=iCustom(Symbol(),0,"indicator-name",parameters,1,0);

Did you change the name of the indicator to "indicator-name" or did you use the correct Indicator file name in your code ?
 

and did you use the correct parameters or a single variable named parameters.

There are no mind-readers here. POST THE ACTUAL CODE!

 
onewithzachy:

Try this, and please get back if this is working or not ;.

add #property indicator_buffers 3 on top.

do all of this on init ()

When I check your LSMA code, it does NOT show anything on data window. So do this : shutdown both your MT and MetaEditor. The start MetaEditor first, compile LSMA, and run MT, and see if this show on Data Window.


Ok i modified sma-lines as you sayd(attached file)

here i call outputs pithfork indicator:

pitchforkup=iCustom(Symbol(),0,"LSMA_Line_RaptorUK",1,68,Red,1,0,1.618,1,0); // this should be reg_upper

pitchforkdown=iCustom(Symbol(),0,"LSMA_Line_RaptorUK",1,68,Green,1,0,1.618,2,0); // this should be reg_lower

and a simple moving average:

MA1 = iCustom(NULL,0,"Moving Averages Red",1,0,MODE_SMA,PRICE_CLOSE);


here there are my sell and buy conditions:

if(MA1 > pitchforkup && OP_SELL <= 3) {....ticket...}

if(MA1 < pitchforkdown && OP_BUY <= 3) {....ticket...}

REVERSE for close conditions

PROBLEM: it opens only sell trade, and it doesnt close trades(only at stop loss or tp)

it seems it recognize at start only reg-upper and then nothing


i've attached also ea if you want to give a look. Thanks

Files:
 
gege79:

i should modify and put this lines in indicator? or in my ea? thanks

read also the post of RaptorUK and WHRoeder again your iCustom function is wrong coded !!!!
 

Yo, guys !.

Check his LSMA Line, it draws 3 lines using trendlines object, but there is 3 buffers.

I print the value of it's 3 buffers and all printed zero !.

I think gege79 knows how to codes, but please check the CI first before reply him about iCustom.

Aaaargghhh, let's not waste time ....

iCustom (Symbol (), Period (), "LSMA_Line", IdNum, RPeriod, LineColor, LineWeight, PriceVal, StDev, buffer, mode);
 
onewithzachy:

Yo, guys !.

Check his LSMA Line, it draws 3 lines using trendlines object, but there is 3 buffers.

I print the value of it's 3 buffers and all printed zero !.

I think gege79 knows how to codes, but please check the CI first before reply him about iCustom.

Aaaargghhh, let's not waste time ....


lol i should put onewithzachy instead of RaptorUk as name for modified indicators. mistake...sry :D
 
deVries:

read also the post of RaptorUK and WHRoeder again your iCustom function is wrong coded !!!!

it was a sample code :D
 

in CI, Here's your new LSMA, please do what I've told you :

Files:
Reason: