But how would you calculate the TP at which all orders should close in overall profit
- Calculate all order average price level.
- minus (or add) 10pips to that price.
- Calculate all order average price level.
- minus (or add) 10pips to that price.
So is it possible to code a function like that, in which regardless of the number of open trades the Expert Advisor can calculate the average price while weighing in the increased lot size per order?
I tried to find an answer to this but could not find anything.
Example: https://ibb.co/1GWQdRS
Lets say this martingale bot has a
-PipStep range of: 20 pips
-And a TP of 10 pips.
If the first sell order were to be successfull the trade would've closed 10 pips in profit.
But how would you calculate the TP at which all orders should close in overall profit if the market goes against you and you end up opening 4 trades with a lot multiplier of 2 like the image above shows?
I appreciate any help, I hope I made myself clear.
You could use these functions: (call CalculateTP with the first order volume)
double CalculateTP(double volume)
{
double aux_take_profit;
aux_take_profit=tp*CalculatePipValue(volume);
return(aux_take_profit);
}
double CalculateSL(double volume)
{
double aux_stop_loss;
aux_stop_loss=-1*grid_size*CalculatePipValue(volume);
return(aux_stop_loss);
}
double CalculatePipValue(double volume)
{
double aux_mm_value=0;
double aux_mm_tick_value = SymbolInfoDouble(Symbol, SYMBOL_TRADE_TICK_VALUE);
double aux_mm_tick_size = SymbolInfoDouble(Symbol, SYMBOL_TRADE_TICK_SIZE);
long aux_mm_digits = SymbolInfoInteger(Symbol, SYMBOL_DIGITS);
double aux_mm_veces_lots;
if (volume!=0)
{
aux_mm_veces_lots = 1/volume;
if (aux_mm_digits==5 || aux_mm_digits==3)
{
aux_mm_value=aux_mm_tick_value*10;
}
else if (aux_mm_digits==4 || aux_mm_digits==2)
{
aux_mm_value = aux_mm_tick_value;
}
aux_mm_value = aux_mm_value/aux_mm_veces_lots;
}
return(aux_mm_value);
}
You could use these functions: (call CalculateTP with the first order volume)
double CalculateTP(double volume)
{
double aux_take_profit;
aux_take_profit=tp*CalculatePipValue(volume);
return(aux_take_profit);
}
double CalculateSL(double volume)
{
double aux_stop_loss;
aux_stop_loss=-1*grid_size*CalculatePipValue(volume);
return(aux_stop_loss);
}
double CalculatePipValue(double volume)
{
double aux_mm_value=0;
double aux_mm_tick_value = SymbolInfoDouble(Symbol, SYMBOL_TRADE_TICK_VALUE);
double aux_mm_tick_size = SymbolInfoDouble(Symbol, SYMBOL_TRADE_TICK_SIZE);
long aux_mm_digits = SymbolInfoInteger(Symbol, SYMBOL_DIGITS);
double aux_mm_veces_lots;
if (volume!=0)
{
aux_mm_veces_lots = 1/volume;
if (aux_mm_digits==5 || aux_mm_digits==3)
{
aux_mm_value=aux_mm_tick_value*10;
}
else if (aux_mm_digits==4 || aux_mm_digits==2)
{
aux_mm_value = aux_mm_tick_value;
}
aux_mm_value = aux_mm_value/aux_mm_veces_lots;
}
return(aux_mm_value);
}
you might want to learn from this

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I tried to find an answer to this but could not find anything.
Example: https://ibb.co/1GWQdRS
Lets say this martingale bot has a
-PipStep range of: 20 pips
-And a TP of 10 pips.
If the first sell order were to be successfull the trade would've closed 10 pips in profit.
But how would you calculate the TP at which all orders should close in overall profit if the market goes against you and you end up opening 4 trades with a lot multiplier of 2 like the image above shows?
I appreciate any help, I hope I made myself clear.