Update StartRiskCalculator TP and Gold lot calculation

This commit is contained in:
Nkondog Anselme
2022-11-24 11:29:58 +01:00
parent 1466535532
commit beac75708a
16 changed files with 114 additions and 14 deletions
+6 -6
View File
@@ -105,7 +105,7 @@ void OnChartEvent(const int id, // Event identifier
if(id==CHARTEVENT_OBJECT_DRAG)
{
price = ObjectGetDouble(0, sparam, OBJPROP_PRICE, 0);
Print("The anchor point coordinates of the object with name ",sparam," has been changed. Price ", price);
///Print("The anchor point coordinates of the object with name ",sparam," has been changed. Price ", price);
}
if(id==CHARTEVENT_KEYDOWN)
@@ -122,7 +122,7 @@ void OnChartEvent(const int id, // Event identifier
Alert("Sell " + LotSize + " lot " + Symb + " at " + Bid + " SL at " + price);
break;
default:
Print("Do nothing");
//Print("Do nothing");
break;
}
@@ -160,7 +160,7 @@ void LotSizeCalculate(double stopLoss)
{
SL = (stopLoss-PriceBid)/_Point;
}
Print("Stop loss distance ", SL);
//Print("Stop loss distance ", SL);
//If the position size is dynamic
if(InpRiskDefaultSize==RISK_DEFAULT_AUTO)
@@ -180,7 +180,7 @@ void LotSizeCalculate(double stopLoss)
RiskBaseAmount=InpBalance;
//Calculate the Position Size
Print("RiskBaseAmount ", RiskBaseAmount, " MaxRiskPerTrade ", InpMaxRiskPerTrade, "Stop loss ", SL, " TickValue ", TickValue);
//Print("RiskBaseAmount ", RiskBaseAmount, " MaxRiskPerTrade ", InpMaxRiskPerTrade, "Stop loss ", SL, " TickValue ", TickValue);
LotSize=((RiskBaseAmount*InpMaxRiskPerTrade/100)/(SL*TickValue));
StoplossPips = SL;
@@ -200,12 +200,12 @@ void LotSizeCalculate(double stopLoss)
//Limit the lot size in case it is greater than the maximum allowed by the broker
if(LotSize>SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX))
LotSize=SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX);
Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX));
//Print("Lot ", LotSize, " Max lot ", SymbolInfoDouble(Symb,SYMBOL_VOLUME_MAX));
//If the lot size is too small then set it to 0 and don't trade
if(LotSize < SymbolInfoDouble(Symb,SYMBOL_VOLUME_MIN))
{
LotSize=0;
Print("Lot size too small");
Alert("Lot size too small");
}
}
//+------------------------------------------------------------------+