Need help with simple Sell code using a signal from a custom indicator mt5

 

Hi everyone 


Need help with simple Sell code using a signal from a custom indicator,

the indicator will generate an arrow (color blue) with number 1 or 2, this will happen at the open of the candle or during.


in need a code to open a sell trade (only) whenever this happens and close the trade immediately at the close of the candle which the position was opened. 

can the code also be able to allow me to control the Lot size.

attached is the indicator 

will gladly appreciate the help 


<ex5 file deleted>

 

Please don't triple post! Create only one thread. If you want help then provide actual source code ".mq5" file, not an executable ".ex5" file.

Also, show your own attempt at coming up with a solution. Don't just expect others to code if for you. If that is what you want, then use the Freelance section.

 
Mangena12:

Hi everyone 


Need help with simple Sell code using a signal from a custom indicator,

the indicator will generate an arrow (color blue) with number 1 or 2, this will happen at the open of the candle or during.


in need a code to open a sell trade (only) whenever this happens and close the trade immediately at the close of the candle which the position was opened. 

can the code also be able to allow me to control the Lot size.

attached is the indicator 

will gladly appreciate the help 

It's easy.

Use iCustom.

Use CopyBuffer

Or Ask it in Freelance Section.

 
Mangena12 #:

hi 

thank you for the advice, 

Fernando Carreiro #
:

Please don't triple post! Create only one thread. If you want help then provide actual source code ".mq5" file, not an executable ".ex5" file.

Also, show your own attempt at coming up with a solution. Don't just expect others to code if for you. If that is what you want, then use the Freelance section.

hi 

thank you for the advice, 

 
_MAHA_ #:

It's easy.

Use iCustom.

Use CopyBuffer

Or Ask it in Freelance Section.

hi thank you for your reply,

i am still learning how to code,

here is what i came up with attached. not sure if i am doing it right



             

Files:
 
Mangena12 #:
kindly see my attempt , i am still learning how to code

Create an ea mql5.

You didn't add an input for adjusting and entering lot.

iCustom. Read the documentation and example at the bottom. Same for CopyBuffer. Also when calling a function, you should check its return in case of failure or error.


Delete the for loop.

Use ArraySetAsSeries on a object of a dynamic array.

Use 2 and 3 as buffer_num in CopyBuffer to access the signal value. If either of values is not equal to EMPTY_VALUE and no trades performed in that bar, so do trade. If trade is performed sucessfully, then check for a new bar to close it.

Use MqlTradeRequest  or CTrade  to place an order.

Reason: