How to code? - page 89

 
shanyang:
i have downloaded an indicator,which shows green/red arrow when the buy/sell signal come.

now i want to program my own EA based on this indicator.

but i have only the ex4 file of this indicator(no source code)

I want my EA read the indicator arrow on the mainchart and send the buy/sell order(green arrow==>buy, red arrow==>sell)

is there any approach to get indicator arrow information on the main chart?

thanks

An arrow can be drawn as a value of one of the indicator's buffers; in this case, the color in the indicator's properties should give you the buffer's number, which is enough to call it by "ICustom()" function; You also need to fill all the values of the "Input" tab as parametres of the ICustom() call.

If the arrow is not a value of a buffer, it is an object. Select it to see its properties. Most of the time, it's easy to understand how the names are generate and then it will be possible to use ObjectFind().

The EA should watch ObjectsTotal(), and only when it is incremented it may try to recognize the last object. If the name is unknow, the EA cannot use OjectFind() and has to scan all objects to identify the last one. The last object is not obviously the one with the highest index (ObjectsTotal() - 1), but it's better to start to scan from the higest index as you probably can break faster. Now you have to compare the OBJPROP_TIME1 get by ObjectGet() to Time[0] or Time[1] for exemple, and check the color or the arrow type, or a substring of the name, to identify a buy or a sell signal.

It seems complex but it is not. Try to write it and dont hesitate to ask more precisions if needed.

 
Big Be:
The previous reply was incomplete.

If the indicator is standard in MT4, it will show up in the normal place. If it is called by iCustom, it will also show up, if coded right.

The following EAs even have the indicators show on the chart window. Study them to learn how:

bouncingPipEA_mpowerV42.mq4

bouncingPipEA_BigBear_v23.mq4

Big Be

Thanks Big Be, I'll check them out.

 
Michel:
An arrow can be drawn as a value of one of the indicator's buffers; in this case, the color in the indicator's properties should give you the buffer's number, which is enough to call it by "ICustom()" function; You also need to fill all the values of the "Input" tab as parametres of the ICustom() call.

If the arrow is not a value of a buffer, it is an object. Select it to see its properties. Most of the time, it's easy to understand how the names are generate and then it will be possible to use ObjectFind().

The EA should watch ObjectsTotal(), and only when it is incremented it may try to recognize the last object. If the name is unknow, the EA cannot use OjectFind() and has to scan all objects to identify the last one. The last object is not obviously the one with the highest index (ObjectsTotal() - 1), but it's better to start to scan from the higest index as you probably can break faster. Now you have to compare the OBJPROP_TIME1 get by ObjectGet() to Time[0] or Time[1] for exemple, and check the color or the arrow type, or a substring of the name, to identify a buy or a sell signal.

It seems complex but it is not. Try to write it and dont hesitate to ask more precisions if needed.

Great explanation Michel ... 100% more complete than mine !

Thanks for who is interested.

FerruFx

 

change ind in a EA

i would like to change the indicator in a EA i have,but i don't know how to do it

i am not a programmer in fact don't much about this kind kind of thing, below is the only part that relates to the indicator i want to change the DiMA to MFA(14)

i want to buy @ >60 and sell@<40

double diClose0=iClose(NULL,5,0);

double diMA1=iMA(NULL,5,7,0,MODE_SMA,PRICE_OPEN,0);

double diClose2=iClose(NULL,5,0);

double diMA3=iMA(NULL,5,6,0,MODE_SMA,PRICE_OPEN,0);

if(AccountFreeMargin()<(1000*Lots)){

Print("We have no money. Free Margin = ", AccountFreeMargin());

return(0);

}

if (!ExistPositions()){

if ((diClose0<diMA1)){

OpenBuy();

return(0);

}

if ((diClose2>diMA3)){

OpenSell();

return(0);

}

}

could someone please help me

denis

 

Please post your MFA indicator. I need to see the buffers. Under what logic will you want to switch indicators?

Dave

 

hi dave i can't post the MFI indicator it is not in the indicators folder you can get the indicator from the tool bar under volumes,i don't know what you mean by under what logic.

denis

 
denis68:
hi dave i can't post the MFI indicator it is not in the indicators folder you can get the indicator from the tool bar under volumes,i don't know what you mean by under what logic. denis

This one? Market Facilitation Index

Files:
mfi.mq4  3 kb
 

hi linuxer i don't think thats the one but thanks anyway, the one i have is called money flow index.

denis

 
denis68:
hi linuxer i don't think thats the one but thanks anyway, the one i have is called money flow index. denis

Sorry, I've misspelled the name, it's that one.

Money Flow Index.mq4 aka MFI.mq4

 
Reason: