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
-1
View File
@@ -265,4 +265,3 @@ void CheckSpread()
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
Binary file not shown.
Binary file not shown.
Binary file not shown.
+50
View File
@@ -0,0 +1,50 @@
//+------------------------------------------------------------------+
//| NewCandleAlert.mq5 |
//| Copyright 2022, Nkondog Anselme Venceslas. |
//| https://www.linkedin.com/in/nkondog |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Nkondog Anselme Venceslas."
#property link "https://www.linkedin.com/in/nkondog"
#property version "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
newBar();
}
//+------------------------------------------------------------------+
bool newBar()
{
static datetime prevTime = 0;
datetime currentTime = iTime(Symbol(), PERIOD_CURRENT, 0);
if(currentTime != prevTime)
{
prevTime = currentTime;
Alert("New candle");
return(true);
}
return(false);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
+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");
}
}
//+------------------------------------------------------------------+
BIN
View File
Binary file not shown.
+6 -6
View File
@@ -95,7 +95,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);
displayOnChart();
}
@@ -113,7 +113,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;
}
@@ -151,7 +151,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)
@@ -171,7 +171,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;
@@ -191,12 +191,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");
//Print("Lot size too small");
}
}
//+------------------------------------------------------------------+
Binary file not shown.
+51
View File
@@ -0,0 +1,51 @@
//+------------------------------------------------------------------+
//| NewCandleAlert.mq4 |
//| Copyright 2022, Nkondog Anselme Venceslas. |
//| https://www.linkedin.com/in/nkondog |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Nkondog Anselme Venceslas."
#property link "https://www.linkedin.com/in/nkondog"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
newBar();
}
//+------------------------------------------------------------------+
bool newBar()
{
static datetime prevTime = 0;
datetime currentTime = iTime(Symbol(), PERIOD_CURRENT, 0);
if(currentTime != prevTime)
{
prevTime = currentTime;
Alert("New candle");
return(true);
}
return(false);
}
+1 -1
View File
@@ -1 +1 @@
New-Item -ItemType Junction -Path "C:\Users\Nkondog\AppData\Roaming\MetaQuotes\Terminal\10CE948A1DFC9A8C27E56E827008EBD4\MQL5\Experts\Nkanven" -Target "D:\ITprojects\sat_bot\Experts\Nkanven"
New-Item -ItemType Junction -Path "C:\Users\Nkondog\AppData\Roaming\MetaQuotes\Terminal\E3E3B02889D32F38295D39BF94B6AD4A\MQL5\Include\Nkanven" -Target "D:\ITprojects\sat_bot\Include\Nkanven"