Once the EA is dropped on the chart it should determine the ticket numbers and take profit values once, not every time a new tick comes in, therefore isn't it in the right place?
Every time a tick comes in it compares price with values obtained when initialized.
Is there someone who can actually help with this??
OK. Can you advise how to do so??
int start() { // add here init(); AdjustSL(); return(0); }
@WHRoeder: I understand your comment now about the chart or trade history not yet being downloaded. Since I only need the array's to be populated once I guess I will need some sort of switch so that it runs only once? Thanks.
@klam2404: Thanks also!
Today on the ausnzd d1 price dropped to 1.07489 (at time of writting). the screen shot below includes the low at the time though cant see cursor.
In the past when i've set tp levels the positions automatically close when price reaches the levels. My tp level was 1.07487 i.e. 2 pipettes below the shown low. As my code attempts to modify the SL level to BE when tp1 is reached and uses the bid for shorts the orders' SL were updated (which i found exciting!) but the broker didn't automatically activate my tp because it wasnt reached.. Should I use sth different than Bid so i'm using the same value as the broker??
// if tp1 reached move to BE if(Bid<=TP1&&MovedToBE==false)
Much appreciated!!
Today on the ausnzd d1 price dropped to 1.07489 (at time of writting). the screen shot below includes the low at the time though cant see cursor.
In the past when i've set tp levels the positions automatically close when price reaches the levels. My tp level was 1.07487 i.e. 2 pipettes below the shown low. As my code attempts to modify the SL level to BE when tp1 is reached and uses the bid for shorts the orders' SL were updated (which i found exciting!) but the broker didn't automatically activate my tp because it wasnt reached.. Should I use sth different than Bid so i'm using the same value as the broker??
Much appreciated!!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there. Thanking you for assistance.
I'm trying to create an EA that works as follows. After I open a trade with 3 positions all with a common SL and entry price, with a TP1, TP2 and without a TP for the 3rd position, I want my EA to move to BE when the price reaches TP1. When price reaches TP2 I want to move the SL to the TP1 level. From that point I want to manually adjust the SL level for the 3rd position. I tried to make an EA that will look at every open order and create an index for the ticket numbers and for the take profit levels. After TP1 is reached the first orders is closed and so the new SL level for the 2nd and 3rd position applies. At TP2 the 2nd position is closed and so the new level for the 3rd position applies and no further adjustments are required. So without any further adieu here is my code but nothing appears to happen at all.
Again, thank you kindly.