please help for simple coding

 

hi im a beginner and im trying to build a very simple EA just to understand how it works first.

Can anybody help me by giving some simple example of a code for

1. Alert when it hits take profit

2.Alert when it hits stop loss

my scenario is this:- after i execute lets say Order buy function, it sets the take profit to 20 pips and stop loss also to 20 pips.

now, i just need an example of a code to alert when it hits the take profit or stop loss. just a simple example. or maybe a variety way of writing this code i would appreciate it.

thanks :)

 

If the orderselect loop doesn't find the order - it has closed.

Find the latest order closed in history. Check if OrderClosePrice is closest to TP or SL.

 
WHRoeder:

If the orderselect loop doesn't find the order - it has closed.

Find the latest order closed in history. Check if OrderClosePrice is closest to TP or SL.


im sorry WHRoeder im not quite undrstand, can u give me an example? or maybe u can write a simple code of buy order and then when it hits take profit or stop loss it will give Alert("profit!"); for take profit or Alert("loss"); for stop loss
 
WHRoeder:

If the orderselect loop doesn't find the order - it has closed.

Find the latest order closed in history. Check if OrderClosePrice is closest to TP or SL.


if OrdersTotal has become smaller you can check the history trades with orderselect loop.......

or if OrdersHistoryTotal has become more you check history trades with ......

 
i dont think that answer my question. i just want to see a simple code written for take profit and stop loss for the above issue
 
springyard:
i dont think that answer my question. i just want to see a simple code written for take profit and stop loss for the above issue
OK, go here: Make my code for me
 
RaptorUK:
OK, go here: Make my code for me


ok thanks i try it now
Reason: