Newbie needs help with coding.

 

Hello guys, I am new to coding, so now I am trying to code an EA to help me manage my orders in terms of SL, TP, and be levels.

 I am now having a problem to my tp levels, since my strategy has 3 tp levels which are set according to the nearest round numbers(every 100 pips).

Examples, I sold USD/JPY  at 110.50 and I want to have my first tp level at 110.00 then the second tp level at 109.00 and finally third tp at 108.00

Since I am new to coding, can anyone tell me is it possible to code  such a thing? Thanks in advance.

 

may be you can try like this..

sellprice=110.50;
OpenPrice=NormalizeDouble(sellprice,0);

TP1=OpenPrice-100*Point;
TP2=OpenPrice-200*Point;
 
I think he wants system TP's to be in place.

You will have to monitor your trades in your code , or open 3 orders with different tp's
 

I have done exactly this in one of my EAs.

I think I should show you what I did here.

I think I will share it here. 

 
Dafiri Irimagha:

I have done exactly this in one of my EAs.

I think I should show you what I did here.

I think I will share it here. 

Do you mind sharing the code?
 
Lorentzos Roussos:
I think he wants system TP's to be in place.

You will have to monitor your trades in your code , or open 3 orders with different tp's

According to my trading system, once the trade hit TP1, the SL of the trade will set to break even and awaits for TP2 and TP3.

In such case, making the EA to open 3 orders with different TPs leads me to another problem which is I have no idea how to make 2 other orders SL to BE after TP1 reached. 

I am new to coding, so do you recommend one order to close partially up to 3 times or open up 3 orders at once?

 
Siti Latifah:

may be you can try like this..

But in that case my TP1 is only 50pips, TP2 150pips and TP3 for 250pips.

Sell USD/JPY 110.50

TP1 110.00

TP2 109.00

TP3 109.00 

Coding it the way like this one below

TP1=OpenPrice-100*Point;

Isn't it going to make the TP1 to be at 109.50?

Reason: