如何编码? - 页 43

 
jimven:
Flytox:我在TrendStrength的副本中找不到这样的代码。

这是TrendStrength v2.2。

 

自定义价格模式

有没有人知道如何制作一个自定义价格模式?我正在使用以下警报,当价格(extern int PriceMode = 6; //(high+low+close+close)/4)穿越MA时发出信号。我想通过增加一个偏移量来使这个警报自定义,比如说1或2%。这可能吗?就像这样。

extern int PriceMode = (((high+low+close+close)/4)* 1.01

----------------------------------------------------

#property indicator_chart_window

extern int MA1.period =5; //周期5

extern int MA1.shift=0;

extern int MA1.method=2; //SMMA

extern int lMA1.price=2; //MA设置为蜡烛高点

extern int sMA1.price=3; //MA设置为蜡烛的低点

Extern int PriceMode = 6; //(high+low+close+close)/4

int cBar,pBarLong,pBarShort;

int start()

{

cBar = Time[0];

如果(CheckMACross(1)==1 && cBar!=pBarLong ) {EmailAlert(1); pBarLong=cBar; }

否则

如果(CheckMACross(2)==-1 && cBar!=pBarShort) {EmailAlert(2); pBarShort=cBar;}

return(0);

}

int CheckMACross(int mode)

{

if(mode==1) int price = lMA1.price;

否则

if(mode==2) price = sMA1.price;

double price1 = iMA(Symbol(),0,1,0,1, PriceMode,1);

double ma1 = iMA(Symbol(),0,MA1.period,MA1.shift,MA1.method, price,1);

double price0 = iMA(Symbol(),0,1,0,1,PriceMode,0);

double ma0 = iMA(Symbol(),0,MA1.period,MA1.shift,MA1.method, price,0);

if(ma1 > price1 && ma0 <= price0) return( 1);

否则

如果(ma1 = price0)返回(-1)。

否则

返回(0)。

}

{

if(mode == 1) SendMail("Signal for LONG",Symbol()+" Go Long"); //SendMail

否则

if(mode == 2) SendMail("SHORT信号",Symbol()+" Go Short");//SendMail

}

int lastBAlert = 0;

int lastSAlert = 0;

空白EmailAlert(int mode)

{

如果(mode == 2 && lastSAlert < Time[0] )

{

SendMail("Go Short 1",Symbol()+" Go Short 1"); //SendMail

lastSAlert = Time[0];

}

}

 
vonokpasah:
我呼吁外面的专家请来帮助我,我需要一些人帮助我建立一个专家顾问META 4 TRADER,如果我的请求得到批准,我将非常感激。

建立一个专家的方法有很多,你在想什么方法?

 

源代码的帮助!

大家好

我有一个EA,我想给它添加一个输入

如果获利>=:xx,买入:xx手

外部int Deltaopen1 =100。

我写道

如果(type == OP_BUY)

{

如果(M2.BuyCnt == 0 && OrderTakeProfit() > OrderOpenPrice() + Deltaopen1*point)

{

Buy(Symbol(), GetLots2(), Ask, 0, 0, Magic2);

返回。

}

}

如果(type == OP_SELL)

{

如果(M2.SellCnt == 0 && OrderTakeProfit() <= OrderOpenPrice() - Deltaopen1*point)

{

Sell(Symbol(), GetLots2(), Bid, 0, 0, Magic2);

返回。

}

}

}

但它并没有工作。

我感谢任何帮助。

谢谢你的帮助。

 

需要一点帮助来完善这个EA

我有这个EA,它是在本论坛其他地方发现的 "GAPS EA "的一个修改版。

总之,附件是代码的副本。

#property link ""

//---- input parameters

extern int min_gapsize = 1;

extern double lotsize_gap = 5;

extern int MagicNumber = 10;

//----

datetime order_time = 0;

//+------------------------------------------------------------------+

//| expert initialization function |

//+------------------------------------------------------------------+

int init()

{

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

return(0);

}

//+------------------------------------------------------------------+

//| expert start function |

//+------------------------------------------------------------------+

int start()

{

/*

Thing to be done in future in this program to make it more efficient

and more powerful:

1. Make the dicission of the quantity of lots used according to

the scillators;

2. This program will catch the gaps.

Things to ware of:

1. the spread;

2. excuting the order not on the gap ends a little bit less.

*/

// Defining the variables to decide.

Print("order time", order_time);

double current_openprice = iOpen(Symbol(), 0, 0);

double previous_highprice = iHigh(Symbol(), 0, 1);

double previous_lowprice = iLow(Symbol(), 0, 1);

double point_gap = MarketInfo(Symbol(), MODE_POINT);

int spread_gap = MarketInfo(Symbol(), MODE_SPREAD)+1;

datetime current_time = iTime(Symbol(), 0, 0);

// catching the gap on sell upper gap

if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap &&

current_time != order_time)

{

int ticket = OrderSend(Symbol(), OP_SELL, lotsize_gap, Bid, 0, 0,

previous_highprice + spread_gap,

"Gapped Up Sell " + Symbol()+ " " +Period()+ "", MagicNumber, 0, Red);

order_time = iTime(Symbol(), 0, 0);

Print("I am inside (sell) :-)", order_time);

//----

if(ticket < 0)

{

Print("OrderSend failed with error #", GetLastError());

}

}

//catching the gap on buy down gap

if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap &&

current_time != order_time)

{

ticket = OrderSend(Symbol(), OP_BUY, lotsize_gap, Ask, 0, 0,

previous_lowprice - spread_gap,

"Gapped Down Buy " + Symbol()+ " " +Period()+ "", MagicNumber, 0, Green);

order_time = iTime(Symbol(), 0, 0);

Print("I am inside (buy) :-)", order_time);

if(ticket < 0)

{

Print("OrderSend failed with error #", GetLastError());

}

}

//----

return(0);

}

//+------------------------------------------------------------------+

每当我把它放到策略测试器中时,它就不能打开交易。我看了一下日志,发现有大量的订单时间。我做错了什么?

 

帮助。基本直方图问题

这可能真的很简单,我正在寻找过去的东西,但我没有资源,找不到答案。

我所要做的就是回忆之前绘制的直方图条的值。

有什么想法吗?

例如,Close[1]显示的是图表上最后一个关闭的柱形图.....

那么,怎样才能在这个独立的窗口指标上显示最后绘制的直方图柱状图呢?

谢谢你的任何建议。

-尊敬的各位专家

 
dharsant:
这可能真的很简单,我正在寻找过去的东西,但我没有资源,找不到答案。

我所要做的就是调用之前绘制的直方图条的值。

有什么想法吗?

例如,Close[1]显示的是图表上最后一个关闭的条形图.....。

那么,怎样才能在这个独立的窗口指标上显示最后绘制的直方图条呢?

谢谢你的任何建议。

-dharsant

你在调用哪个指标?只要设置移位,就可以调用前一个条形图。

例如,对于当前条形移动平均线。

iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,0)。

对于前一棒的移动平均线。

iMA(NULL,0,13,8,MODE_SMMA,PRICE_MEDIAN,1)。

调用指标时,最后一个参数 表示将读取从当前开始的多少个条。

希望这就是你要找的东西。

 

需要编码帮助

我想在一个EA中使用几个不同的指标,但似乎无法解决如何在系统中实现它们。我应该用指标的哪一部分来表示买入或卖出。我如何将斜率方向线纳入EA的一部分。

欢呼声

贝诺

附加的文件:
 

我可能没有很好地解释我自己。

我想知道我需要在iCustom中输入什么,这就是我的做法。

double SDL=iCustom(NULL,0, "Slope Direction Line",period,method,price)

我需要做的是为我的EA从斜率方向线指标生成买入和卖出信号。以下是我到目前为止所做的,它已经编译,但没有生成任何头寸。

bool Long = TML && SDL && HeikenAshiOpen < HeikenAshiClose && hasOpen < hasClose;

bool Short = TMS && SDL && HeikenAshiOpen > HeikenAshiClose && hasOpen > hasClose;

任何帮助都将是巨大的

欢呼声

贝诺

 

首先,iCustom调用在最后需要两个额外的参数,即从哪个指标缓冲区 读取,以及从哪个索引读取。

其次,"SDL "是一个双数,所以仅仅把 "SDL "作为一个条件显示出一些混乱;可能它被编译为 "SDL != 0",也可能是这个意思。