|
@@ -299,7 +299,7 @@ void writeDataClientCof()
|
|
|
|
|
|
|
|
Print(" Client Closed % = ", closedPercentage);
|
|
Print(" Client Closed % = ", closedPercentage);
|
|
|
|
|
|
|
|
- string OrderToWrite = time+","+symbol+","+IntegerToString(orderType)+","+DoubleToString(PositionGetDouble(POSITION_PRICE_OPEN), (int)digits)+","+DoubleToString(PositionGetDouble(POSITION_VOLUME),2)+","+DoubleToString(stopLoss,(int) digits)+","+DoubleToString(takeProfit, (int) digits)+","+IntegerToString(PositionGetInteger(POSITION_TICKET))+","+IntegerToString(PositionGetInteger(POSITION_MAGIC))+","+(string)AccountInfoDouble(ACCOUNT_BALANCE)+","+DoubleToString(closedPercentage)+","+(string)SymbolInfoDouble(PositionGetString(POSITION_SYMBOL),SYMBOL_TRADE_CONTRACT_SIZE)+PositionGetString(POSITION_COMMENT)+"\r\n";
|
|
|
|
|
|
|
+ string OrderToWrite = time+","+symbol+","+IntegerToString(orderType)+","+DoubleToString(PositionGetDouble(POSITION_PRICE_OPEN), (int)digits)+","+DoubleToString(PositionGetDouble(POSITION_VOLUME),2)+","+DoubleToString(stopLoss,(int) digits)+","+DoubleToString(takeProfit, (int) digits)+","+IntegerToString(PositionGetInteger(POSITION_TICKET))+","+IntegerToString(PositionGetInteger(POSITION_MAGIC))+","+(string)AccountInfoDouble(ACCOUNT_BALANCE)+","+DoubleToString(closedPercentage, 1)+","+(string)SymbolInfoDouble(PositionGetString(POSITION_SYMBOL),SYMBOL_TRADE_CONTRACT_SIZE)+PositionGetString(POSITION_COMMENT)+"\r\n";
|
|
|
|
|
|
|
|
FileWrite(filehandle,OrderToWrite);
|
|
FileWrite(filehandle,OrderToWrite);
|
|
|
}
|
|
}
|
|
@@ -805,7 +805,7 @@ void readData()
|
|
|
totalLot = sumOfClosed + currentLot;
|
|
totalLot = sumOfClosed + currentLot;
|
|
|
|
|
|
|
|
if(totalLot > 0.0)
|
|
if(totalLot > 0.0)
|
|
|
- closedPercentage = (sumOfClosed / totalLot) * 100.0;
|
|
|
|
|
|
|
+ closedPercentage = NormalizeDouble((sumOfClosed / totalLot) * 100.0, 1);
|
|
|
}
|
|
}
|
|
|
//Print(" Magic: ", cod[j].magic, " Ticket: ", order_array[i].ticket, " Master Lot: ", cod[j].masterLot, " Client Lot: ", order_array[i].lots);
|
|
//Print(" Magic: ", cod[j].magic, " Ticket: ", order_array[i].ticket, " Master Lot: ", cod[j].masterLot, " Client Lot: ", order_array[i].lots);
|
|
|
if(cod[j].magic==order_array[i].ticket)
|
|
if(cod[j].magic==order_array[i].ticket)
|
|
@@ -814,8 +814,8 @@ void readData()
|
|
|
{
|
|
{
|
|
|
percentageToClose = MathAbs(order_array[i].closedPercentageOfTrade - closedPercentage);
|
|
percentageToClose = MathAbs(order_array[i].closedPercentageOfTrade - closedPercentage);
|
|
|
//Print(" Cod Lot Size: ", cod[j].masterLot, " Order Array Lot: ", order_array[i].lots);
|
|
//Print(" Cod Lot Size: ", cod[j].masterLot, " Order Array Lot: ", order_array[i].lots);
|
|
|
- Print("Closed % = ", closedPercentage, " Master Ticket Percentage: ", order_array[i].closedPercentageOfTrade);
|
|
|
|
|
- Print("Order is partial close:",cod[j].magic, " Percentage To Be Closed: ", percentageToClose);
|
|
|
|
|
|
|
+ //Print("Closed % = ", closedPercentage, " Master Ticket Percentage: ", order_array[i].closedPercentageOfTrade);
|
|
|
|
|
+ //Print("Order is partial close:",cod[j].magic, " Percentage To Be Closed: ", percentageToClose);
|
|
|
trade_taken=1;
|
|
trade_taken=1;
|
|
|
partialCloseOrderPosition=j;
|
|
partialCloseOrderPosition=j;
|
|
|
}
|
|
}
|
|
@@ -830,8 +830,17 @@ void readData()
|
|
|
if(partialCloseOrderPosition!=-1)
|
|
if(partialCloseOrderPosition!=-1)
|
|
|
{
|
|
{
|
|
|
bool isOrderClose=false;
|
|
bool isOrderClose=false;
|
|
|
- double lotClosePer = NormalizeDouble((totalLot * percentageToClose) / 100,2);
|
|
|
|
|
- if(percentageToClose > 0)
|
|
|
|
|
|
|
+ int roundDigit=0;
|
|
|
|
|
+ double step=SymbolInfoDouble(cod[partialCloseOrderPosition].symbol,SYMBOL_VOLUME_STEP);
|
|
|
|
|
+
|
|
|
|
|
+ while(step<1)
|
|
|
|
|
+ {
|
|
|
|
|
+ roundDigit++;
|
|
|
|
|
+ step=step*10;
|
|
|
|
|
+ }
|
|
|
|
|
+ // Print("Round Digits:", roundDigit);
|
|
|
|
|
+ double lotClosePer = NormalizeDouble((totalLot * percentageToClose) / 100, roundDigit);
|
|
|
|
|
+ if(percentageToClose > 0 && lotClosePer > SymbolInfoDouble(cod[partialCloseOrderPosition].symbol,SYMBOL_VOLUME_MIN))
|
|
|
{
|
|
{
|
|
|
if(!trade.PositionClosePartial(cod[partialCloseOrderPosition].ticket, lotClosePer))
|
|
if(!trade.PositionClosePartial(cod[partialCloseOrderPosition].ticket, lotClosePer))
|
|
|
{
|
|
{
|
|
@@ -1073,7 +1082,35 @@ void readData()
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
trade_close = false;
|
|
trade_close = false;
|
|
|
- if(OrderGetDouble(ORDER_TP)!=order_array[j].takeprofit || OrderGetDouble(ORDER_SL)!=order_array[j].stoploss || OrderGetDouble(ORDER_PRICE_OPEN)!=order_array[j].price)
|
|
|
|
|
|
|
+ int digitss = (int)getDoubleSymbolInfo(PositionGetString(POSITION_SYMBOL), "digits");
|
|
|
|
|
+ if(NormalizeDouble(cod[i].takeprofit, digitss) != NormalizeDouble(order_array[j].takeprofit, digitss))
|
|
|
|
|
+ {
|
|
|
|
|
+ if(NormalizeDouble(order_array[j].takeprofit, digitss) == NormalizeDouble(OrderGetDouble(ORDER_TP), digitss))
|
|
|
|
|
+ {
|
|
|
|
|
+ Print(" Pending Master Position Tp Was Manually Modified. ");
|
|
|
|
|
+ cod[i].takeprofit=NormalizeDouble(order_array[j].takeprofit, digitss);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(NormalizeDouble(cod[i].stoploss, digitss) != NormalizeDouble(order_array[j].stoploss, digitss))
|
|
|
|
|
+ {
|
|
|
|
|
+ if(NormalizeDouble(order_array[j].stoploss, digitss) == NormalizeDouble(OrderGetDouble(ORDER_SL), digitss))
|
|
|
|
|
+ {
|
|
|
|
|
+ Print(" Pending Master Position SL Was Manually Modified. ");
|
|
|
|
|
+ cod[i].stoploss = NormalizeDouble(order_array[j].stoploss, digitss);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(NormalizeDouble(cod[i].price, digitss) != NormalizeDouble(order_array[j].price, digitss))
|
|
|
|
|
+ {
|
|
|
|
|
+ if(NormalizeDouble(order_array[j].price, digitss) == NormalizeDouble(OrderGetDouble(ORDER_PRICE_OPEN), digitss))
|
|
|
|
|
+ {
|
|
|
|
|
+ Print(" Pending Master Position Price Was Manually Modified. ");
|
|
|
|
|
+ cod[i].price = NormalizeDouble(order_array[j].price, digitss);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // if(OrderGetDouble(ORDER_TP)!=order_array[j].takeprofit || OrderGetDouble(ORDER_SL)!=order_array[j].stoploss || OrderGetDouble(ORDER_PRICE_OPEN)!=order_array[j].price)
|
|
|
|
|
+ if(NormalizeDouble(cod[i].takeprofit, digitss) != NormalizeDouble(order_array[j].takeprofit, digitss) || NormalizeDouble(cod[i].stoploss, digitss) != NormalizeDouble(order_array[j].stoploss, digitss) || NormalizeDouble(cod[i].price, digitss) != NormalizeDouble(order_array[j].price, digitss))
|
|
|
{
|
|
{
|
|
|
if(trade.OrderModify(OrderGetInteger(ORDER_TICKET),order_array[j].price,order_array[j].stoploss,order_array[j].takeprofit, 0, 0, 0))
|
|
if(trade.OrderModify(OrderGetInteger(ORDER_TICKET),order_array[j].price,order_array[j].stoploss,order_array[j].takeprofit, 0, 0, 0))
|
|
|
{
|
|
{
|