[警告关闭!]任何新手问题,为了不给论坛添乱。专业人士,不要走过。没有你,哪里都不能去。 - 页 863

 
IgorM:

在终端挂断(断电)的情况下,保存重要数据/变量的最佳方法是什么?

- 终端的全局变量? 到一个文件?

- 它们需要多长时间被保存一次?(最后的股权值和一些bools是很重要的)

有什么问题呢,所有的都是一个数组,数组在每次勾选时 都是一个文件,在初始化时读取文件,没有问题。
 

你好!

我不明白为什么我不能修改一个未结头寸,我输入了订单(在订单选择功能中)。

//+------------------------------------------------------------------+
||新闻贸易.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp.
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright"Copyright © 2010, MetaQuotes Software Corp.
#属性链接 "http://www.metaquotes.net"


外部bool In_BUYSTOP=true。
外部intProfit_buy=100。
外来的int StopLoss_buy=5;
外来的双倍Lots_buy=0.01。
//+------------------------------------------------------------------+
外部 bool In_SELLSTOP =true;
外部inttern TakeProfit_sell=100。
外置 int StopLoss_sell =5;
外置双倍Lots_sell =0.01;
extern int LevelProfit = 25; // - 盈利水平,以点为单位,必须达到这个水平才能将其止损点转移到盈亏平衡点。
extern int LevelWLoss = 1; // -Breakeven level in points, which stop position will be moved to after its profit reaches the LevelProfit level in points.

//+------------------------------------------------------------------+
//|专家初始化功能|
//+------------------------------------------------------------------+
int init()
{
//----
int profitbuy=((Bid - OrderOpenPrice())/Point); // BUY
int profitsell=((OrderOpenPrice()- Ask)/Point); // SELL
//----
return(0);
}
//+------------------------------------------------------------------+
//|专家去初始化功能|
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//|专家启动功能|
//+------------------------------------------------------------------+
int start()
//----
{
int票。
如果(Bid>iHigh(NULL,PERIOD_D1,1))
{
如果(OrdersTotal() < 1)
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots_sell,iHigh(NULL,PERIOD_D1,1),3,iHigh(NULL,PERIOD_D1,1)+StopLoss_sell*Point,iHigh(NULL,PERIOD_D1,1)-TakeProfit_sell*Point, Hour() ==21 &&Minute() ==59)
}
如果(Ask<iLow(NULL,PERIOD_D1,1))
{
如果(OrdersTotal() < 1)
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots_buy,iLow(NULL,PERIOD_D1,1),3,iLow(NULL,PERIOD_D1,1)-StopLoss_buy*Point,iLow(NULL,PERIOD_D1,1)+TakeProfit_buy*Point, Hour() ==21 && Minute() ==59)
}
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooso
return(0);
}
//+------------------------------------------------------------------+
如果(OrderSelect(0, SELECT_BY_POS,MODE_TRADES)==true)
{
int order_type=OrderType()。
order_type=OP_SELL。
int profitsell=((OrderOpenPrice()- Ask)/Point)。
If (profitell>5)
ticket=OrderModify(OrderTicket(,OrderOpenPrice(),0,OrderTakeProfit(),0,Blue)。
return(0);
}
如果(OrderSelect(0, SELECT_BY_POS,MODE_TRADES)==true)
{
order_type=OP_BUY;
int profitbuy=((Bid - OrderOpenPrice())/Point)。
如果 (profitbuy>5)
int stopmodify=OrderOpenPrice()。
OrderModify(OrderTicket(),OrderOpenPrice(),stopmodify,OrderTakeProfit(),0,Blue)。
return(0);
}
 

亲爱的开发者,有一个问题要问你。

当从专家顾问中调用该指标时,我无法使该指标的全局变量正确工作。

以下是该指标的代码(只有对理解该问题很重要的字符串)。

double  price;
double  PriceBuffer[];

int init()
{
   SetIndexBuffer(0,PriceBuffer);
   return(0);
}
int start()
{
   int limit, i;
   int counted_bars=IndicatorCounted();
   
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(i=limit-1; i>=0; i--)
   {
        PriceBuffer[i] = price;
        price = iClose(NULL,0,i);
   }
   return(0);
}

在每个条形图中,它都将当前价格保存在全局变量price中,并在下一个条形图中显示。因此,我们应该看到价格图表延迟了一个柱状。如果我们把指标附在图表上,一切都会相当顺利。

但是,如果从EA中调用这个指标并进行视觉测试,我们会在测试结束时看到:这个指标只是与它应该有的东西稍微相似。

如果现在我们在视觉测试图上重新计算该指标(例如,打开和关闭其属性),一切都会恢复正常--我们再次看到第一张图片。

我做错了什么?

我做了一个搜索,但没有找到任何答案。

我使用MT4 4.00版Build 226。

 
我认为这是因为故事中没有足够的虱子。这就是为什么它不见了。在实时的情况下,一切都应该是清楚的!;)
 

你好,请告知代码中哪里不准确,因为当脚本工作时,日志中出现了这样的错误。

15:40:29 11dP_real_symbol EURUSD,H4: <---发现2个正确的图表。--->

15:40:29 11dP_real_symbol EURUSD,H4: <---要看结果,请打开EURUSD,M1002图表--->。

15:40:29 11dP_real_symbol EURUSD,H4: MarketInfo函数的符号名称必须是一个字符串

15:40:29 11dP_real_symbol:FileWriteString函数 的空字符串参数

15:40:29 11dP_real_symbol EURUSD,H4: MarketInfo函数的符号名称必须是一个字符串

15:40:29 11dP_real_symbol EURUSD,H4: <---要看结果,打开图表,M1002 --->

15:40:29 11dP_real_symbol EURUSD,H4: WindowHandle函数的第一个参数必须是一个初始化字符串

15:40:30 11dP_real_symbol EURUSD,H4: WindowHandle函数的第一个参数必须是一个初始化的字符串。

15:40:31 11dP_real_symbol EURUSD,H4: WindowHandle 函数 的第一个参数 必须是一个初始化字符串

我在下面附上了代码本身。

附加的文件:
11dp.mq4  15 kb
 
IgorM:

在终端挂断(断电)的情况下,保存重要数据/变量的最佳方法是什么?

-终端的全局变量? 到一个文件?

- 它们需要多长时间被保存一次?(最后的股权价值和顾问的一些bools是很重要的)


与其他变量不同,GV变量不仅可以从任何程序中创建,还可以被删除。即使客户终端关闭后,GV变量的值仍然保留在计算机的硬盘上。一旦宣布GV变量存在于客户终端,自最后一次呼叫后的4周内。如果在此期间没有程序访问GV变量,GV变量将被客户终端删除。一个GV变量只能是double类型。
 
etroplus:

你好!

我不明白为什么我不能修改一个未结头寸,我输入了订单(在订单选择功能中)。

//+------------------------------------------------------------------+
||新闻贸易.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp.
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp.
#属性链接 "http://www.metaquotes.net"


外部bool In_BUYSTOP=true。
外部intProfit_buy=100。
外来的int StopLoss_buy=5;
外来的双倍Lots_buy=0.01。
//+------------------------------------------------------------------+
外部 bool In_SELLSTOP =true;
外部inttern TakeProfit_sell=100。
外置 int StopLoss_sell =5;
外置双倍Lots_sell =0.01;
extern int LevelProfit = 25; // - 盈利水平,以点为单位,必须达到这个水平才能将其止损点转移到盈亏平衡点。
extern int LevelWLoss = 1; // -Breakeven level in points, which stop position will be moved to after its profit reaches the LevelProfit level in points.

//+------------------------------------------------------------------+
//|专家初始化功能|
//+------------------------------------------------------------------+
int init()
{
//----
int profitbuy=((Bid - OrderOpenPrice())/Point); // BUY是多余的,首先所有变量等于0
int profitsell=((OrderOpenPrice()- Ask)/Point); // SELL
//----
return(0);
}
//+------------------------------------------------------------------+
//|专家去初始化功能|
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//|专家启动功能|
//+------------------------------------------------------------------+
int start()
//----
{
int票。
如果(Bid>iHigh(NULL,PERIOD_D1,1))
{
如果(OrdersTotal() < 1)
ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots_sell,iHigh(NULL,PERIOD_D1,1),3,iHigh(NULL,PERIOD_D1,1)+StopLoss_sell*Point,iHigh(NULL,PERIOD_D1,1)-TakeProfit_sell*Point, Hour() ==21 &&Minute() ==59)
}
如果(Ask<iLow(NULL,PERIOD_D1,1))
{
如果(OrdersTotal() < 1)
ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots_buy,iLow(NULL,PERIOD_D1,1),3,iLow(NULL,PERIOD_D1,1)-StopLoss_buy*Point,iLow(NULL,PERIOD_D1,1)+TakeProfit_buy*Point, Hour() ==21 && Minute() ==59)
}
//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooso
return(0);
}
//+------------------------------------------------------------------+
如果(OrderSelect(0, SELECT_BY_POS,MODE_TRADES)==true)
{
int order_type=OrderType()。
order_type=OP_SELL;//也许如果(order_type==OP_SELL),就需要更多的括号。
int profitsell=((OrderOpenPrice()- Ask)/Point)。
如果(profitell>5)//所以你会尝试每一个tick修改订单吗?
ticket=OrderModify(OrderTicket(,OrderOpenPrice(),0,OrderTakeProfit(),0,Blue)。
return(0);
}
如果(OrderSelect(0, SELECT_BY_POS,MODE_TRADES)==true)
{
order_type=OP_BUY;
int profitbuy=((Bid - OrderOpenPrice())/Point)。
如果 (profitbuy>5)
int stopmodify=OrderOpenPrice()。
OrderModify(OrderTicket(),OrderOpenPrice(),stopmodify,OrderTakeProfit(),0,Blue)。
return(0);
}
 
你好,请告知代码中哪里有不准确的地方,因为在脚本运行时,日志中出现了这样的错误。


15:40:29 11dP_real_symbol EURUSD,H4: <---发现2个正确的图表。--->

15:40:29 11dP_real_symbol EURUSD,H4: <---要看结果,请打开EURUSD,M1002图表--->。

15:40:29 11dP_real_symbol EURUSD,H4: MarketInfo函数的符号名称必须是一个字符串

15:40:29 11dP_real_symbol:FileWriteString函数 的空字符串参数

15:40:29 11dP_real_symbol EURUSD,H4: MarketInfo函数的符号名称必须是一个字符串

15:40:29 11dP_real_symbol EURUSD,H4: <---要看结果,打开图表,M1002 --->

15:40:29 11dP_real_symbol EURUSD,H4: WindowHandle函数的第一个参数必须是一个初始化字符串

15:40:30 11dP_real_symbol EURUSD,H4: WindowHandle函数的第一个参数必须是一个初始化的字符串。

15:40:31 11dP_real_symbol EURUSD,H4: WindowHandle函数的第一个参数必须是一个初始化字符串

我在下面附上自己的代码。
附加的文件:
11dp_1.mq4  15 kb
 

请告诉我 "OP BUY"--预期变量是什么意思?

here while(difference>Span)
(OrderSend(string symbol, OP_BUY, volume, double price, slippage,Bid-stoploss*Point,
Bid+takeprofit*Point, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=Red))

while(0-different>Red)
( OrderSend (string symbol, OP_SELL, volume, double price, slippage,Ask+stoploss*Point,
Ask-takeeprofit*Point, string comment=NULL, string comment=0, int magic=0, datetime expiration=0, color arrow_color=Black) )

 
我如何在mql4的图表上写下一个点? 我需要写下价格和时间,以便它在任何时间段都能保持原样
原因: