I can set a grid using the above code but how do I get the Buy Grid and Sell grid grid to trail independently or as a set and retain the separate grid spacing? I have tried all sorts of things and must be missing something obvious. All I get is either all the pending orders move to the same level and then trail as a group or the pending orders start moving up and down with the price action.
[CODE] void TrailingOrders() {
if (Trail.BUYSTOP.Orders && OrderType()==OP_BUYSTOP) {
if (OrderOpenPrice()-Ask>(Trail.BUYSTOP.Orders.Distance)*myPoint) {
I can set a grid using the above code but how do I get the Buy Grid and Sell grid grid to trail independently or as a set and retain the separate grid spacing? I have tried all sorts of things and must be missing something obvious. All I get is either all the pending orders move to the same level and then trail as a group or the pending orders start moving up and down with the price action.
[CODE] void TrailingOrders() {
if (Trail.BUYSTOP.Orders && OrderType()==OP_BUYSTOP) {
if (OrderOpenPrice()-Ask>(Trail.BUYSTOP.Orders.Distance)*myPoint) {
解释起来不那么容易
你必须向离线图表发送一个事件,"告诉 "它(从你的指标)产生了一个新的tick,它应该执行所需的程序。这意味着使用低级别的函数。整个事情可以看起来像这样。
#import "user32.dll"
int GetParent(int hWnd);
#import
#define CHART_CMD_UPDATE_DATA 33324
void UpdateChartWindows()
{
int filePeriod = 1; // file period
string fileSymbol = "your offline symbol name";
string chartName = "your offline symbol chart full name";
string stringForName = " ";
//
//
//
//
//
int windowHandle = WindowHandle(fileSymbol,filePeriod);
if (windowHandle != 0)
{
windowHandle = GetParent(windowHandle);
windowHandle = GetWindow(windowHandle,GW_HWNDFIRST);
while (windowHandle != 0)
{
int len = GetWindowTextA(windowHandle,stringForName,80);
if (len > 0 && StringSubstr(stringForName,0,len) == chartName)
PostMessageA(windowHandle,WM_COMMAND,CHART_CMD_UPDATE_DATA,0);
windowHandle = GetWindow(windowHandle,GW_HWNDNEXT);
}
}
}
谢谢你,我会检查 的。然而,我发现发送命令的问题是正确的。我的指标为离线图表创建了一个非标准的名称,平台因此无法打开它。
谢谢你的耐心解答
好的,脱机图的问题正在工作中。
我还有一个问题。
我必须创建一个指标,用特定的规则来计算交易量。
我需要的是,每当有一个刻度的变化时,该指标必须计算摆动的长度。
例如。
所以它必须计算回调前的所有刻度,但最终返回的值是蜡烛收盘后的最高值。
之后,它必须设置柱状图的颜色,重新分配从缓冲区返回的最高范围的移动。
我以不同的方式尝试,但没有成功。
请帮助我吧^^。
谢谢你
谢谢你们的支持。我正在学习更多的知识,在你们的帮助下,我解决了所有的问题......但是。
我还有一个问题^^。
我需要创建一个空函数 来调用,它必须是这两个代码的合并。
第一个是找到最后的开仓单,第二个是找到开仓价较高的开仓单的数量。
我需要做一个函数,直接找出开盘价最高的订单的数量。
谢谢你
OrderSelect(i, SELECT_BY_POS);
if(OrderSymbol() == Symbol() && OrderType() == TYPE ) {
if(TYPE == OP_BUY) {
double OPrice = OrderOpenPrice();[/PHP]
[PHP]for(int e=0;e<OrdersTotal();e++) {
if(OrderSelect(e,SELECT_BY_POS,MODE_TRADES)==false ) break;
if(OrderSymbol() == Symbol() && OrderType() == TYPE) {
if(TYPE == OP_BUY) {
if(OrderOpenPrice()>test(OP_BUY) Hbuys++;
}
}
}
return(Hbuys);
}
谢谢你们的支持。我学到了更多,在你们的帮助下,我解决了所有的问题......但是。
我有另一个问题^^。
我需要创建一个无效函数来调用,它必须是这两个代码的合并。
第一个是找到最后一个开仓单,第二个是找到开仓价较高的开仓单的数量。
我需要做一个函数来直接找出开盘价最高的订单的数量。
谢谢你
OrderSelect(i, SELECT_BY_POS);
if(OrderSymbol() == Symbol() && OrderType() == TYPE ) {
if(TYPE == OP_BUY) {
double OPrice = OrderOpenPrice();[/PHP]
if(OrderSelect(e,SELECT_BY_POS,MODE_TRADES)==false ) break;
if(OrderSymbol() == Symbol() && OrderType() == TYPE) {
if(TYPE == OP_BUY) {
if(OrderOpenPrice()>test(OP_BUY) Hbuys++;
}
}
}
return(Hbuys);
}
我在第二段代码中犯了一个错误。是这样的
[PHP]for(int e=0;e<OrdersTotal();e++) {
if(OrderSelect(e,SELECT_BY_POS,MODE_TRADES)==false) break;
如果(OrderSymbol() == Symbol() && OrderType() == TYPE) {
如果(TYPE == OP_BUY) {
如果(OrderOpenPrice()>OPrice Hbuys++;
}
}
}
return(Hbuys);
}
大司马
void函数 是一个不返回任何值的函数。如果是这样的话,那么唯一合理的方法就是使用一些将通过引用传递给函数的变量(根据我的经验,为此目的使用全局范围的变量是一种非常糟糕的做法--它避免了结构化的编码规则,而且,在必须寻找错误的情况下,使用这种变量是一场噩梦)。这就是你所想的吗?
我在第二个代码上做了一个错误。这是对的
if(OrderSelect(e,SELECT_BY_POS,MODE_TRADES)==false ) break;
if(OrderSymbol() == Symbol() && OrderType() == TYPE) {
if(TYPE == OP_BUY) {
if(OrderOpenPrice()>OPrice Hbuys++;
}
}
}
return(Hbuys);
}
dasio void函数是一个不返回任何值的函数。如果是这样的话,那么唯一合理的方法就是使用一些将通过引用传递给函数的变量(根据我的经验,为此目的使用全局范围的变量是一个非常糟糕的做法--它避免了结构化的编码规则,而且,在需要寻找错误的情况下,使用这样的变量是一个噩梦)。这就是你所想的吗?
谢谢你的回答。
我只需要在最后一次买入时,有最高开仓单和最低开仓单的买入数量。
我必须使用moltiplier的结果进入vois函数 进行一些检查。
这样,当要求时,就可以更简单地调用这个记录。也许以这种方式,我可以简单地调用它 CalculateCurrentBuy(Symbol())
int Hopen=0;
for(int i=0;i<OrdersTotal();i++) {
code here
}
}
return(Hopen);
}
追踪网格?
{
if(Set.SELLSTOP && s.ticketP==0){
OrderSend(Symbol(),OP_SELLSTOP,Sell.Lots+i*Sell.Multiplier,Ask-i*(Trail.SELLSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}
if(Set.BUYSTOP && b.ticketP==0){
OrderSend(Symbol(),OP_BUYSTOP,Buy.Lots+i*Buy.Multiplier,Bid+i*(Trail.BUYSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}
}[/CODE]
I can set a grid using the above code but how do I get the Buy Grid and Sell grid grid to trail independently or as a set and retain the separate grid spacing? I have tried all sorts of things and must be missing something obvious. All I get is either all the pending orders move to the same level and then trail as a group or the pending orders start moving up and down with the price action.![](https://c.mql5.com/forextsd/smiles/confused_smile.png)
[CODE] void TrailingOrders() {
if (Trail.BUYSTOP.Orders && OrderType()==OP_BUYSTOP) {
if (OrderOpenPrice()-Ask>(Trail.BUYSTOP.Orders.Distance)*myPoint) {
OrderModify(OrderTicket(),Ask+OrderOpenPrice()+(Trail.BUYSTOP.Orders.Distance)*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Aqua);
}
}
if (Trail.SELLSTOP.Orders && OrderType()==OP_SELLSTOP) {
if (Bid-OrderOpenPrice()>(Trail.SELLSTOP.Orders.Distance)*myPoint) {
OrderModify(OrderTicket(),Bid-OrderOpenPrice()-(Trail.SELLSTOP.Orders.Distance)*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Yellow);
}
}
}这段代码可以跟踪2个订单,但我怎样才能修改它以跟踪更多的订单?只要我试图将跟踪代码设置为多级,如上面的网格代码,就会变成奶油蛋糕。
如有任何见解,敬请关注。
谢谢你,CJA
...
cja
我用下面的代码试了一下,效果不错(见示例图:已经应用了不同的步骤)。
我不知道s.ticketP和b.ticketP这两个变量有什么作用,所以按照代码中的方式使用。
extern double Trail.BUYSTOP.Orders.Distance = 20;
extern int Stop.Order.Levels = 4;
extern double Sell.Lots = 0.1;
extern double Sell.Multiplier = 0.1;
extern double Buy.Lots = 0.1;
extern double Buy.Multiplier = 0.2;
extern bool Set.SELLSTOP = true;
extern bool Set.BUYSTOP = true;
int init()
{
return(0);
}
int start()
{
double myPoint=1; if (Digits==3 || Digits==5) myPoint=10; myPoint *= Point;
static int s.ticketP=0;
static int b.ticketP=0;
for(int i = 1; i < Stop.Order.Levels+1; i++)
{
if(Set.SELLSTOP && s.ticketP==0){ OrderSend(Symbol(),OP_SELLSTOP,Sell.Lots+i*Sell.Multiplier,Bid-i*(Trail.SELLSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}
if(Set.BUYSTOP && b.ticketP==0){ OrderSend(Symbol(),OP_BUYSTOP ,Buy.Lots+i *Buy.Multiplier ,Ask+i*(Trail.BUYSTOP.Orders.Distance)*myPoint ,0,0,0,0,0,0,CLR_NONE);}
}
s.ticketP=Stop.Order.Levels;
b.ticketP=Stop.Order.Levels;
return(0);
}
{
if(Set.SELLSTOP && s.ticketP==0){
OrderSend(Symbol(),OP_SELLSTOP,Sell.Lots+i*Sell.Multiplier,Ask-i*(Trail.SELLSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}
if(Set.BUYSTOP && b.ticketP==0){
OrderSend(Symbol(),OP_BUYSTOP,Buy.Lots+i*Buy.Multiplier,Bid+i*(Trail.BUYSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}
}[/CODE]
I can set a grid using the above code but how do I get the Buy Grid and Sell grid grid to trail independently or as a set and retain the separate grid spacing? I have tried all sorts of things and must be missing something obvious. All I get is either all the pending orders move to the same level and then trail as a group or the pending orders start moving up and down with the price action.![](https://c.mql5.com/forextsd/smiles/confused_smile.png)
[CODE] void TrailingOrders() {
if (Trail.BUYSTOP.Orders && OrderType()==OP_BUYSTOP) {
if (OrderOpenPrice()-Ask>(Trail.BUYSTOP.Orders.Distance)*myPoint) {
OrderModify(OrderTicket(),Ask+OrderOpenPrice()+(Trail.BUYSTOP.Orders.Distance)*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Aqua);
}
}
if (Trail.SELLSTOP.Orders && OrderType()==OP_SELLSTOP) {
if (Bid-OrderOpenPrice()>(Trail.SELLSTOP.Orders.Distance)*myPoint) {
OrderModify(OrderTicket(),Bid-OrderOpenPrice()-(Trail.SELLSTOP.Orders.Distance)*myPoint,OrderStopLoss(),OrderTakeProfit(), 0, Yellow);
}
}
}这段代码可以跟踪两个订单,但我如何修改它以跟踪更多的订单?当我试图将跟踪代码设置为多级,如上面的网格代码,它就变成了奶油蛋糕。
如有任何见解,敬请关注。
注意:CJA拖曳式网格
cja
我用下面的代码试了一下,效果不错(见例图:已经应用了不同的步骤)。
我不知道s.ticketP和b.ticketP这两个变量有什么用,所以按照代码中的方式使用。
extern double Trail.BUYSTOP.Orders.Distance = 20;
extern int Stop.Order.Levels = 4;
extern double Sell.Lots = 0.1;
extern double Sell.Multiplier = 0.1;
extern double Buy.Lots = 0.1;
extern double Buy.Multiplier = 0.2;
extern bool Set.SELLSTOP = true;
extern bool Set.BUYSTOP = true;
int init()
{
return(0);
}
int start()
{
double myPoint=1; if (Digits==3 || Digits==5) myPoint=10; myPoint *= Point;
static int s.ticketP=0;
static int b.ticketP=0;
for(int i = 1; i < Stop.Order.Levels+1; i++)
{
if(Set.SELLSTOP && s.ticketP==0){ OrderSend(Symbol(),OP_SELLSTOP,Sell.Lots+i*Sell.Multiplier,Bid-i*(Trail.SELLSTOP.Orders.Distance)*myPoint,0,0,0,0,0,0,CLR_NONE);}
if(Set.BUYSTOP && b.ticketP==0){ OrderSend(Symbol(),OP_BUYSTOP ,Buy.Lots+i *Buy.Multiplier ,Ask+i*(Trail.BUYSTOP.Orders.Distance)*myPoint ,0,0,0,0,0,0,CLR_NONE);}
}
s.ticketP=Stop.Order.Levels;
b.ticketP=Stop.Order.Levels;
return(0);
}
嗨,mladen。
谢谢你的帮助,但是我在上面的帖子里可能没有说清楚。我没有设置网格的问题,我的问题是在不丢失订单分离的情况下拖动网格。
s.ticketP和b.ticketP只是指EA中其他地方使用的BUYSTOP和SELLSTOP挂单 代码。
注意:CJA
拖曳式网格
你好,mladen。
谢谢你的帮助,但是我在上面的帖子中可能没有说得很清楚。我没有设置网格的问题,我的问题是在不丢失订单分离的情况下跟踪网格。
s.ticketP和b.ticketP只是指EA中其他地方使用的BUYSTOP和SELLSTOP挂单代码。
Regards CJA你好mladen。
有时间看一下这个吗?
![](https://c.mql5.com/forextsd/smiles/regular_smile.png)
友好的问候 CJA