# How to convert a users Dollar amount into pips for stoploss or takeprofit

94

Can someone help me?

If a user inputs \$10

extern double takeProfit=10.00;

extern double lotSize=0.01;

how can you convert this so you can add set the take profit to \$10.00 above the ask.

Thank you

Moderator
10566

Her's a script that I did some time ago that modifies open orders according to SL and TP in account currency.

It may not be exactly what you want, but can probably be modified.

```//+------------------------------------------------------------------+
//|                                                        order.mq4 |
//|                                                           GumRai |
//|                                                             none |
//+------------------------------------------------------------------+
#property version   "1.00"
#property strict
#property script_show_inputs
//--- input parameters
input double SL_in_Currency=10;
input double TP_in_Currency=10;

#include <stdlib.mqh>
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
//---

for(int x=OrdersTotal()-1;x>=0;x--)
{
{
Print("Error with OrderSelect-",ErrorDescription(GetLastError()));
continue;
}
continue;
continue;

double pnt=SymbolInfoDouble(OrderSymbol(),SYMBOL_POINT);
double loss_for_1_lot=SymbolInfoDouble(OrderSymbol(),SYMBOL_TRADE_TICK_VALUE);  //Loss/Gain for a 1 tick move with 1 lot
double loss_for_lot_size_this_trade=loss_for_1_lot*OrderLots();    //Loss/Gain for a 1 tick move with trade lot size
double SL_points=MathFloor(SL_ticks*tick_size/pnt)*pnt;
double TP_points=MathFloor(TP_ticks*tick_size/pnt)*pnt;

if(OrderType()==OP_SELL)
{
SL_points= (-SL_points);
TP_points= (-TP_points);
}

double new_sl=OrderOpenPrice()-SL_points;
if(MathAbs(new_sl-OrderClosePrice()) -minfromcurrentprice<pnt)
{
Alert(OrderSymbol()," Order ",OrderTicket()," SL too close to current price");
new_sl=OrderStopLoss();
}
double new_tp=OrderOpenPrice()+TP_points;
if(MathAbs(new_tp-OrderClosePrice()) -minfromcurrentprice<pnt)
{
Alert(OrderSymbol()," Order ",OrderTicket()," TP too close to current price");
new_tp=OrderTakeProfit();
}
if(MathAbs(new_sl-OrderStopLoss())>=pnt || MathAbs(new_tp-OrderTakeProfit())>=pnt)
OrderModify(OrderTicket(),OrderOpenPrice(),new_sl,new_tp,0,0);

}
}
//+------------------------------------------------------------------+
```
94

Right on thank you. I will have a loo k in the morning and test it out.
94

I just tested it out and that is exactly what I was trying to do thank you so much I will have to go through your code so that I understand it better.