If you want to save your hard coded inputs, copy the whole of this:
Code: Select all
double CalculateTakeProfit(int type, double price)
{
//Returns the take profit for use in LookForTradingOpps and InsertMissingStopLoss
double take;
double lp = 0;
RefreshRates();
if (ObjectFind(tpline) > -1)
{
lp = ObjectGet(tpline, OBJPROP_PRICE1);
}//if (ObjectFind(tpline) > -1)
if (type == OP_BUY)
{
if (!CloseEnough(TakeProfit, 0) )
{
take = price + (TakeProfit / factor);
HiddenTakeProfit = take;
}//if (!CloseEnough(TakeProfit, 0) )
//TP at the stack tp line if stacking is being used
if (!CloseEnough(lp, 0)) take = lp;
if (HiddenPips > 0 && take > 0) take = NormalizeDouble(take + (HiddenPips / factor), Digits);
}//if (type == OP_BUY)
if (type == OP_SELL)
{
if (!CloseEnough(TakeProfit, 0) )
{
take = price - (TakeProfit / factor);
HiddenTakeProfit = take;
}//if (!CloseEnough(TakeProfit, 0) )
//TP at the stack tp line if stacking is being used
if (!CloseEnough(lp, 0)) take = lp;
if (HiddenPips > 0 && take > 0) take = NormalizeDouble(take - (HiddenPips / factor), Digits);
}//if (type == OP_SELL)
return(take);
}//End double CalculateTakeProfit(int type)