编码帮助 - 页 405

 
Tomcat98:
嗨,Mladen。

下面是那些Multi_Indic_00是振荡器,Up_Prime_00是定义水平的挂单的循环内容。

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

//---- 如果订单类型为限价且趋势已改变,则检查并关闭。

如果(OrderType()==OP_BUYLIMIT)

如果(( Multi_Indic_00 ) <= (Up_Prime_00 ))

{

_OrderDelete=OrderDelete(OrderTicket() )。

}

如果(OrderType()==OP_SELLLIMIT)

如果(( Multi_Indic_00 ) >= ( Down_Prime_00 ))

{

_OrderDelete=OrderDelete(OrderTicket())。

}

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

好了,没有什么特别的....

交易愉快。

真诚的。

Tomcat98

Tomcat98

我希望看到的是for()循环语句。如果你有一个像这样的for语句:

for (int i = 0; i < OrdersTotal(); i++)

那么一些订单将被遗漏,如果在这段时间内一些订单被关闭或删除。另一方面,如果for()的循环是这样的。

for (int i = OrdersTotal()-1; i >= 0; i--)

那么它将处理所有的订单

 

姆拉登,

哦,我明白了。

这里是它的关闭过程。

"

for(int i=0;i<OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

如果(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) 继续。

"

Tomcat98

 
Tomcat98:
Mladen ,

哦,我明白了。

这里是它的关闭过程。

"

for(int i=0;i<OrdersTotal();i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

如果(OrderMagicNumber()!=MAGIC || OrderSymbol()!=Symbol()) 继续。

"

Tomcat98

Tomcat98

将循环改为

for(int i=OrdersTotal()-1;i>=0;i--)

它应该是确定的

 

姆拉登。

中奖了!

现在它完全满足了我的需要。

非常感谢你的巨大帮助。

"人们并不关心你知道多少,直到他们知道你有多关心"

- 西奥多-罗斯福

真诚的。

Tomcat98

 
Tomcat98:
Mladen,

中奖了!

现在它完全满足了我的需要。

非常感谢你的巨大帮助。

"人们并不关心你知道多少,直到他们知道你有多关心"

- 西奥多-罗斯福

真诚的。

Tomcat98

快乐编码

 

嗨,Mladen,谢谢你做的一切,现在工作得很好......

现在我被一个不能重新加载的指标困住了,所以每次蜡烛收盘我都要重新加载这个指标,你能帮我解决这个问题吗? 这里是部分代码(是一个基于差距的简单想法的趋势指标,谢谢。

#property copyright "Copyright © 2014 Daniel Luchinger"

#property link

#property strict

#property strict

#属性 indicator_chart_window

#perty indicator_buffers 4

#perty indicator_color1 clrLime

#属性 indicator_color2 clrRed

#属性 indicator_color3 clrMagenta

#属性 indicator_color4 clrCyan

#define BUY 1

#define SELL 2

双重Buy[]。

卖出[]。

FirstBuy[],

FirstSell[]。

int OnInit() {

SetIndexBuffer(0,FirstBuy);

SetIndexBuffer(1,FirstSell);

SetIndexBuffer(2,Buy);

SetIndexBuffer(3,Sell)。

for(int i=0; i<4; i++) {

SetIndexStyle (i,DRAW_ARROW,STYLE_SOLID,2); }

SetIndexArrow (0,233);

SetIndexArrow (1,234);

SetIndexArrow (2,233);

SetIndexArrow (3,234)。

返回(INIT_SUCCEEDED);}

void OnDeinit(const int reason){}。

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[]) {

static int lastSignal=0;

for(int i=MathMin(rate_total-prev_calculated, rates_total-1); i>=0; i--){

FirstBuy=FirstSell=Buy=Sell=EMPTY_VALUE。

datetime when=Time;

if((High-Close)<0){

if(lastSignal==SELL) {

FirstBuy=Close;

SoundAlert(when, "Buy");}。

lastSignal=BUY;}

如果((Low-Close)>0){

如果(lastSignal==BUY) {

FirstSell=Close;

SoundAlert(when, "Sell"); }

lastSignal=SELL;}

}

return(rate_total);}

void SoundAlert(datetime i, string dir) {

static datetime lastAlert=0。

如果(lastAlert!=i) {

Alert(StringFormat("%s signal on %s at %s",dir,Symbol(),TimeToStr(i))。

 
daniel1983:
嗨,Mladen,谢谢你做的一切,现在工作得很好......

现在我被一个不能重新加载的指标困住了,所以每次蜡烛收盘我都要重新加载这个指标,你能帮我解决这个问题吗? 这里是部分代码(是一个基于差距的简单想法的趋势指标,谢谢你。

#property copyright "Copyright © 2014 Daniel Luchinger"

#property link

#property strict

#property strict

#属性 indicator_chart_window

#perty indicator_buffers 4

#perty indicator_color1 clrLime

#属性 indicator_color2 clrRed

#属性 indicator_color3 clrMagenta

#属性 indicator_color4 clrCyan

#define BUY 1

#define SELL 2

双重Buy[]。

卖出[]。

FirstBuy[],

FirstSell[]。

int OnInit() {

SetIndexBuffer(0,FirstBuy);

SetIndexBuffer(1,FirstSell);

SetIndexBuffer(2,Buy);

SetIndexBuffer(3,Sell)。

for(int i=0; i<4; i++) {

SetIndexStyle (i,DRAW_ARROW,STYLE_SOLID,2); }

SetIndexArrow (0,233);

SetIndexArrow (1,234);

SetIndexArrow (2,233);

SetIndexArrow (3,234)。

返回(INIT_SUCCEEDED);}

void OnDeinit(const int reason){}。

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[]) {

static int lastSignal=0;

for(int i=MathMin(rate_total-prev_calculated, rates_total-1); i>=0; i--){

FirstBuy=FirstSell=Buy=Sell=EMPTY_VALUE。

datetime when=Time;

if((High-Close)<0){

if(lastSignal==SELL) {

FirstBuy=Close;

SoundAlert(when, "Buy");}。

lastSignal=BUY;}

如果((Low-Close)>0){

如果(lastSignal==BUY) {

FirstSell=Close;

SoundAlert(when, "Sell"); }

lastSignal=SELL;}

}

return(rate_total);}

void SoundAlert(datetime i, string dir) {

static datetime lastAlert=0。

如果(lastAlert!=i) {

Alert(StringFormat("%s signal on %s at %s",dir,Symbol(),TimeToStr(i))。

daniel1983

像这样试一下:

#property copyright "Copyright © 2014 Daniel Luchinger"

#property link ""

#property strict

#property strict

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 clrLime

#property indicator_color2 clrRed

#property indicator_color3 clrMagenta

#property indicator_color4 clrCyan

#define BUY 1

#define SELL 2

double Buy[],

Sell[],

FirstBuy[],

FirstSell[];

int OnInit() {

SetIndexBuffer(0,FirstBuy);

SetIndexBuffer(1,FirstSell);

SetIndexBuffer(2,Buy);

SetIndexBuffer(3,Sell);

for(int i=0; i<4; i++) {

SetIndexStyle (i,DRAW_ARROW,STYLE_SOLID,2);}

SetIndexArrow (0,233);

SetIndexArrow (1,234);

SetIndexArrow (2,233);

SetIndexArrow (3,234);

return(INIT_SUCCEEDED);}

void OnDeinit(const int reason) {}

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[]) {

static int lastSignal=0;

for(int i=MathMin(rates_total-prev_calculated, rates_total-2); i>=0; i--)

{

FirstBuy=FirstSell=Buy=Sell=EMPTY_VALUE;

datetime when=Time;

if((High-Close)<0) {

if(lastSignal==SELL) {

FirstBuy=Close;

SoundAlert(when,"Buy");}

lastSignal=BUY;}

if((Low-Close)>0){

if(lastSignal==BUY) {

FirstSell=Close;

SoundAlert(when,"Sell");}

lastSignal=SELL;}

}

return(rates_total);

}

void SoundAlert(datetime i, string dir) {

static datetime lastAlert=0;

if(lastAlert!=i) {

Alert(StringFormat("%s signal on %s at %s",dir,Symbol(),TimeToStr(i)));

}

}

 

嗨,Mladen,谢谢你,但是这样写代码,有缺失的信号,请看一下,我做了一张图片,在日线图USDJPY上进行比较。

这可能是什么?

附加的文件:
 
daniel1983:
嗨,Mladen,谢谢你,但这样写代码,有缺失的信号,请看一下,我做了一张图片,在日线图USDJPY上进行比较。

这可能是什么?

daniel1983

在你的代码中,你使用了未来值(这些:

高点-收盘

低点-收盘

我使用了Close - 这是一个正常的前值。把它改成 "但",就会重新显示出来。

 

亲爱的mrtools和mladen

谁能帮帮我?TomDemark 移动平均线是我的策略中的一个关键指标,然而,当一个新的架子出现时,报警将是非常有用的;如果报警能编入指标中,我将非常感激。期待您的帮助。

非常感谢

附加的文件: