Skip to content

Commit 7a341cd

Browse files
authored
1.18
1. Added two input parameters to set colors for the Long/Short order direction button. 2. Added an input parameter to set the color for the Trade buttons. 3. Added the Include directions switch to the Risk tab to filter either All, Buy only, or Sell only when calculating risk and reward data. 4. Changed how the TP-locked-on-SL feature works. It is now turned on and off via a dedicated checkbox on the Main tab rather than being bound to the TP button. 5. Changed the Count pending orders checkbox on the Risk tab to a button that switches between All, Pending orders, and Open positions. 6. Changed the Ignore symbols switch to the Include symbols switch on the Risk tab. 7. Fixed checkbox color (was always dark). 8. Fixed a bug with TP not following SL for Pending orders. 9. Fixed incorrect application of trading restrictions from the Trading tab. 10. Fixed risk calculation for no-SL buy trades on the Risk tab. 11. Fixed a potentially crashing bug when no account data is available.
1 parent d5dc2f9 commit 7a341cd

File tree

77 files changed

+13140
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+13140
-0
lines changed

PositionSizer/PositionSizer.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30011.22
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PositionSizer", "PositionSizer\PositionSizer.csproj", "{fd30f0bd-39e0-46b8-9173-68b7f60fdcfa}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{fd30f0bd-39e0-46b8-9173-68b7f60fdcfa}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{fd30f0bd-39e0-46b8-9173-68b7f60fdcfa}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{fd30f0bd-39e0-46b8-9173-68b7f60fdcfa}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{fd30f0bd-39e0-46b8-9173-68b7f60fdcfa}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace cAlgo.Robots;
2+
3+
public enum AdditionalTradeButtons
4+
{
5+
None,
6+
AboveTheEntryLine,
7+
MainTab,
8+
Both
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace cAlgo.Robots;
2+
3+
public enum AtrCandle
4+
{
5+
CurrentCandle,
6+
PreviousCandle
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.ComponentModel;
2+
3+
namespace cAlgo.Robots;
4+
5+
public enum IncludeDirectionsMode
6+
{
7+
[Description("All Directions")]
8+
AllDirections,
9+
[Description("Long Only")]
10+
LongOnly,
11+
[Description("Short Only")]
12+
ShortOnly
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.ComponentModel;
2+
3+
namespace cAlgo.Robots;
4+
5+
public enum IncludeOrdersMode
6+
{
7+
[Description("All")]
8+
All,
9+
[Description("Pending Only")]
10+
PendingOnly,
11+
[Description("Pos. Only")]
12+
PositionsOnly
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.ComponentModel;
2+
3+
namespace cAlgo.Robots;
4+
5+
public enum IncludeSymbolsMode
6+
{
7+
[Description("All")]
8+
All,
9+
[Description("Current Only")]
10+
CurrentOnly,
11+
[Description("Others Only")]
12+
OthersOnly
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace cAlgo.Robots;
2+
3+
public enum ShowSpreadMode
4+
{
5+
None,
6+
Pips,
7+
Spread_SL_Ratio
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace cAlgo.Robots;
2+
3+
public enum SymbolChangeAction
4+
{
5+
/// <summary>
6+
/// Each chart symbol has it's own model file and parameter settings file
7+
/// </summary>
8+
EachSymbolOwnSettings,
9+
10+
/// <summary>
11+
/// Everytime the symbol changes, the robot will reset to default settings
12+
/// If there's an old settings file, it will be kept and used
13+
/// </summary>
14+
ResetToDefaultsOnSymbolChange,
15+
16+
/// <summary>
17+
/// There are some global settings that are shared between all symbols
18+
/// Those that are not shared will be reset to default everytime the symbol changes
19+
/// </summary>
20+
KeepPanelAsIs
21+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
using cAlgo.API;
2+
3+
namespace cAlgo.Robots;
4+
5+
public class ExtractedParameters
6+
{
7+
public string Version { get; set; }
8+
public bool InputShowLineLabels { get; set; }
9+
public bool InputShowAdditionalStopLossLabel { get; set; }
10+
public bool InputShowAdditionalTpLabel { get; set; }
11+
public bool InputShowAdditionalEntryLabel { get; set; }
12+
public bool InputHideAccountSize { get; set; }
13+
public bool InputShowPipValue { get; set; }
14+
public bool InputShowMaxPositionSizeButton { get; set; }
15+
public bool InputStartPanelMinimized { get; set; }
16+
public bool InputShowAtrOptions { get; set; }
17+
public bool InputShowMaxParametersOnTradingTab { get; set; }
18+
public bool InputShowTradingFusesOnTradingTab { get; set; }
19+
public bool InputShowCheckBoxesOnTradingTab { get; set; }
20+
public AdditionalTradeButtons InputAdditionalTradeButtons { get; set; }
21+
public bool InputHideEntryLineForInstantOrders { get; set; }
22+
public SerializableColor InputStopLossLabelColor { get; set; }
23+
public SerializableColor InputTpLabelColor { get; set; }
24+
public SerializableColor InputStopPriceLabelColor { get; set; }
25+
public SerializableColor InputEntryLabelColor { get; set; }
26+
public int InputLabelsFontSize { get; set; }
27+
public SerializableColor InputEntryLineColor { get; set; }
28+
public SerializableColor InputStopLossLineColor { get; set; }
29+
public SerializableColor InputTakeProfitLineColor { get; set; }
30+
public SerializableColor InputStopPriceLineColor { get; set; }
31+
public SerializableColor InputBreakevenLineColor { get; set; }
32+
public LineStyle InputEntryLineStyle { get; set; }
33+
public LineStyle InputStopLossLineStyle { get; set; }
34+
public LineStyle InputTakeProfitLineStyle { get; set; }
35+
public LineStyle InputStopPriceLineStyle { get; set; }
36+
public LineStyle InputBreakevenLineStyle { get; set; }
37+
public int InputEntryLineWidth { get; set; }
38+
public int InputStopLossLineWidth { get; set; }
39+
public int InputTakeProfitLineWidth { get; set; }
40+
public int InputStopPriceLineWidth { get; set; }
41+
public int InputBreakevenLineWidth { get; set; }
42+
public TradeType InputTradeType { get; set; }
43+
public double InputDefaultStopLossPips { get; set; }
44+
public double InputDefaultTakeProfitPips { get; set; }
45+
public int InputTakeProfitsNumber { get; set; }
46+
public OrderType InputOrderType { get; set; }
47+
public bool InputShowLinesByDefault { get; set; }
48+
public int InputAtrPeriod { get; set; }
49+
public double InputDefaultAtrMultiplierStopLoss { get; set; }
50+
public double InputDefaultAtrMultiplierTakeProfit { get; set; }
51+
public SerializableTimeFrame InputAtrTimeFrame { get; set; }
52+
public bool InputSpreadAdjustmentStopLoss { get; set; }
53+
public bool InputSpreadAdjustmentTakeProfit { get; set; }
54+
public AccountSizeMode InputAccountSizeMode { get; set; }
55+
public double InputRiskPercentage { get; set; }
56+
public double InputMoneyRisk { get; set; }
57+
public double InputPositionSizeInLots { get; set; }
58+
public IncludeOrdersMode InputIncludeOrdersMode { get; set; }
59+
public bool InputIgnoreOrdersWithoutStopLoss { get; set; }
60+
public bool InputIgnoreOrdersWithoutTakeProfit { get; set; }
61+
public IncludeSymbolsMode InputIncludeSymbolsMode { get; set; }
62+
public IncludeDirectionsMode InputIncludeDirectionsMode { get; set; }
63+
public double InputCustomLeverage { get; set; }
64+
public string InputLabel { get; set; }
65+
public string InputCommentary { get; set; }
66+
public bool InputAutoSuffix { get; set; }
67+
public bool InputDisableTradingWhenLinesAreHidden { get; set; }
68+
public double InputMaxSlippagePips { get; set; }
69+
public double InputMaxSpreadPips { get; set; }
70+
public double InputMaxEntryStopLossDistancePips { get; set; }
71+
public double InputMinEntryStopLossDistancePips { get; set; }
72+
public double InputMaxPositionSizeTotalForTradingTab { get; set; }
73+
public double InputMaxPositionSizePerSymbolForTradingTab { get; set; }
74+
public bool InputSubtractOpv { get; set; }
75+
public bool InputSubtractPov { get; set; }
76+
public bool InputDoNotApplyStopLoss { get; set; }
77+
public bool InputDoNotApplyTakeProfit { get; set; }
78+
public bool InputAskForConfirmation { get; set; }
79+
public int InputPanelPositionX { get; set; }
80+
public int InputPanelPositionY { get; set; }
81+
public bool InputTakeProfitLockedOnStopLoss { get; set; }
82+
public double InputTrailingStopPips { get; set; }
83+
public double InputBreakevenPips { get; set; }
84+
public int InputExpirySeconds { get; set; }
85+
public int InputMaxNumberOfTradesTotal { get; set; }
86+
public int InputMaxNumberOfTradesPerSymbol { get; set; }
87+
public double InputMaxRiskTotal { get; set; }
88+
public double InputMaxRiskPerSymbol { get; set; }
89+
public bool InputStopLossDistancePipsInsteadOfLevel { get; set; }
90+
public bool InputTakeProfitDistancePipsInsteadOfLevel { get; set; }
91+
public string InputHotkeyExecuteTrade { get; set; }
92+
public string InputHotkeySwitchOrderType { get; set; }
93+
public string InputHotkeySwitchEntryDirection { get; set; }
94+
public string InputHotkeySwitchHideShowLines { get; set; }
95+
public string InputHotkeySetStopLoss { get; set; }
96+
public string InputHotkeySetTakeProfit { get; set; }
97+
public string InputHotkeySetEntry { get; set; }
98+
public string InputMinimizeMaximizeHotkeyPanel { get; set; }
99+
public string InputHotkeySwitchStopLossPointsLevel { get; set; }
100+
public string InputSwitchTpPointsLevelHotkey { get; set; }
101+
public double InputTakeProfitMultiplierForStopLossValue { get; set; }
102+
public bool InputUseCommissionToSetTpDistance { get; set; }
103+
public ShowSpreadMode InputShowSpread { get; set; }
104+
public double InputAdditionalFunds { get; set; }
105+
public double InputCustomBalance { get; set; }
106+
public AtrCandle InputAtrCandle { get; set; }
107+
public bool InputCalculateUnadjustedPositionSize { get; set; }
108+
public bool InputSurpassBrokerMaxPositionSizeWithMultipleTrades { get; set; }
109+
public bool InputUseAsyncOrders { get; set; }
110+
public RoundingMode InputRoundingPositionSizeAndPotentialReward { get; set; }
111+
public double InputQuickRisk1Pct { get; set; }
112+
public double InputQuickRisk2Pct { get; set; }
113+
public bool InputDisableStopLimit { get; set; }
114+
public bool InputApplySlTpAfterAllTradesExecuted { get; set; }
115+
public bool InputDarkMode { get; set; }
116+
public bool InputRestoreWindowLocationOnChartSizeChange { get; set; }
117+
public bool InputUseLastSavedSettings { get; set; }
118+
public bool InputPrefillAdditionalTpsBasedOnMain { get; set; }
119+
public bool InputAskForConfirmationBeforeClosingThePanel { get; set; }
120+
public bool InputAllowSmallerTradesWhenTradingLimitsAreExceeded { get; set; }
121+
public int InputRefreshMilliseconds { get; set; }
122+
public int InputIndexTest { get; set; }
123+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
using cAlgo.API;
2+
using cAlgo.Robots.Tools;
3+
using PositionSizer.XTextBoxControl.ByTypes;
4+
5+
namespace cAlgo.Robots;
6+
7+
public interface IKeyMultiplierFeature
8+
{
9+
Chart Chart { get; }
10+
void Print(object obj);
11+
}
12+
13+
public class KeyMultiplierFeature
14+
{
15+
private readonly IKeyMultiplierFeature _resources;
16+
public double KeyMultiplier { get; set; }
17+
18+
public KeyMultiplierFeature(IKeyMultiplierFeature resources)
19+
{
20+
_resources = resources;
21+
22+
Chart.KeyDown += args =>
23+
{
24+
KeyMultiplier = 1;
25+
26+
/*
27+
Add keyboard modifiers for the increase and decrease buttons to add/subtract
28+
in multiples of the tick size: Ctrl (×10), Shift (×100), and Ctrl+Shift (×1000).
29+
For the +/- buttons - e.g., near the Stop-loss, Take-profit, and so on.
30+
*/
31+
32+
if (args.CtrlKey && !args.ShiftKey)
33+
{
34+
KeyMultiplier = 10;
35+
Print($"Key Multiplier: {KeyMultiplier}");
36+
return;
37+
}
38+
39+
if (!args.CtrlKey && args.ShiftKey)
40+
{
41+
KeyMultiplier = 100;
42+
Print($"Key Multiplier: {KeyMultiplier}");
43+
return;
44+
}
45+
46+
if (args.CtrlKey && args.ShiftKey)
47+
{
48+
KeyMultiplier = 1000;
49+
Print($"Key Multiplier: {KeyMultiplier}");
50+
return;
51+
}
52+
};
53+
54+
Chart.MouseDown += args =>
55+
{
56+
Print($"Setting Key Multiplier to 1");
57+
KeyMultiplier = 1;
58+
};
59+
}
60+
61+
public void SetFeatureOnButton(XTextBoxDoubleNumeric button)
62+
{
63+
button.DecrementButtonClicked += (sender, args) => button.ChangeByFactor *= KeyMultiplier;
64+
button.IncrementButtonClicked += (sender, args) => button.ChangeByFactor *= KeyMultiplier;
65+
button.OnAfterClick += (sender, args) =>
66+
{
67+
if (KeyMultiplier.IsNot(1))
68+
button.ChangeByFactor /= KeyMultiplier;
69+
70+
ResetKeyMultiplier();
71+
};
72+
}
73+
74+
public void ResetKeyMultiplier()
75+
{
76+
KeyMultiplier = 1;
77+
}
78+
79+
private Chart Chart => _resources.Chart;
80+
private void Print(object obj)
81+
{
82+
_resources.Print(obj);
83+
}
84+
}

0 commit comments

Comments
 (0)