Download MetaTrader 5

Newbie needs help with coding.

To add comments, please log in or register
viintex
23
viintex  

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.

Siti Latifah
6946
Siti Latifah  

may be you can try like this..

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

TP1=OpenPrice-100*Point;
TP2=OpenPrice-200*Point;
Lorentzos Roussos
10047
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
Dafiri Irimagha
226
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. 

viintex
23
viintex  
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?
viintex
23
viintex  
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?

viintex
23
viintex  
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?

To add comments, please log in or register