最后由 Toomore 于 2024-5-23 20:28 编辑
刚接触EA,做了个手工辅助操盘的小工具,其中便编译版本正常,源码丢了,后面重新搞了一个,把字体加粗了,但是指标不刷新,就是持仓比例数字不实时跳动,源码版本调整了下但是调用数字不正常波动,请哪位高手修改下。适合满屏手工操盘。一眼可以看到资金比例,尤其是短线操作。
- #property copyright "#####"
- #property link "#####"
- #property version "1.00"
- #property strict
- #property indicator_chart_window
-
- extern string wb_name="辅助看盘工具"; // 辅助看盘工具
- extern int wb_x=1900; //面板X轴坐标
- extern int wb_y=360; //面板Y轴坐标
- extern bool wb_jinju=true; //警句区开关
- extern string wb_jinjuinfo1="√控制心态 √集中精力 √顺勢开仓"; //警句1
- extern string wb_jinjuinfo2="√收K开单 √轻仓轻仓 √开仓止损"; //警句2
- extern string wb_jinjuinfo3="√未挪去损 √一单一结 √亏损不加仓"; //警句3
- extern string wb_jinjuinfo4="√亏损不锁仓 √亏损要休息"; //警句4
- extern string wb_jinjuinfo5="√按时睡觉 √按时锻炼 √每日总结"; //警句5
- extern string wb_font_1="Tahoma"; //警句字体类型
- extern int wb_fontsize_1=10; //警句字体大小
- extern color wb_fontcolor_1=clrYellow; //警句字体颜色
- extern string wb_prefix="——————==账户相关==——————"; //分割线
- extern color wb_prefixfontcolor=clrDodgerBlue; //分割线颜色
- extern bool wb_accinfo=true; //账户区开关
- extern string wb_font_2="Tahoma"; //账户字体类型
- extern int wb_fontsize_2=11; //账户字体大小
- extern color wb_fontcolor_2=clrDodgerBlue; //账户字体颜色
- extern string wb_font_3="Tahoma"; //账户值字体类型
- extern int wb_fontsize_3=11; //账户值字体大小
- extern color wb_fontcolor_3=clrRed; //账户值字体颜色
- extern color wb_fontcolor_4=clrLime; //亏损字体颜色
-
-
- int OnInit()
- {
- return(INIT_SUCCEEDED);
- }
-
- void OnDeinit(const int reason)
- {
- ObjectDelete("LabelCreatejinju");
- }
-
- int OnCalculate(const int rates_total,
- const int prev_calculated,
- const datetime &time[],
- const double &open[],
- const double &high[],
- const double &low[],
- const double &close[],
- const long &tick_volume[],
- const long &volume[],
- const int &spread[])
- {
- //---
- LabelCreatejinju(0,0,wb_jinjuinfo1,wb_jinjuinfo1,wb_x,wb_y,wb_font_1,wb_fontsize_1,wb_fontcolor_1,false);
- LabelCreatejinju(0,0,wb_jinjuinfo2,wb_jinjuinfo2,wb_x,wb_y+25,wb_font_1,wb_fontsize_1,wb_fontcolor_1,false);
- LabelCreatejinju(0,0,wb_jinjuinfo3,wb_jinjuinfo3,wb_x,wb_y+50,wb_font_1,wb_fontsize_1,wb_fontcolor_1,false);
- LabelCreatejinju(0,0,wb_jinjuinfo4,wb_jinjuinfo4,wb_x,wb_y+75,wb_font_1,wb_fontsize_1,wb_fontcolor_1,false);
- LabelCreatejinju(0,0,wb_jinjuinfo5,wb_jinjuinfo5,wb_x,wb_y+100,wb_font_1,wb_fontsize_1,wb_fontcolor_1,false);
- LabelCreatejinju(0,0,wb_prefix,wb_prefix,wb_x,wb_y+125,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"账户余额","账户余额:",wb_x,wb_y+150,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"余额",DoubleToStr(AccountInfoDouble(ACCOUNT_BALANCE),2),wb_x+75,wb_y+150,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"信用赠金","信用赠金:",wb_x+135,wb_y+150,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"信用值",DoubleToStr(AccountInfoDouble(ACCOUNT_CREDIT),2),wb_x+210,wb_y+150,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"账户净值","账户净值:",wb_x,wb_y+175,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"账户值",DoubleToStr(AccountInfoDouble(ACCOUNT_EQUITY),2),wb_x+75,wb_y+175,wb_font_3,wb_fontsize_3,wb_fontcolor_3,false);
- LabelCreatejinju(0,0,"可用金额","可用金额:",wb_x+135,wb_y+175,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"可用值",DoubleToStr(AccountInfoDouble(ACCOUNT_FREEMARGIN),2),wb_x+210,wb_y+175,wb_font_3,wb_fontsize_3,wb_fontcolor_3,false);
- LabelCreatejinju(0,0,"爆仓比例","爆仓比例:",wb_x,wb_y+200,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"爆仓值",DoubleToStr(AccountInfoDouble(ACCOUNT_MARGIN_SO_SO),2)+"%",wb_x+75,wb_y+200,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"资金比例","资金比例:",wb_x+135,wb_y+200,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"比例值",DoubleToStr(AccountInfoDouble(ACCOUNT_MARGIN_LEVEL),2)+"%",wb_x+210,wb_y+200,wb_font_3,wb_fontsize_3,wb_fontcolor_3,false);
- LabelCreatejinju(0,0,"平台杠杆","平台杠杆:",wb_x,wb_y+225,wb_font_2,wb_fontsize_2,wb_fontcolor_2,false);
- LabelCreatejinju(0,0,"杠杆值","1:"+DoubleToStr(AccountInfoInteger(ACCOUNT_LEVERAGE),0),wb_x+75,wb_y+225,wb_font_3,wb_fontsize_3,wb_fontcolor_3,false);
- //--- return value of prev_calculated for next call
- return(rates_total);
- }
-
- bool LabelCreatejinju(const long chart_ID=0, // chart's ID
- const int sub_window=0, // subwindow index
- const string name="Label", // label name
- const string text="Label", // text
- const int x=0, // X coordinate
- const int y=0, // Y coordinate
- const string font="Arial", // font
- const int font_size=10, // font size
- const color clr=clrRed, // color
- const bool back=false) // in the background
- {
- //--- reset the error value
- ResetLastError();
- //--- create a text label
- if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
- {
- Print(__FUNCTION__,
- ": failed to create text label! Error code = ",GetLastError());
- return(false);
- }
- //--- set label coordinates
- ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
- ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
- //--- set the text
- ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
- //--- set text font
- ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
- //--- set font size
- ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
- //--- set color
- ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
- //--- display in the foreground (false) or background (true)
- ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
- //--- successful execution
- return(true);
- }
复制代码
|