### Calculating Percentage Distance from TakeProfit Price to position.EntryPrice to do A Stop Jump

yeril123@hotmail.com since: 06 Oct 2016;

26 Sep 2022, 09:25
###### Calculating Percentage Distance from TakeProfit Price to position.EntryPrice to do A Stop Jump

So what I am trying to is to create a Stop Jump that once the price is getting closer to the Take Profit it will removed the take profit and move the Stop Lose closer by percentages in distance.

What do i mean by percentage in distance?

For example:

Parameneters
% Distance Trigger
% Distance Place StopJump

--
Position Entry Price = 20,000
Take Profit Price = 25,000

Distance = (Distance between EntryPrice and TakeProfit)

What I am trying to do is the following:

if the position is winning at "X Distance(in % from the Take Profit)", Remove take profit and place Stop Lose at "X Distance( in % from the Take Profit).

private void OnStopJumpPerPercentage()
{

double PercentageTrigger = StopJumpTrigger / 100;
double percentageDiference = StopJumpPercentage / 100;

double NewStopJumplaceSell =0;

{

double DistancePipTrigger = Math.Round((DistanceFRomEntryAndMarjetTPBuy * PercentageTrigger) * Symbol.PipSize);

if (CurrentDistanceFrom_TP_Price >= DistancePipTrigger)
}

foreach (Position position in sellPositions)
{

double DistanceFRomEntryAndMarjetTPSell = Math.Round((TakeProfitSell - position.EntryPrice) * Symbol.PipSize);

double CurrentDistanceFrom_TP_Price = Math.Round((TakeProfitSell - Symbol.Bid) * Symbol.PipSize);

double DistancePipTrigger = Math.Round((DistanceFRomEntryAndMarjetTPSell * PercentageTrigger) * Symbol.PipSize);

NewStopJumplaceSell = position.EntryPrice + (DistanceFRomEntryAndMarjetTPSell * percentageDiference) * Symbol.PipSize;

if (CurrentDistanceFrom_TP_Price >= DistancePipTrigger)
ModifyPosition(position, NewStopJumplaceSell);
}
}