287 lines
No EOL
30 KiB
Text
287 lines
No EOL
30 KiB
Text
int OnInit()
|
|
{
|
|
// シンボル・チャートコメント・状態表示
|
|
if (!IsTesting())
|
|
{
|
|
//CenterSymbol(); // 別途センターシンボルを利用する場合は、チャートコメントより先に記載。でないとシンボルがコメントより手前に表示される。
|
|
ChartComment();
|
|
}
|
|
}
|
|
|
|
void OnTick()
|
|
{
|
|
// チャートコメント・状態表示
|
|
if (!IsTesting())
|
|
{
|
|
ChartComment(); // チャートコメント
|
|
}
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| チャートコメント表示 |
|
|
//+------------------------------------------------------------------+
|
|
void ChartComment()
|
|
{
|
|
// 状態によって色変更
|
|
color clrChartWar = ChartWarning >= 2? clrNONE : clrWhite;
|
|
color clrChartWarPP = ChartWarning >= 2? clrNONE : totalpips < 0? clrOrangeRed : clrWhite;
|
|
color clrChartWarPF = ChartWarning >= 2? clrNONE : 0 < ProfitFactor && ProfitFactor < 1? clrOrangeRed : clrWhite;
|
|
|
|
string LotsComment;
|
|
if (MM_ON == Fixed) LotsComment = DoubleToStr(Lots,2);
|
|
else LotsComment = DoubleToStr(CalculateLots(MM_Risk, StopLoss_pips),2) +
|
|
" (" + DoubleToStr(MM_Risk,1) +"%)";
|
|
|
|
string Comment0 = "Magic : " + (string)MagicNumber;
|
|
string Comment1 = "Lots : " + LotsComment;
|
|
string Comment2 = "MM : " + (MM_ON == 0 ? "Fixed" : MM_ON == 1 ? "FreeMargin" : MM_ON == 2 ? "Balance" : "AddCredit");
|
|
string Comment3 = "Summertime : " + (Summertime == 0 ? "none" : Summertime == 1 ? "US" : "UK");
|
|
string Comment4 = "Spread Lim/Ave : " + DoubleToStr(MaxSpread_pips,1) + "/" + DoubleToStr(SpreadAve,1);
|
|
string Comment5 = "Stoploss B/S : " + DoubleToStr(StopLoss_pips_buy, 0) + "/" + DoubleToStr(StopLoss_pips_sell, 0);
|
|
string Comment6 = "Swap B/S : " + DoubleToStr(MarketInfo(Symbol(),MODE_SWAPLONG), 2) + "/" +
|
|
DoubleToStr(MarketInfo(Symbol(),MODE_SWAPSHORT), 2);
|
|
string Comment7 = "TradeCounts : " + DoubleToStr(TradeCounts, 0);
|
|
string Comment8 = "Profit (pips) : " + DoubleToStr(totalpips, 1);
|
|
string Comment9 = (plus_profit == 0 || minus_profit == 0? "Profit factor : ---" :
|
|
"Profit factor : " + DoubleToStr(ProfitFactor, 2));
|
|
string Comment10 = (plus_profit == 0 || minus_profit == 0? "RRR/Win% : ---/---" :
|
|
"RRR/Win% : " + DoubleToStr(RRR, 2) + "/" + DoubleToStr(WinPer, 1));
|
|
|
|
|
|
CommentLabel("ComObj0", Comment0, 4, 38, 10, clrYellow);
|
|
CommentLabel("ComObj1", Comment1, 4, 58, 10, clrYellow);
|
|
CommentLabel("ComObj2", Comment2, 6, 82, 8, clrChartWar);
|
|
CommentLabel("ComObj3", Comment3, 6, 100, 8, clrChartWar);
|
|
CommentLabel("ComObj4", Comment4, 6, 118, 8, clrChartWar);
|
|
CommentLabel("ComObj5", Comment5, 6, 136, 8, clrChartWarPP);
|
|
CommentLabel("ComObj6", Comment6, 6, 154, 8, clrChartWarPF);
|
|
CommentLabel("ComObj7", Comment7, 6, 172, 8, clrChartWar);
|
|
CommentLabel("ComObj8", Comment8, 6, 190, 8, clrChartWar);
|
|
CommentLabel("ComObj9", Comment9, 6, 208, 8, clrChartWar);
|
|
CommentLabel("ComObj10", Comment10, 6, 226, 8, clrChartWar);
|
|
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
void CommentLabel(string ComName, string ComText, int ComPos_x, int ComPos_y, int ComSize, color ComClr= clrBlack)
|
|
{
|
|
ComPos_x = (int)NormalizeDouble(ComPos_x * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
ComPos_y = (int)NormalizeDouble(ComPos_y * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
|
|
ObjectCreate(ComName, OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetString (0, ComName, OBJPROP_TEXT, ComText);
|
|
ObjectSetInteger(0, ComName, OBJPROP_XDISTANCE, ComPos_x);
|
|
ObjectSetInteger(0, ComName, OBJPROP_YDISTANCE, ComPos_y);
|
|
ObjectSetInteger(0, ComName, OBJPROP_FONTSIZE, ComSize);
|
|
ObjectSetInteger(0, ComName, OBJPROP_COLOR, ComClr);
|
|
ObjectSetString (0, ComName, OBJPROP_FONT, "Segoe UI");
|
|
ObjectSetInteger(0, ComName, OBJPROP_BACK, true);
|
|
ObjectSetInteger(0, ComName, OBJPROP_SELECTABLE, false);
|
|
ObjectSetInteger(0, ComName, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0, ComName, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
|
|
// バリエーション
|
|
|
|
//オーダーコメント用
|
|
//+------------------------------------------------------------------+
|
|
//| チャートコメント表示 |
|
|
//+------------------------------------------------------------------+
|
|
void ChartComment()
|
|
{
|
|
color clrChartWar = ChartWarning >= 2? clrNONE : clrWhite;
|
|
color clrChartWarPP = ChartWarning >= 2? clrNONE : totalpips < 0? clrOrangeRed : clrWhite;
|
|
color clrChartWarPF = ChartWarning >= 2? clrNONE : 0 < ProfitFactor && ProfitFactor < 1? clrOrangeRed : clrWhite;
|
|
color clrChartWarCom = (_Comment == "" || StringLen(_Comment) > 31) ? clrOrangeRed : clrChartWar;
|
|
|
|
string LotsComment;
|
|
if (MM_ON == Fixed) LotsComment = DoubleToStr(Lots,2);
|
|
else LotsComment = DoubleToStr(CalculateLots(MM_Risk, StopLoss_pips),2) +
|
|
" (" + DoubleToStr(MM_Risk,1) +"%)";
|
|
|
|
string Comment0 = "Magic : " + (string)MagicNumber;
|
|
string Comment1 = "Lots : " + LotsComment;
|
|
string Comment2 = "MM : " + (MM_ON == 0 ? "Fixed" : MM_ON == 1 ? "FreeMargin" : MM_ON == 2 ? "Balance" : "AddCredit");
|
|
//string Comment3 = "Summertime : " + (Summertime == 0 ? "none" : Summertime == 1 ? "US" : "UK");
|
|
string Comment3 = "Stoploss B/S : " + DoubleToStr(StopLoss_pips_buy, 0) + "/" + DoubleToStr(StopLoss_pips_sell, 0);
|
|
string Comment4 = "Swap B/S : " + DoubleToStr(MarketInfo(Symbol(),MODE_SWAPLONG), 2) + "/" +
|
|
DoubleToStr(MarketInfo(Symbol(),MODE_SWAPSHORT), 2);
|
|
string Comment5 = "Spread Lim/Ave : " + DoubleToStr(MaxSpread_pips,1) + "/" + DoubleToStr(SpreadAve,1);
|
|
string Comment6 = "TradeCounts : " + DoubleToStr(TradeCounts, 0);
|
|
string Comment7 = "Profit (pips) : " + DoubleToStr(totalpips, 1);
|
|
string Comment8 = (plus_profit == 0 || minus_profit == 0? "Profit factor : ---" :
|
|
"Profit factor : " + DoubleToStr(ProfitFactor, 2));
|
|
string Comment9 = (plus_profit == 0 || minus_profit == 0? "RRR/Win% : ---/---" :
|
|
"RRR/Win% : " + DoubleToStr(RRR, 2) + "/" + DoubleToStr(WinPer, 1));
|
|
string Comment10 = "[OrderComment]";
|
|
string Comment11 = _Comment;
|
|
|
|
CommentLabel("ComObj0", Comment0, 4, 38, 10, clrYellow);
|
|
CommentLabel("ComObj1", Comment1, 4, 58, 10, clrYellow);
|
|
CommentLabel("ComObj2", Comment2, 6, 82, 8, clrChartWar);
|
|
CommentLabel("ComObj3", Comment3, 6, 100, 8, clrChartWar);
|
|
CommentLabel("ComObj4", Comment4, 6, 118, 8, clrChartWar);
|
|
CommentLabel("ComObj5", Comment5, 6, 136, 8, clrChartWar);
|
|
CommentLabel("ComObj6", Comment6, 6, 154, 8, clrChartWar);
|
|
CommentLabel("ComObj7", Comment7, 6, 172, 8, clrChartWarPP);
|
|
CommentLabel("ComObj8", Comment8, 6, 190, 8, clrChartWarPF);
|
|
CommentLabel("ComObj9", Comment9, 6, 208, 8, clrChartWar);
|
|
CommentLabel("ComObj10", Comment10, 6, 226, 8, clrChartWarCom);
|
|
CommentLabel("ComObj11", Comment11, 6, 248, 6, clrChartWar);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
void CommentLabel(string ComName, string ComText, int ComPos_x, int ComPos_y, int ComSize, color ComClr= clrBlack)
|
|
{
|
|
ComName = ComName;
|
|
ObjectCreate(ComName, OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetString (0, ComName, OBJPROP_TEXT, ComText);
|
|
ObjectSetInteger(0, ComName, OBJPROP_XDISTANCE, ComPos_x);
|
|
ObjectSetInteger(0, ComName, OBJPROP_YDISTANCE, ComPos_y);
|
|
ObjectSetInteger(0, ComName, OBJPROP_FONTSIZE, ComSize);
|
|
ObjectSetInteger(0, ComName, OBJPROP_COLOR, ComClr);
|
|
ObjectSetString (0, ComName, OBJPROP_FONT, "Segoe UI");
|
|
ObjectSetInteger(0, ComName, OBJPROP_BACK, true);
|
|
ObjectSetInteger(0, ComName, OBJPROP_SELECTABLE, false);
|
|
ObjectSetInteger(0, ComName, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0, ComName, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
|
|
//ロジック別設定用
|
|
//+------------------------------------------------------------------+
|
|
//| チャートコメント表示 |
|
|
//+------------------------------------------------------------------+
|
|
void ChartComment()
|
|
{
|
|
color clrChartWar = ChartWarning >= 2? clrNONE : clrWhite;
|
|
color clrChartWarPP = ChartWarning >= 2? clrNONE : totalpips < 0? clrOrangeRed : clrWhite;
|
|
color clrChartWarPF = ChartWarning >= 2? clrNONE : 0 < ProfitFactor && ProfitFactor < 1? clrOrangeRed : clrWhite;
|
|
|
|
string LotsComment;
|
|
if (MM_ON == Fixed) LotsComment = DoubleToStr(Lots,2);
|
|
else LotsComment = DoubleToStr(CalculateLots(MM_Risk, StopLoss_pips),2) +
|
|
" (" + DoubleToStr(MM_Risk,1) +"%)";
|
|
|
|
string Comment0 = "Magic : " + (string)MagicNumber;
|
|
string Comment1 = "Lots : " + LotsComment;
|
|
string Comment2 = "MM : " + (MM_ON == 0 ? "Fixed" : MM_ON == 1 ? "FreeMargin" : MM_ON == 2 ? "Balance" : "AddCredit");
|
|
string Comment3 = "Summertime : " + (Summertime == 0 ? "none" : Summertime == 1 ? "US" : "UK");
|
|
string Comment4 = "Slippage log : " + (string)Measurement;
|
|
string Comment5 = "Spread Lim/Ave : " + DoubleToStr(MaxSpread_pips,1) + "/" + DoubleToStr(SpreadAve,1);
|
|
string Comment6 = "Profit (pips) : " + DoubleToStr(totalpips, 1);
|
|
string Comment7 = (plus_profit == 0 || minus_profit == 0? "Profit factor : ---" : "Profit factor : " + DoubleToStr(ProfitFactor, 2));
|
|
string Comment8 = "------------------------------";
|
|
string Comment9 = "Logic_Buy1: " + (string)Logic_Buy1;
|
|
string Comment10 = "TP/SL: " + DoubleToStr(TakeProfit_pips_Buy1,0) + "/" + DoubleToStr(StopLoss_pips_Buy1,0);
|
|
string Comment11 = "Modify: " + (string)Modify_Buy1;
|
|
string Comment12 = "Logic_Buy2: " + (string)Logic_Buy2;
|
|
string Comment13 = "TP/SL: " + DoubleToStr(TakeProfit_pips_Buy1,0) + "/" + DoubleToStr(StopLoss_pips_Buy1,0);
|
|
string Comment14 = "Logic_Sell1: " + (string)Logic_Sell1;
|
|
string Comment15 = "TP/SL: " + DoubleToStr(TakeProfit_pips_Sell1,0) + "/" + DoubleToStr(StopLoss_pips_Sell1,0);
|
|
string Comment16 = "Logic_Sell2: " + (string)Logic_Sell2;
|
|
string Comment17 = "TP/SL: " + DoubleToStr(TakeProfit_pips_Sell2,0) + "/" + DoubleToStr(StopLoss_pips_Sell2,0);
|
|
string Comment18 = "------------------------------";
|
|
|
|
|
|
CommentLabel("ComObj0", Comment0, 4, 38, 10, clrYellow);
|
|
CommentLabel("ComObj1", Comment1, 4, 58, 10, clrYellow);
|
|
CommentLabel("ComObj2", Comment2, 6, 82, 8, clrChartWar);
|
|
CommentLabel("ComObj3", Comment3, 6, 100, 8, clrChartWar);
|
|
CommentLabel("ComObj4", Comment4, 6, 118, 8, clrChartWar);
|
|
CommentLabel("ComObj5", Comment5, 6, 136, 8, clrChartWar);
|
|
CommentLabel("ComObj6", Comment6, 6, 154, 8, clrChartWarPP);
|
|
CommentLabel("ComObj7", Comment7, 6, 172, 8, clrChartWarPF);
|
|
CommentLabel("ComObj8", Comment8, 6, 186, 8, clrChartWar);
|
|
CommentLabel("ComObj9", Comment9, 6, 200, 8, clrChartWar);
|
|
CommentLabel("ComObj10", Comment10, 6, 218, 8, clrChartWar);
|
|
CommentLabel("ComObj11", Comment11, 6, 236, 8, clrChartWar);
|
|
CommentLabel("ComObj12", Comment12, 6, 254, 8, clrChartWar);
|
|
CommentLabel("ComObj13", Comment13, 6, 272, 8, clrChartWar);
|
|
CommentLabel("ComObj14", Comment14, 6, 290, 8, clrChartWar);
|
|
CommentLabel("ComObj15", Comment15, 6, 308, 8, clrChartWar);
|
|
CommentLabel("ComObj16", Comment16, 6, 326, 8, clrChartWar);
|
|
CommentLabel("ComObj17", Comment17, 6, 344, 8, clrChartWar);
|
|
CommentLabel("ComObj18", Comment18, 6, 358, 8, clrChartWar);
|
|
|
|
}
|
|
// チャートコメントの仕様
|
|
void CommentLabel(string ComName, string ComText, int ComPos_x, int ComPos_y, int ComSize, color ComClr= clrBlack)
|
|
{
|
|
ObjectCreate(ComName, OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetString (0, ComName, OBJPROP_TEXT, ComText);
|
|
ObjectSetInteger(0, ComName, OBJPROP_XDISTANCE, ComPos_x);
|
|
ObjectSetInteger(0, ComName, OBJPROP_YDISTANCE, ComPos_y);
|
|
ObjectSetInteger(0, ComName, OBJPROP_FONTSIZE, ComSize);
|
|
ObjectSetInteger(0, ComName, OBJPROP_COLOR, ComClr);
|
|
ObjectSetString (0, ComName, OBJPROP_FONT, "Segoe UI");
|
|
ObjectSetInteger(0, ComName, OBJPROP_BACK, true);
|
|
ObjectSetInteger(0, ComName, OBJPROP_SELECTABLE, false);
|
|
ObjectSetInteger(0, ComName, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0, ComName, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| チャートコメント表示 |
|
|
//+------------------------------------------------------------------+
|
|
void ChartComment()
|
|
{
|
|
string LotsComment;
|
|
if (MM_ON == Fixed) LotsComment = DoubleToStr(Lots,2);
|
|
else LotsComment = DoubleToStr(CalculateLots(MM_Risk, StopLoss_pips),2) +
|
|
" (" + DoubleToStr(MM_Risk,1) +"%)";
|
|
|
|
string Comment0 = "Magic : " + (string)MagicNumber;
|
|
string Comment1 = "Lots : " + LotsComment;
|
|
string Comment2 = "MM : " + (MM_ON == 0 ? "Fixed" : MM_ON == 1 ? "FreeMargin" : MM_ON == 2 ? "Balance" : "AddCredit");
|
|
string Comment3 = "Summertime : " + (Summertime == 0 ? "none" : Summertime == 1 ? "US" : "UK");
|
|
string Comment4 = "Spread Limit/Ave : " + DoubleToStr(MaxSpread_pips,1) + "/" + DoubleToStr(SpreadAve,1);
|
|
string Comment5 = "Stoploss B/S : " + DoubleToStr(StopLoss_pips_buy, 0) + "/" + DoubleToStr(StopLoss_pips_sell, 0);
|
|
string Comment6 = "Swap B/S : " + DoubleToStr(MarketInfo(Symbol(),MODE_SWAPLONG), 2) + "/" +
|
|
DoubleToStr(MarketInfo(Symbol(),MODE_SWAPSHORT), 2);
|
|
|
|
CommentLabel("ComObj0", Comment0, 4, 38, 10, clrYellow);
|
|
CommentLabel("ComObj1", Comment1, 4, 58, 10, clrYellow);
|
|
CommentLabel("ComObj2", Comment2, 6, 82, 8, clrWhite);
|
|
CommentLabel("ComObj3", Comment3, 6, 100, 8, clrWhite);
|
|
CommentLabel("ComObj4", Comment4, 6, 118, 8, clrWhite);
|
|
CommentLabel("ComObj5", Comment5, 6, 172, 8, clrWhite);
|
|
CommentLabel("ComObj6", Comment6, 6, 190, 8, clrWhite);
|
|
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
void CommentLabel(string ComName, string ComText, int ComPos_x, int ComPos_y, int ComSize, color ComClr= clrBlack)
|
|
{
|
|
ComName = ComName;
|
|
ObjectCreate(ComName, OBJ_LABEL, 0, 0, 0);
|
|
ObjectSetString (0, ComName, OBJPROP_TEXT, ComText);
|
|
ObjectSetInteger(0, ComName, OBJPROP_XDISTANCE, ComPos_x);
|
|
ObjectSetInteger(0, ComName, OBJPROP_YDISTANCE, ComPos_y);
|
|
ObjectSetInteger(0, ComName, OBJPROP_FONTSIZE, ComSize);
|
|
ObjectSetInteger(0, ComName, OBJPROP_COLOR, ComClr);
|
|
ObjectSetString (0, ComName, OBJPROP_FONT, "Segoe UI");
|
|
ObjectSetInteger(0, ComName, OBJPROP_BACK, true);
|
|
ObjectSetInteger(0, ComName, OBJPROP_SELECTABLE, false);
|
|
ObjectSetInteger(0, ComName, OBJPROP_CORNER, CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0, ComName, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER);
|
|
}
|
|
//+------------------------------------------------------------------+ |