Skip to content

Instantly share code, notes, and snippets.

@arielmoraes
Last active April 24, 2021 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielmoraes/1350b0dea65a00e199ae999468cd3836 to your computer and use it in GitHub Desktop.
Save arielmoraes/1350b0dea65a00e199ae999468cd3836 to your computer and use it in GitHub Desktop.
SkyStrategy
private void UpdateStrategy()
{
var newChange = (CurrentPrice - EnterPrice) / EnterPrice;
CurrentPercentChange = newChange * 100;
if (CurrentPercentChange >= MinWinPercentage)
{
if (CurrentPercentChange > MaxWinPercentChange)
{
MaxWinPercentChange = CurrentPercentChange;
Action = StrategyAction.RaisingSell;
}
else
{
var winLossPercentage = MaxWinPercentChange * (MaxLossPercentageAfterWin / 100M);
var winLossDiff = MaxWinPercentChange - winLossPercentage;
if (CurrentPercentChange < winLossDiff)
{
Action = StrategyAction.FallingSell;
}
else
{
Action = StrategyAction.RaisingSell;
}
}
}
else if (CurrentPercentChange < MinWinPercentage)
{
Action = StrategyAction.Wait;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment