208 lines
No EOL
17 KiB
Text
208 lines
No EOL
17 KiB
Text
// ボタンは、EA名か□ボタンの二種類選んでコピペ
|
|
|
|
|
|
// ビジュアルモード切替ボタン
|
|
bool VisualMode;
|
|
|
|
int OnInit()
|
|
{
|
|
//+------------------------------------------------------------------+
|
|
// チャート自動変更・シンボル・チャートコメント・状態表示
|
|
if (!IsTesting())
|
|
{
|
|
ChartSet(); // チャート自動変更
|
|
CenterSymbol(); // 中央のシンボル
|
|
ChartComment(); // チャートコメント
|
|
EA_test(); // 状態表示
|
|
EventSetTimer(60); // 状態表示
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
// トレード履歴をチャートに表示(ライン・pips)
|
|
history();
|
|
PosHis();
|
|
//+------------------------------------------------------------------+(□ボタンの場合)
|
|
// ビジュアルモード切り替えボタン作成
|
|
Button("Visual", "", 22, 26, clrLimeGreen, 1);
|
|
{
|
|
ObjectSetInteger(0, "Visual", OBJPROP_STATE, true);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_BORDER_COLOR, clrSilver);
|
|
VisualMode = true;
|
|
}
|
|
//+------------------------------------------------------------------+(EA名の場合)
|
|
// ビジュアルモード切り替えボタン作成
|
|
Button("Visual", WindowExpertName(), StringLen(WindowExpertName()) * 12, 0, CHART_COLOR_BACKGROUND, 1);
|
|
{
|
|
ObjectSetInteger(0, "Visual", OBJPROP_STATE, true);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_BORDER_COLOR, clrGray);
|
|
VisualMode = true;
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
}
|
|
|
|
void OnTick()
|
|
{
|
|
// 注文より後に記載
|
|
//+------------------------------------------------------------------+
|
|
// チャート自動変更・シンボル・チャートコメント・状態表示
|
|
if (!IsTesting() && VisualMode)
|
|
{
|
|
CenterSymbol(); // センターにシンボル情報
|
|
ChartComment(); // チャートコメント
|
|
CT++; // 状態表示用
|
|
EA_test(); // 状態表示用
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
// チャートにトレード線とpips表示
|
|
if ((IsTesting() == false || IsVisualMode() == true) && VisualMode)
|
|
{
|
|
if (sf != Seconds() && OrdersTotal() > 0)
|
|
{
|
|
PosHis();
|
|
sf = Seconds();
|
|
}
|
|
|
|
if ((hf != iTime((string)0, 60, 0) && Seconds() > 30) || tof != OrdersHistoryTotal())
|
|
{
|
|
history();
|
|
hf = iTime((string)0, 60, 0);
|
|
tof = OrdersHistoryTotal();
|
|
}
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| ビジュアルモード切替ボタン |
|
|
//+------------------------------------------------------------------+
|
|
void OnChartEvent(const int id, //イベントID
|
|
const long &lparam, //long型イベント
|
|
const double &dparam, //double型イベント
|
|
const string &sparam) //string型イベント
|
|
{
|
|
if(id == CHARTEVENT_OBJECT_CLICK)
|
|
{
|
|
if(ObjectGetInteger(0,"Visual",OBJPROP_STATE) == true)
|
|
{
|
|
if(sparam == "Visual")
|
|
{
|
|
VisualMode = true;
|
|
history();
|
|
PosHis();
|
|
Button("Visual", "", 22, 26, clrLimeGreen, 1);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_STATE, true);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_BORDER_COLOR, clrSilver);
|
|
EA_label ("Now Loading...", clrWhite);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
VisualMode = false;
|
|
ObjectsDeleteAll();
|
|
Button("Visual", "", 22, 26, clrWhite, 1);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_STATE, false);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_BORDER_COLOR, clrSilver);
|
|
ChartComment();
|
|
for(int i=2; i<=9; i++)
|
|
{
|
|
ObjectDelete(0,"ComObj"+(string)i);
|
|
}
|
|
EA_label ("Status display OFF", clrWhite);
|
|
}
|
|
}
|
|
}
|
|
//| ボタン仕様
|
|
void Button(string name, string text, int x, int y ,color clr, int a)
|
|
{
|
|
x = (int)NormalizeDouble(x * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
y = (int)NormalizeDouble(y * DPIAdjust, 0); // 別途DPI換算コードで調整
|
|
|
|
ObjectCreate(0,name,OBJ_BUTTON,ChartWindowFind(),0,0); // ボタンの作成をする(この段階ではデザインや場所が指定されていない枠だけのボタン
|
|
ObjectSetInteger(0,name,OBJPROP_COLOR,clrWhite); // ボタンの文字色を設定する
|
|
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false); // ボタンを選択して移動したり消したりしないようにするための設定
|
|
ObjectSetInteger(0,name,OBJPROP_HIDDEN,true); // ボタンがオブジェクトのリストに表示されないようにするための設定
|
|
ObjectSetString (0,name,OBJPROP_TEXT,text); // ボタンに表示するテキストを設定する
|
|
ObjectSetString (0,name,OBJPROP_FONT,"Segoe UI"); // ボタンの文字のフォントを設定する
|
|
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,8); // ボタンの文字サイズを設定する
|
|
ObjectSetInteger(0,name,OBJPROP_CORNER,a); // ボタンの基準位置をきめる(右上・左上・左下・右下)
|
|
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x); // ボタンの基準位置からのX座標を設定
|
|
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y); // ボタンの基準位置からのY座標を設定
|
|
ObjectSetInteger(0,name,OBJPROP_XSIZE,18); // ボタンの横幅の設定
|
|
ObjectSetInteger(0,name,OBJPROP_YSIZE,16); // ボタンの縦幅の設定
|
|
ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clr); // ボタンの色の設定
|
|
//ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,clrGray); // ボタンの枠線の色を設定 基本的にはボタン色と一緒で問題なくて、枠線を付けたい時だけ別にする
|
|
//ObjectSetInteger(0,name,OBJPROP_STATE,false); // ボタンの状態を設定(押されている状態か、押されていない状態か) 最初は押されていない状態で大丈夫
|
|
ObjectSetInteger(0,name,OBJPROP_BACK,false); // オブジェクトの背景表示設定
|
|
//ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| ビジュアルモード切替ボタン(EA表示名アレンジ) |
|
|
//+------------------------------------------------------------------+
|
|
void OnChartEvent(const int id, //イベントID
|
|
const long &lparam, //long型イベント
|
|
const double &dparam, //double型イベント
|
|
const string &sparam) //string型イベント
|
|
{
|
|
int xx = StringLen(WindowExpertName()) * 12;
|
|
|
|
if(id == CHARTEVENT_OBJECT_CLICK)
|
|
{
|
|
if(ObjectGetInteger(0,"Visual",OBJPROP_STATE) == true)
|
|
{
|
|
if(sparam == "Visual")
|
|
{
|
|
VisualMode = true;
|
|
history();
|
|
PosHis();
|
|
Button("Visual", WindowExpertName(), xx, 0, CHART_COLOR_BACKGROUND, 1);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_STATE, true);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_BORDER_COLOR, clrGray);
|
|
EA_label ("状態ロード中...", clrWhite);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
VisualMode = false;
|
|
ObjectsDeleteAll();
|
|
Button("Visual", WindowExpertName(), xx, 0, CHART_COLOR_BACKGROUND, 1);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_STATE, false);
|
|
ObjectSetInteger(0, "Visual", OBJPROP_BORDER_COLOR, clrSilver);
|
|
ChartComment();
|
|
for(int i=2; i<=15; i++)
|
|
{
|
|
ObjectDelete(0,"ComObj"+(string)i);
|
|
}
|
|
EA_label ("状態表示OFF", clrWhite);
|
|
}
|
|
}
|
|
}
|
|
//| ボタン仕様
|
|
void Button(string name, string text, int x, int y ,color clr, int a)
|
|
{
|
|
int xx = StringLen(WindowExpertName()) * 12 - 26;
|
|
|
|
ObjectCreate(0,name,OBJ_BUTTON,ChartWindowFind(),0,0); // ボタンの作成をする(この段階ではデザインや場所が指定されていない枠だけのボタン
|
|
ObjectSetInteger(0,name,OBJPROP_COLOR,clrWhite); // ボタンの文字色を設定する
|
|
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false); // ボタンを選択して移動したり消したりしないようにするための設定
|
|
ObjectSetInteger(0,name,OBJPROP_HIDDEN,true); // ボタンがオブジェクトのリストに表示されないようにするための設定
|
|
ObjectSetString (0,name,OBJPROP_TEXT,text); // ボタンに表示するテキストを設定する
|
|
ObjectSetString (0,name,OBJPROP_FONT,"Segoe UI"); // ボタンの文字のフォントを設定する
|
|
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,8); // ボタンの文字サイズを設定する
|
|
ObjectSetInteger(0,name,OBJPROP_CORNER,a); // ボタンの基準位置をきめる(右上・左上・左下・右下)
|
|
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x); // ボタンの基準位置からのX座標を設定
|
|
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y); // ボタンの基準位置からのY座標を設定
|
|
ObjectSetInteger(0,name,OBJPROP_XSIZE,xx); // ボタンの横幅の設定
|
|
ObjectSetInteger(0,name,OBJPROP_YSIZE,24); // ボタンの縦幅の設定
|
|
ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clr); // ボタンの色の設定
|
|
//ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,clrGray); // ボタンの枠線の色を設定 基本的にはボタン色と一緒で問題なくて、枠線を付けたい時だけ別にする
|
|
//ObjectSetInteger(0,name,OBJPROP_STATE,false); // ボタンの状態を設定(押されている状態か、押されていない状態か) 最初は押されていない状態で大丈夫
|
|
ObjectSetInteger(0,name,OBJPROP_BACK,false); // オブジェクトの背景表示設定
|
|
//ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
|
|
ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
|
|
}
|
|
//+------------------------------------------------------------------+ |