# Calculating Price Target

[Deleted]

Hi,I want to set up a TP on my ea, which equals (High[2]-Low[2])*1.5

Which is simply put range of a certain bar multplied by 1.5..

My question is How do I type it correctly because it seems that i make a calculation error. Thank you.

```  for(int s=OrdersTotal()-1;s>=0;s--)
{
if(OrderMagicNumber()==MagicNumber)
if(OrderSymbol()==Symbol())
if(OrderType()==OP_SELL)
OrderModify(OrderTicket(),OrderOpenPrice(),High[2]+3*Point,(High[2]-Low[2])*1.5,0,Brown);```
17410

Redael777:

Hi,I want to set up a TP on my ea, which equals (High[2]-Low[2])*1.5

Which is simply put range of a certain bar multplied by 1.5..

My question is How do I type it correctly because it seems that i make a calculation error. Thank you.

For a Sell you can't set the TP higher than the current price . . . you need to check before you try to modify the order . . . you also need to check the return value from your Trading Functions and if they fail report the error and any relevant variables: What are Function return values ? How do I use them ?

This is what your code needs to check before placing or modifying Orders: Requirements and Limitations in Making Trades
[Deleted]

I meant Bid - (High[2]-Low[2])*1.5, will that do? what should I add?

17410

Redael777:

I meant Bid - (High[2]-Low[2])*1.5, will that do? what should I add?

You need to check to see if that price complies with this: Requirements and Limitations in Making Trades <--- click this and read . . .
[Deleted]

ok i will play with stoplevel etc, but more important for me is the arithmetics, when i tried to print out(using Comment) this (High[2]-Low[2])*1.5 it gave me 0...

17410

Redael777:

ok i will play with stoplevel etc, but more important for me is the arithmetics, when i tried to print out(using Comment) this (High[2]-Low[2])*1.5 it gave me 0...

If you have a bar with no movement High equals Low so High - Low = 0.0
[Deleted]
so how should i calculate barlength that is already finished..?
17410

Redael777:
so how should i calculate barlength that is already finished..?
You are calculating it correctly . . . but if High == Low the length is 0.0
Moderator
32166

Redael777:

ok i will play with stoplevel etc, but more important for me is the arithmetics, when i tried to print out(using Comment) this (High[2]-Low[2])*1.5 it gave me 0...