- 2010-01-31 (日) 2:03
- 未分類
MetaTrader4 に、クリック証券FXの履歴を表示するインジケーター。
表示項目
チャート上に矢印 新規:斜め矢印。決済:上下矢印。
通算の最高/最低時 損益。
表示中ペアと全通貨通算の、
約定回数、約定数量、損益、手数料、スワップ、入出金
等を表示します。
準備
インジケーターを
クリック証券のWebサイトからダウンロードしたFXの履歴(
ファイルの名前を変える場合は、設定にあるファイル名も変えて下さい。
期間指定は入れていませんので、ダウンロードした
例えば、20090101-20091231 のファイルをダウンロードして、
設定にあるファイル名も
MT4のサーバーによって時間が違う為、
取引履歴の矢印がずれると思いますので、
パラメーターにあるtimediffを変更してください。
RecordViewClickFX.mq4
タグ: MetaTrader4
同じタグの投稿
表示項目
チャート上に矢印 新規:斜め矢印。決済:上下矢印。
通算の最高/最低時 損益。
表示中ペアと全通貨通算の、
約定回数、約定数量、損益、手数料、スワップ、入出金
等を表示します。
準備
インジケーターを
MetaTrader 4\experts\indicators フォルダにクリック証券のWebサイトからダウンロードしたFXの履歴(
torihikiFX.csv)をMetaTrader 4\experts\files フォルダに入れます。ファイルの名前を変える場合は、設定にあるファイル名も変えて下さい。
期間指定は入れていませんので、ダウンロードした
torihikiFX.csv の全てが計算されます。(ただし、1行目は項目名として125バイト分スキップします。
torihikiFX.csv の1行目にある項目名は、変更せずそのままにしておいてください。)
例えば、20090101-20091231 のファイルをダウンロードして、
torihikiFX2009.csv とした場合、設定にあるファイル名も
torihikiFX2009.csvと変更して下さい。MT4のサーバーによって時間が違う為、
取引履歴の矢印がずれると思いますので、
パラメーターにあるtimediffを変更してください。
RecordViewClickFX.mq4
以下、MQL4のソースコードです。
//+------------------------------------------------------------------+
//| RecordViewClickFX.mq4 |
//| http://kirock.net |
//+------------------------------------------------------------------+
#property copyright "kirock.net"
#property link "http://kirock.net"
#property indicator_chart_window
extern string File="torihikiFX.csv";
extern color newL_color= Yellow;
extern color CloseL_color= White;
extern color newS_color= Red;
extern color CloseS_color= Pink;
extern int timediff=8;
extern bool ShowPL=true;
color PL_Color;
extern int Window=0;
extern int Corner=3;
extern int x = 5;
extern int y = 0;
extern string Font_Family = "Meiryo";
extern int Font_Size=13;
extern color Lost_FontColer=Pink;
extern color Income_FontColer=White;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
string date;//入出金日
int timediffok = timediff*3600;
int handle;
string PositionNum;//建玉番号
string OderNum;//注文番号
string Pair;//通貨ペア
string BS;//売買
int ExeVol;//約定数量
int Commision;//取引手数料
string neworclose;
double price;
double EntryRate;
int ptime;
string jtime;
string pentry;
int Swap;
int profitloss;
int inout;
string tab;
int handle0;
int Commisionalltotal;
int PL;//損益
int OtherPL;//他通貨の損益
int SymbolSwap;//スワップ
int OtherSwap;//他通貨のスワップ
int SymbolCommision;
int OtherCommision;
int SymbolVol;//合計取引数量
int OtherVol;//合計取引数量
int Count=0;//通貨別約定回数
int OtherCount=0;//全通貨約定回数
int deposit;
int withdrawal;
int HPL;
string HPLdate;
int LPL;
string LPLdate;
handle=FileOpen(File, FILE_CSV, ',');
handle0=FileOpen("NumList", FILE_CSV|FILE_WRITE, ';');
if(handle>0)
{
FileSeek(handle, 125, SEEK_CUR); //2行目まで移動(バイト数)
while(!FileIsEnding(handle)){
date=FileReadString(handle);
jtime=FileReadString(handle);
ptime=StrToTime(jtime)-timediffok;
PositionNum=FileReadString(handle);
OderNum=FileReadString(handle);
Pair=FileReadString(handle);
Pair=StringConcatenate(StringSubstr(Pair, 0, 3),StringSubstr(Pair, 4, 3));// /を削除
neworclose=FileReadString(handle);
BS=FileReadString(handle);
ExeVol=FileReadNumber(handle)/10000;
price=FileReadNumber(handle);
Commision=FileReadNumber(handle);
EntryRate=FileReadNumber(handle);
Swap=FileReadNumber(handle);
profitloss=FileReadNumber(handle);
inout=FileReadNumber(handle);
//
if(inout!=0){deposit=deposit+inout;}
if(Symbol()!=Pair){
if(neworclose=="新規"||neworclose=="決済"){OtherCount++;}
OtherPL=OtherPL+profitloss;
OtherSwap=OtherSwap+Swap;
OtherCommision=OtherCommision+Commision;
OtherVol=OtherVol+ExeVol;
}
else if(Symbol()==Pair){
if(neworclose=="新規"||neworclose=="決済"){Count++;}
PL=PL+profitloss;
SymbolSwap=SymbolSwap+Swap;
SymbolCommision=SymbolCommision+Commision;
SymbolVol=SymbolVol+ExeVol;
FileWrite(handle0,OderNum);
ObjectCreate(OderNum, OBJ_ARROW, 0,ptime, price);
if(BS=="買"&&neworclose=="決済"){
ObjectSet(OderNum, OBJPROP_COLOR,CloseS_color);
ObjectSet(OderNum, OBJPROP_ARROWCODE,233);
ObjectSetText( OderNum,jtime+"\n"+neworclose+" "+BS+" "+ExeVol+" lots "+"\n損益"+profitloss+" 円"+"\n建レート\n"+EntryRate+"\n"+PositionNum);
}else if(BS=="売"&&neworclose=="決済"){
ObjectSet(OderNum, OBJPROP_COLOR,CloseL_color);
ObjectSet(OderNum, OBJPROP_ARROWCODE,234);
ObjectSetText( OderNum,jtime+"\n"+neworclose+" "+BS+" "+ExeVol+" lots "+"\n損益"+profitloss+" 円"+"\n建レート\n"+EntryRate+"\n"+PositionNum);
}
if(BS=="買"&&neworclose=="新規"){
ObjectSet(OderNum, OBJPROP_COLOR,newL_color);
ObjectSet(OderNum, OBJPROP_ARROWCODE,236);
ObjectSetText( OderNum,jtime+"\n"+neworclose+" "+BS+"\n"+ExeVol+" lots"+"\n約定レート\n"+price+"\n");
}else if(BS=="売"&&neworclose=="新規"){
ObjectSet(OderNum, OBJPROP_COLOR,newS_color);
ObjectSet(OderNum, OBJPROP_ARROWCODE,238);
ObjectSetText( OderNum,jtime+"\n"+neworclose+" "+BS+"\n"+ExeVol+" lots"+"\n約定レート\n"+price+"\n");
}
}
if(HPL<(OtherPL+PL+SymbolSwap+OtherSwap+SymbolCommision+OtherCommision)){
HPLdate=jtime;
HPL=(OtherPL+PL+SymbolSwap+OtherSwap+SymbolCommision+OtherCommision);
}
if(LPL>(OtherPL+PL+SymbolSwap+OtherSwap+SymbolCommision+OtherCommision)){
LPLdate=jtime;
LPL=(OtherPL+PL+SymbolSwap+OtherSwap+SymbolCommision+OtherCommision);
}
}
FileClose(handle0);
FileClose(handle);
}
if(ShowPL){
ObjectCreate("deposit and withdrawal", OBJ_LABEL, Window, 0, 0);
if(deposit>0){PL_Color=Lost_FontColer;}else{PL_Color=Income_FontColer;}
ObjectSetText("deposit and withdrawal","入出金 \\"+deposit,Font_Size, Font_Family, PL_Color);
ObjectSet("deposit and withdrawal", OBJPROP_CORNER,Corner);
ObjectSet("deposit and withdrawal", OBJPROP_XDISTANCE, x);
ObjectSet("deposit and withdrawal", OBJPROP_YDISTANCE, Font_Size+y);
ObjectCreate("OtherPL", OBJ_LABEL, Window, 0, 0);//全通貨通算損益
if((OtherPL+PL+SymbolSwap+OtherSwap+SymbolCommision+OtherCommision)<0){PL_Color=Lost_FontColer;}else{PL_Color=Income_FontColer;}
ObjectSetText("OtherPL","全ペア確定損益 \\"+(OtherPL+PL+SymbolSwap+OtherSwap+SymbolCommision+OtherCommision),Font_Size, Font_Family, PL_Color);
ObjectSet("OtherPL", OBJPROP_CORNER,Corner);
ObjectSet("OtherPL", OBJPROP_XDISTANCE, x);
ObjectSet("OtherPL", OBJPROP_YDISTANCE, Font_Size*3+y);
ObjectCreate("TotalSwap", OBJ_LABEL, Window, 0, 0);
if((SymbolSwap+OtherSwap)<0){PL_Color=Lost_FontColer;}else{PL_Color=Income_FontColer;}
ObjectSetText("TotalSwap","全ペア合計スワップ \\"+(SymbolSwap+OtherSwap),Font_Size, Font_Family, PL_Color);
ObjectSet("TotalSwap", OBJPROP_CORNER,Corner);
ObjectSet("TotalSwap", OBJPROP_XDISTANCE, x);
ObjectSet("TotalSwap", OBJPROP_YDISTANCE, Font_Size*5+y);
ObjectCreate("TotalCommision", OBJ_LABEL,Window, 0, 0);
if((SymbolCommision+OtherCommision)<0){PL_Color=Lost_FontColer;}else{PL_Color=Income_FontColer;}
ObjectSetText("TotalCommision","全ペア合計手数料 \\"+(SymbolCommision+OtherCommision),Font_Size, Font_Family, PL_Color);
ObjectSet("TotalCommision", OBJPROP_CORNER,Corner);
ObjectSet("TotalCommision", OBJPROP_XDISTANCE, x);
ObjectSet("TotalCommision", OBJPROP_YDISTANCE, Font_Size*7+y);
ObjectCreate("SymbolCommision", OBJ_LABEL, Window, 0, 0);
if(SymbolCommision<0){PL_Color=Lost_FontColer;}else{PL_Color=Income_FontColer;}
ObjectSetText("SymbolCommision","手数料 \\"+SymbolCommision,Font_Size, Font_Family, PL_Color);
ObjectSet("SymbolCommision", OBJPROP_CORNER,Corner);
ObjectSet("SymbolCommision", OBJPROP_XDISTANCE, x);
ObjectSet("SymbolCommision", OBJPROP_YDISTANCE, Font_Size*9+y);
ObjectCreate("SymbolSwap", OBJ_LABEL, Window, 0, 0);
if(SymbolSwap<0){PL_Color=Lost_FontColer;}else{PL_Color=Income_FontColer;}
ObjectSetText("SymbolSwap","スワップ \\"+(SymbolSwap),Font_Size, Font_Family, PL_Color);
ObjectSet("SymbolSwap", OBJPROP_CORNER,Corner);
ObjectSet("SymbolSwap", OBJPROP_XDISTANCE, x);
ObjectSet("SymbolSwap", OBJPROP_YDISTANCE, Font_Size*11+y);
ObjectCreate("profitloss", OBJ_LABEL, Window, 0, 0);
if((PL+SymbolSwap+SymbolCommision)<0){PL_Color=Lost_FontColer;}else{PL_Color=Income_FontColer;}
ObjectSetText("profitloss",Symbol()+"確定損益 \\"+(PL+SymbolSwap+SymbolCommision),Font_Size, Font_Family, PL_Color);
ObjectSet("profitloss", OBJPROP_CORNER,Corner);
ObjectSet("profitloss", OBJPROP_XDISTANCE, x);
ObjectSet("profitloss", OBJPROP_YDISTANCE,Font_Size*13+y);
ObjectCreate("TotalVol", OBJ_LABEL, Window, 0, 0);
ObjectSetText("TotalVol","Lots ("+Symbol()+"/合計) "+SymbolVol+" / "+(SymbolVol+OtherVol),Font_Size, Font_Family, White);
ObjectSet("TotalVol", OBJPROP_CORNER,Corner);
ObjectSet("TotalVol", OBJPROP_XDISTANCE, x);
ObjectSet("TotalVol", OBJPROP_YDISTANCE,Font_Size*15+y);
ObjectCreate("Count", OBJ_LABEL, Window, 0, 0);
ObjectSetText("Count","約定回数 "+"("+Symbol()+"/合計) "+Count+" / "+(OtherCount+Count),Font_Size, Font_Family, White);
ObjectSet("Count", OBJPROP_CORNER,Corner);
ObjectSet("Count", OBJPROP_XDISTANCE, x);
ObjectSet("Count", OBJPROP_YDISTANCE,Font_Size*17+y);
ObjectCreate("HPL", OBJ_LABEL, Window, 0, 0);
ObjectSetText("HPL","口座最高 "+HPLdate+" \\"+HPL,Font_Size, Font_Family, Income_FontColer);
ObjectSet("HPL", OBJPROP_CORNER,Corner);
ObjectSet("HPL", OBJPROP_XDISTANCE, x);
ObjectSet("HPL", OBJPROP_YDISTANCE,Font_Size*19+y);
ObjectCreate("LPL", OBJ_LABEL, Window, 0, 0);
ObjectSetText("LPL","口座最低 "+LPLdate+" \\"+LPL,Font_Size, Font_Family, Lost_FontColer);
ObjectSet("LPL", OBJPROP_CORNER,Corner);
ObjectSet("LPL", OBJPROP_XDISTANCE, x);
ObjectSet("LPL", OBJPROP_YDISTANCE,Font_Size*21+y);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
int handle1;
string OderNum1;
handle1=FileOpen("NumList", FILE_CSV, ';');
if(handle1>0){
while(!FileIsEnding(handle1)){
OderNum1=FileReadString(handle1);
ObjectDelete(OderNum1);
}
}
FileClose(handle1);
ObjectDelete("deposit and withdrawal");
ObjectDelete("OtherPL");
ObjectDelete("TotalCommision");
ObjectDelete("TotalSwap");
ObjectDelete("SymbolCommision");
ObjectDelete("SymbolSwap");
ObjectDelete("profitloss");
ObjectDelete("TotalVol");
ObjectDelete("Count");
ObjectDelete("HPL");
ObjectDelete("LPL");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
タグ: MetaTrader4
同じタグの投稿
- Newer: Zenphoto mod_rewrite 設定
- Older: MetaTrader4 テンプレートチェンジャー
コメント:0
トラックバック:0
- このエントリーのトラックバックURL
- http://kirock.net/article/mt4_recordview/trackback/
- Listed below are links to weblogs that reference
- MetaTrader4 履歴表示 インジケーター from 記録係の記録帳