last works on XBackTester ...
This commit is contained in:
@@ -24,9 +24,26 @@
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Classes/x-saherelm.x-alert.class.mq5"
|
||||
#include "../Classes/x-saherelm.x-rm.panel.class.mq5"
|
||||
#include "../Classes/x-saherelm.x-chart.helper.class.mq5"
|
||||
#include "../Classes/x-saherelm.x-trade.class.mq5"
|
||||
|
||||
//
|
||||
// Import Chart Objects ...
|
||||
#include <Arrays/ArrayObj.mqh>
|
||||
#include <ChartObjects/ChartObject.mqh>
|
||||
#include <ChartObjects/ChartObjectsArrows.mqh>
|
||||
#include <ChartObjects/ChartObjectsFibo.mqh>
|
||||
#include <ChartObjects/ChartObjectsLines.mqh>
|
||||
#include <ChartObjects/ChartObjectsShapes.mqh>
|
||||
#include <ChartObjects/ChartObjectsTxtControls.mqh>
|
||||
#include <Charts/Chart.mqh>
|
||||
#include <Controls/Button.mqh>
|
||||
#include <Controls/Edit.mqh>
|
||||
#include <Controls/Label.mqh>
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
@@ -54,7 +71,32 @@ input bool eATerminalAlerts = false; // Terminal Alerts
|
||||
string eaLogTag; // EA Log Prefix ...
|
||||
XCAlert *eaAlert; // Alert Provider for Expert Adviser ...
|
||||
XCTrade *eaTrader; // Trader of Expert Adviser ...
|
||||
XCRMPanel eaMainWindow; // Main Window ...
|
||||
XCChartHelper *mChartHelper; // Chart Helper Class ...
|
||||
|
||||
//
|
||||
// Object Props ...
|
||||
|
||||
//
|
||||
string objSuffix;
|
||||
|
||||
//
|
||||
CButton btnBuy;
|
||||
CButton btnSell;
|
||||
CButton btnClose;
|
||||
CButton btnCloseAll;
|
||||
CButton btnSelectedPosInfo;
|
||||
|
||||
//
|
||||
CEdit lblPositionId;
|
||||
int lblPositionIdSizeX = 0;
|
||||
int lblPositionIdSizeY = 0;
|
||||
int lblPositionIdStartX = 0;
|
||||
int lblPositionIdStartY = 0;
|
||||
ulong selectedPositionID = 0;
|
||||
|
||||
//
|
||||
// Position Arrays ...
|
||||
CArrayObj posArray;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
@@ -148,6 +190,7 @@ void OnTick()
|
||||
// Handle On Trade Event ...
|
||||
void OnTrade()
|
||||
{
|
||||
//
|
||||
eaTrader.HandleOnTrade();
|
||||
}
|
||||
|
||||
@@ -168,9 +211,6 @@ void OnChartEvent(
|
||||
const string &sparam //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Apply Chart Event on Main Window ...
|
||||
eaMainWindow.ChartEvent(id, lparam, dparam, sparam);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -285,7 +325,19 @@ bool InitEA()
|
||||
eaSlippage,
|
||||
eaMagicNumber //
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Attach Event Handlers ...
|
||||
eaTrader.AddOnDealsChangedEventHandler(OnDealsChanged);
|
||||
eaTrader.AddOnStopLossEventHandler(OnStopLossTriggered);
|
||||
eaTrader.AddOnOrdersChangedEventHandler(OnOrdersChanged);
|
||||
eaTrader.AddOnTakeProfitEventHandler(OnTakeProfitTriggered);
|
||||
eaTrader.AddOnModifyPositionEventHandler(OnPositionModified);
|
||||
eaTrader.AddOnPositionsChangedEventHandler(OnPositionsChanged);
|
||||
eaTrader.AddOnTradeStateChangedEventHandler(OnTradeStateChanged);
|
||||
eaTrader.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
|
||||
eaTrader.AddOnPartialClosePositionEventHandler(OnPositionPartialClosed);
|
||||
|
||||
//
|
||||
// TODO: Fix This ...
|
||||
result = true;
|
||||
@@ -317,24 +369,155 @@ bool InitGUI()
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Initialize Application Main Window ...
|
||||
result = eaMainWindow.Create(
|
||||
ChartID(),
|
||||
ShortName, // Dialog Name ...
|
||||
0, // SubWindow ...
|
||||
10, // X1 ...
|
||||
35, // Y1 ...
|
||||
300, // X2 ...
|
||||
200 // Y2 ...
|
||||
);
|
||||
int subWindow = 0;
|
||||
ulong chartId = ChartID();
|
||||
objSuffix = ShortName + "_";
|
||||
|
||||
//
|
||||
// Try To Run Main Window ...
|
||||
// Initial Chart Class Instance ...
|
||||
mChartHelper = new XCChartHelper(chartId);
|
||||
|
||||
//
|
||||
int startX = 5;
|
||||
int startY = 25;
|
||||
|
||||
//
|
||||
// Buy ...
|
||||
int btnBuyStartX = startX;
|
||||
int btnBuySizeX = startX + 100;
|
||||
int btnBuyStartY = startY;
|
||||
int btnBuySizeY = startY + 50;
|
||||
string btnBuyName = objSuffix + "BTN_BUY";
|
||||
result = btnBuy.Create(
|
||||
chartId,
|
||||
btnBuyName,
|
||||
subWindow,
|
||||
btnBuyStartX,
|
||||
btnBuyStartY,
|
||||
btnBuySizeX,
|
||||
btnBuySizeY //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
eaMainWindow.Run();
|
||||
//
|
||||
// Apply Buy Button Style ...
|
||||
|
||||
//
|
||||
btnBuy.Text("Buy");
|
||||
btnBuy.Color(clrYellow);
|
||||
btnBuy.ColorBackground(clrGreen);
|
||||
}
|
||||
|
||||
//
|
||||
// Sell ...
|
||||
int btnSellStartX = btnBuyStartX + btnBuySizeX;
|
||||
int btnSellSizeX = btnSellStartX + 100;
|
||||
int btnSellStartY = btnBuyStartY;
|
||||
int btnSellSizeY = btnBuySizeY;
|
||||
string btnSellName = objSuffix + "BTN_SELL";
|
||||
result = btnSell.Create(
|
||||
chartId,
|
||||
btnSellName,
|
||||
subWindow,
|
||||
btnSellStartX,
|
||||
btnSellStartY,
|
||||
btnSellSizeX,
|
||||
btnSellSizeY //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Apply Sell Button Style ...
|
||||
|
||||
//
|
||||
btnSell.Text("Sell");
|
||||
btnSell.Color(clrYellow);
|
||||
btnSell.ColorBackground(clrDarkRed);
|
||||
}
|
||||
|
||||
//
|
||||
// LABEL Position ID ...
|
||||
lblPositionIdStartX = btnBuyStartX;
|
||||
lblPositionIdSizeX = lblPositionIdStartX + 100;
|
||||
lblPositionIdStartY = btnSellSizeY + 5;
|
||||
lblPositionIdSizeY = lblPositionIdStartY + 50;
|
||||
string lblPositionIdName = objSuffix + "LBL_POS_ID";
|
||||
result = lblPositionId.Create(
|
||||
chartId,
|
||||
lblPositionIdName,
|
||||
subWindow,
|
||||
lblPositionIdStartX,
|
||||
lblPositionIdStartY,
|
||||
lblPositionIdSizeX,
|
||||
lblPositionIdSizeY //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Apply Label Position ID Style ...
|
||||
lblPositionId.ReadOnly(true);
|
||||
lblPositionId.Text("Pos ID: ");
|
||||
lblPositionId.Color(clrYellow);
|
||||
lblPositionId.ColorBackground(clrDarkGray);
|
||||
}
|
||||
|
||||
//
|
||||
// Close ...
|
||||
int btnCloseStartX = startX;
|
||||
int btnCloseSizeX = btnCloseStartX + 100;
|
||||
int btnCloseStartY = lblPositionIdSizeY + 5;
|
||||
int btnCloseSizeY = lblPositionIdSizeY + 50;
|
||||
string btnCloseName = objSuffix + "BTN_CLOSE";
|
||||
result = btnClose.Create(
|
||||
chartId,
|
||||
btnCloseName,
|
||||
subWindow,
|
||||
btnCloseStartX,
|
||||
btnCloseStartY,
|
||||
btnCloseSizeX,
|
||||
btnCloseSizeY //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Apply Close Button Style ...
|
||||
|
||||
//
|
||||
btnClose.Text("Close");
|
||||
btnClose.Color(clrYellow);
|
||||
btnClose.ColorBackground(clrDarkOrange);
|
||||
}
|
||||
|
||||
//
|
||||
// Close All ...
|
||||
int btnCloseAllStartX = btnCloseSizeX + 5;
|
||||
int btnCloseAllSizeX = btnCloseAllStartX + 100;
|
||||
int btnCloseAllStartY = lblPositionIdSizeY + 5;
|
||||
int btnCloseAllSizeY = lblPositionIdSizeY + 50;
|
||||
string btnCloseAllName = objSuffix + "BTN_CLOSE_ALL";
|
||||
result = btnCloseAll.Create(
|
||||
chartId,
|
||||
btnCloseAllName,
|
||||
subWindow,
|
||||
btnCloseAllStartX,
|
||||
btnCloseAllStartY,
|
||||
btnCloseAllSizeX,
|
||||
btnCloseAllSizeY //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Apply Close Button Style ...
|
||||
|
||||
//
|
||||
btnCloseAll.Text("Close All");
|
||||
btnCloseAll.Color(clrYellow);
|
||||
btnCloseAll.ColorBackground(clrDarkRed);
|
||||
}
|
||||
|
||||
//
|
||||
UpdateGUIState();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -345,7 +528,94 @@ bool InitGUI()
|
||||
void UpdateGUI()
|
||||
{
|
||||
//
|
||||
eaMainWindow.UpdateState();
|
||||
UpdateGUIState();
|
||||
|
||||
//
|
||||
// Buy Button Pressed ...
|
||||
if (btnBuy.Pressed())
|
||||
{
|
||||
//
|
||||
HandleBuyTrade();
|
||||
btnBuy.Pressed(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Sell Button Pressed ...
|
||||
if (btnSell.Pressed())
|
||||
{
|
||||
//
|
||||
HandleSellTrade();
|
||||
btnSell.Pressed(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Close Button Pressed ...
|
||||
if (btnClose.Pressed())
|
||||
{
|
||||
//
|
||||
if (btnClose.IsEnabled())
|
||||
{
|
||||
//
|
||||
if (selectedPositionID > 0)
|
||||
{
|
||||
HandleCloseTrade(selectedPositionID);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
btnClose.Pressed(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Close All Button Pressed ...
|
||||
if (btnCloseAll.Pressed())
|
||||
{
|
||||
//
|
||||
if (btnCloseAll.IsEnabled())
|
||||
{
|
||||
HandleCloseTrade(0);
|
||||
}
|
||||
|
||||
//
|
||||
btnCloseAll.Pressed(false);
|
||||
}
|
||||
|
||||
//
|
||||
// Check Positions Buttons ...
|
||||
int posCount = posArray.Total();
|
||||
bool has = IsValidSize(posCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < posCount; i++)
|
||||
{
|
||||
//
|
||||
CButton *iBtn = (CButton *)posArray.At(i);
|
||||
|
||||
//
|
||||
if (iBtn.Pressed())
|
||||
{
|
||||
//
|
||||
if (iBtn.IsEnabled())
|
||||
{
|
||||
//
|
||||
ulong posID = ExtractPositionIDFromButtonName(iBtn.Name());
|
||||
if (posID > 0 && selectedPositionID != posID)
|
||||
{
|
||||
selectedPositionID = posID;
|
||||
UpdateGUIState();
|
||||
Print("Changed Selected Pos ID: ", selectedPositionID);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
iBtn.Pressed(false);
|
||||
}
|
||||
|
||||
//
|
||||
ZeroMemory(iBtn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,5 +624,448 @@ void UpdateGUI()
|
||||
void DestroyGUI()
|
||||
{
|
||||
//
|
||||
eaMainWindow.Destroy();
|
||||
delete mChartHelper;
|
||||
ZeroMemory(mChartHelper);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Trade Event Handlers ...
|
||||
|
||||
/**
|
||||
* Handle StopLoss Triggered Positions ...
|
||||
*
|
||||
* @param deal: XDeal instance ...
|
||||
*/
|
||||
void OnStopLossTriggered(const XDeal &deal)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Take Profit Triggered Positions ...
|
||||
*
|
||||
* @param deal: XDeal instance ...
|
||||
*/
|
||||
void OnTakeProfitTriggered(const XDeal &deal)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Force Close a Position ...
|
||||
*
|
||||
* @param ticket: ULONG ...
|
||||
* @param position: XPosition instance ...
|
||||
* @param comment: String ...
|
||||
*/
|
||||
void OnPositionForceClosed(
|
||||
const ulong ticket,
|
||||
const XPosition &position,
|
||||
const string comment //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Deals Changes ...
|
||||
*
|
||||
* @param count: Integer, Number of Changes ...
|
||||
*/
|
||||
void OnDealsChanged(int count)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Orders Changes ...
|
||||
*
|
||||
* @param count: Integer, Number of Changes ...
|
||||
*/
|
||||
void OnOrdersChanged(int count)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Positions Changes ...
|
||||
*
|
||||
* @param count: Integer, Number of Changes ...
|
||||
*/
|
||||
void OnPositionsChanged(int count)
|
||||
{
|
||||
//
|
||||
// Update Position Buttons ...
|
||||
UpdatePositionButtons();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Position Modified ...
|
||||
*
|
||||
* @param ticket: ulong, Position Ticket ...
|
||||
* @param profit: double, Position Profit ...
|
||||
* @param comment: string, Comment ...
|
||||
*/
|
||||
void OnPositionModified(
|
||||
const ulong ticket,
|
||||
const double profit,
|
||||
const string comment //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Position Partial Closed ...
|
||||
*
|
||||
* @param ticket: ulong, Position Ticket ...
|
||||
* @param profit: double, Position Profit ...
|
||||
* @param comment: string, Comment ...
|
||||
*/
|
||||
void OnPositionPartialClosed(
|
||||
const ulong ticket,
|
||||
const double profit,
|
||||
const string comment //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Trade State Changed ...
|
||||
*
|
||||
* @param state: XOnTradeHandlerState instance ...
|
||||
*/
|
||||
void OnTradeStateChanged(const XOnTradeHandlerState &state)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// GUI Event Handlers and Helpers ...
|
||||
|
||||
//
|
||||
void HandleBuyTrade()
|
||||
{
|
||||
HandleTrade(X_DIRECTION_BULLISH);
|
||||
}
|
||||
|
||||
//
|
||||
void HandleSellTrade()
|
||||
{
|
||||
HandleTrade(X_DIRECTION_BEARISH);
|
||||
}
|
||||
|
||||
//
|
||||
void HandleTrade(ENUM_X_DIRECTION dir)
|
||||
{
|
||||
//
|
||||
if (!HasDirection(dir))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
string symbol = mChartHelper.Symbol();
|
||||
ENUM_TIMEFRAMES period = mChartHelper.Period();
|
||||
|
||||
//
|
||||
bool isBullish = IsSpecifiedBullish(dir);
|
||||
|
||||
//
|
||||
double r2r = 1.5;
|
||||
double volume = 0.01;
|
||||
double riskInPoints = 100;
|
||||
double point = GetPoints(symbol);
|
||||
double entry = GetEntry(symbol, dir);
|
||||
|
||||
//
|
||||
double risk = riskInPoints * point;
|
||||
double reward = risk * r2r;
|
||||
|
||||
//
|
||||
double sl = isBullish
|
||||
? entry - risk
|
||||
: entry + risk;
|
||||
double tp = isBullish
|
||||
? entry + reward
|
||||
: entry - reward;
|
||||
|
||||
//
|
||||
string comment = ShortName + "_POS_" + ToXString(dir);
|
||||
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
eaTrader.Buy(
|
||||
symbol,
|
||||
period,
|
||||
volume,
|
||||
entry,
|
||||
sl,
|
||||
tp,
|
||||
comment //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
eaTrader.Sell(
|
||||
symbol,
|
||||
period,
|
||||
volume,
|
||||
entry,
|
||||
sl,
|
||||
tp,
|
||||
comment //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void HandleCloseTrade(ulong positionID)
|
||||
{
|
||||
//
|
||||
if (positionID == 0)
|
||||
{
|
||||
//
|
||||
// Force Close All ...
|
||||
Print("Close All Positions ...");
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Close Specified Position ...
|
||||
Print("Close Position: ", positionID);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
ulong ExtractPositionIDFromButtonName(string name)
|
||||
{
|
||||
//
|
||||
ulong result = 0;
|
||||
|
||||
//
|
||||
string nameParts[];
|
||||
int namePartsCount = SplitContent(nameParts, name, "_");
|
||||
bool has = IsValidSize(namePartsCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
string lastPart = nameParts[namePartsCount - 1];
|
||||
StringReplace(lastPart, "_", "");
|
||||
result = (long)lastPart;
|
||||
}
|
||||
|
||||
//
|
||||
SpecifiedClean(nameParts);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void UpdatePositionButtons()
|
||||
{
|
||||
//
|
||||
// Retrieve Positions ...
|
||||
XPosition positions[];
|
||||
int count = eaTrader.GetPositions(
|
||||
positions //
|
||||
);
|
||||
bool has = IsValidSize(count);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
posArray.Clear();
|
||||
selectedPositionID = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
posArray.Clear();
|
||||
|
||||
//
|
||||
// Selected Position ID ...
|
||||
if (selectedPositionID == 0)
|
||||
{
|
||||
//
|
||||
XPosition youngest;
|
||||
int youngestIDX = GetXYoungest(youngest, positions);
|
||||
bool hasYoungest = IsValidIndex(youngestIDX) &&
|
||||
youngest.IsValid();
|
||||
if (hasYoungest)
|
||||
{
|
||||
selectedPositionID = youngest.ticket;
|
||||
}
|
||||
|
||||
//
|
||||
youngest.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
int subWindow = 0;
|
||||
ulong chartId = mChartHelper.ChartId();
|
||||
|
||||
//
|
||||
int btnWidth = 25;
|
||||
|
||||
//
|
||||
int lastX = lblPositionIdSizeX + 5;
|
||||
int lastSizeX = lastX + btnWidth;
|
||||
|
||||
//
|
||||
int lastY = lblPositionIdStartY;
|
||||
int lastSizeY = lblPositionIdSizeY;
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPos = positions[i];
|
||||
|
||||
//
|
||||
string posTypeStr = IsLong(iPos.type)
|
||||
? "LONG"
|
||||
: "SHORT";
|
||||
|
||||
//
|
||||
int iPosBtnX = lastX;
|
||||
int iPosBtnSizeX = iPosBtnX + btnWidth;
|
||||
string iPosBtnName = objSuffix + "_" + posTypeStr + "_POS_SELECT_BTN_" + ToXString(iPos.ticket);
|
||||
|
||||
//
|
||||
CButton *iPosBtn = new CButton();
|
||||
has = iPosBtn.Create(
|
||||
chartId,
|
||||
iPosBtnName,
|
||||
subWindow,
|
||||
iPosBtnX,
|
||||
lastY,
|
||||
iPosBtnSizeX,
|
||||
lastSizeY //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Apply Styles ...
|
||||
string iPosBtnText = ToXString(iPos.ticket);
|
||||
|
||||
//
|
||||
iPosBtn.Text(iPosBtnText);
|
||||
iPosBtn.Color(clrWhite);
|
||||
|
||||
//
|
||||
color iPosBtnBG = IsLong(iPos.type)
|
||||
? clrGreen
|
||||
: clrDarkRed;
|
||||
iPosBtn.ColorBackground(iPosBtnBG);
|
||||
|
||||
//
|
||||
lastX = iPosBtnSizeX + 5;
|
||||
|
||||
//
|
||||
if (selectedPositionID == iPos.ticket)
|
||||
{
|
||||
iPosBtn.Disable();
|
||||
}
|
||||
|
||||
//
|
||||
posArray.Add(iPosBtn);
|
||||
}
|
||||
|
||||
//
|
||||
iPos.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
SpecifiedClean(positions);
|
||||
UpdateGUIState();
|
||||
}
|
||||
|
||||
//
|
||||
void UpdateGUIState()
|
||||
{
|
||||
//
|
||||
// Update States Of Position Select Buttons ...
|
||||
int count = posArray.Total();
|
||||
bool has = IsValidSize(count) && selectedPositionID > 0;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
CButton *iBtn = (CButton *)posArray.At(i);
|
||||
|
||||
//
|
||||
ulong posID = ExtractPositionIDFromButtonName(iBtn.Name());
|
||||
|
||||
//
|
||||
// Select Position ...
|
||||
XPosition iPos;
|
||||
bool hasPosition = eaTrader.GetPosition(
|
||||
posID,
|
||||
iPos //
|
||||
);
|
||||
string iTooltip =
|
||||
!hasPosition
|
||||
? ""
|
||||
: IsLong(iPos.type)
|
||||
? "Long"
|
||||
: "Short";
|
||||
|
||||
//
|
||||
if (posID == selectedPositionID)
|
||||
{
|
||||
//
|
||||
iBtn.Disable();
|
||||
iBtn.ColorBackground(clrDarkGray);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
iBtn.Enable();
|
||||
|
||||
//
|
||||
color iBtnBG = IsLong(iPos.type)
|
||||
? clrGreen
|
||||
: clrDarkRed;
|
||||
|
||||
//
|
||||
iBtn.ColorBackground(iBtnBG);
|
||||
}
|
||||
|
||||
//
|
||||
ZeroMemory(iBtn);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update State of Close All ...
|
||||
if (has && count > 1)
|
||||
{
|
||||
//
|
||||
btnCloseAll.Enable();
|
||||
btnCloseAll.ColorBackground(clrDarkRed);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
btnCloseAll.Disable();
|
||||
btnCloseAll.ColorBackground(clrDarkGray);
|
||||
}
|
||||
|
||||
//
|
||||
// Update State of BtnClose and BtnClose All ...
|
||||
if (selectedPositionID == 0)
|
||||
{
|
||||
//
|
||||
btnClose.Disable();
|
||||
btnClose.ColorBackground(clrDarkGray);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
btnClose.Enable();
|
||||
btnClose.ColorBackground(clrDarkOrange);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user