如何编码? - 页 233

 
CoeyCoey:
大家好。

我正在修改一个货币强度表,根据图表的时间显示货币的强度。 目前,所使用的代码是。

aHigh = MarketInfo(mySymbol,MODE_HIGH); // set a high today

aLow = MarketInfo(mySymbol,MODE_LOW); // set a low today

aBid = MarketInfo(mySymbol,MODE_BID); // set a last bid

aAsk = MarketInfo(mySymbol,MODE_ASK);

我知道MODE_HIGH和MODE_LOW可以获得当前日期的高点和低点。 我怎样才能获得图表当前时间段的高点和低点呢?

谢谢!

P.S. 我不是一个程序员,所以请用小字:)

你不一定要使用MarketInfo()。如果你想获得当前的高点,使用High[0]和Low[n],Close[n],Open[n]。'n'表示从当前条形图的偏移量。例如,要获得当前条形的高点,你可以使用High[1],因为当前条形是0,之前的条形与当前条形的偏移量是1。

要检查图表上其他时间段的高点、低点、开盘、收盘,你可以使用iHigh(), iLow(), iClose(), 和iOpen函数

下面是用法示例。

double high_of_gbpusd_4hours_current = iHigh("gbpusd", period_h4, 0);

[删除]  

谢谢! 你们真了不起!

 
mfurlend:

我想我差不多已经成功了(不确定),但由于某些原因,数组中除了合法的值之外,还填入了很多'0'值。

我是这样做的。

#define TICKET 0

#define PRICES 1

double ResumeArray[0,2];

int CheckForResume()

{

ResumeCheck = TimeLocal()+(PERIOD_M1*60)*5;

bool success = false;

int k;

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

{

if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES))continue;

if (OrderType() > OP_SELL || OrderProfit()> Cutoff)continue;

int arraycount=ArrayRange(ResumeArray,TICKET);

bool found = false;

for (k=arraycount-1; k>=0; k--)

{

if (ResumeArray[k,TICKET] == OrderTicket())

{

found = true;

if (ResumeArray[k,PRICES] + Cutoff < OrderProfit())break;

else

{

success=true;

Print ("ELSE");

ResumeArray[k,PRICES] = OrderProfit();

break;

}

}

}

if (found == false)

{

arraycount = ArrayResize(ResumeArray,arraycount+1)/2;

ResumeArray[arraycount-1,TICKET] = OrderTicket();

ResumeArray[arraycount-1,PRICES] = OrderProfit();

success=true;

}

}

if(success)return (1);

else return(0);

}

你不必使用TICKET和PRICES的定义,我只是把它们包括在内,以显示二维数组是如何工作的。只需将所有出现的TICKET和PRICES分别替换为0和1。

我将'for'循环中的'return'命令替换为'break',所以所有未结订单都将被处理。

需要注意的是,关闭的订单永远不会从数组中删除,所以它的大小会继续增长,并拖慢你的平台。

d4v3

 

条数历史限制

如果有人能在这个RenkoLiveChart_v3.2脚本中添加条数限制选项,我将非常感激。

它占用了太多的计算机资源。

附加的文件:
 

基本警报EA

................[已解决] ....................

 

减少噪音

大家好 - 我一直在寻找一种方法来限制交易中的噪音,并使其更快地被切断。

这个想法其实很简单

噪声显示在这张照片上,它是动态的,意味着它不断变化以适应市场条件。

这是我为收盘所做的一些代码,如果有人想使用它,请随意,它只需要在其中加入一些乘法。

int profit = OrderProfit() + OrderSwap() + OrderCommission();

int Trades = ScanTrades(0,0);

如果(Trades == 0) TS1 = 0;

如果((ScanTrades(2,0) > 0) && (profit < 0))TS= ((MarketInfo(Symbol(),MODE_BID))+噪音+滑点)。

如果((ScanTrades(2,0) > 0) && (profit > 0))TS= ((MarketInfo(Symbol(),MODE_BID))+ 噪声)。

如果((ScanTrades(1,0) > 0) && (profit < 0))TS= ((MarketInfo(Symbol(),MODE_BID))- noise - Slippage)。

如果((ScanTrades(1,0) > 0) && (profit > 0))TS= ((MarketInfo(Symbol(),MODE_BID))- 噪声)。

//做空

如果((ScanTrades(2,0) > 0)&& (TS1 ==0 ))TS1 = TS。

如果((ScanTrades(2,0) > 0)&& (TS < TS1)TS1 = TS。

如果((ScanTrades(2,0) > 0)&& (MarketInfo(Symbol(),MODE_BID) > TS1)) CloseOrder(2);

//长线

如果((ScanTrades(1,0) > 0)&& (TS1 ==0 ))TS1 = TS。

如果((ScanTrades(1,0) > 0)&& (TS>TS1))TS1 = TS。

如果((ScanTrades(1,0) > 0)&& (MarketInfo(Symbol(),MODE_BID) < TS1)) CloseOrder(1);

什么是获得条形图上的当前和前一个高点和低点的最佳方法。 我需要创建变量 "噪音"。

我试过了,但它的命中率很低,T1和l1有时是0,这让我很沮丧,因为它是整个EA "完成 "的所有障碍,如果有这样的事情的话。

double hh2=高。

double ll2=Low;

double hh3=High;

双重ll3=低。

double t1,l1,noise;

//噪音 = 前面各条的重叠部分

如果 ((hh2 - hh3) > 0 )t1 =(hh3); //基本上是在两个 "高点 "之间选取最低的 "高点"--看涨。

如果((hh3-hh2)>0 )t1=(hh2); //看跌

如果 ((ll2-ll3) > 0 )l1 =(ll2); //选取最高的低杠看涨

如果 ((ll3-ll2) > 0 )l1=(ll3); //看跌

噪音=(t1-l1)。

Print("t1 = ",t1,"; l1 = ",l1);

打印的典型结果是t1=0 l1=94.3 它最讨厌的是hh2和hh3是== 我只是不知道该怎么做,我只是看不到我的代码有问题。

附加的文件:
cutoff.jpg  5 kb
[删除]  

谁能帮助我?

谁能告诉我如何在3个熟悉的指标的基础上制作一个新的指标?我做了一个基于3个指标的策略,这些指标显示了非常强的买入/卖出信号,但我想创建一个指标。

 

请对EA进行修正

请帮助我对该EA进行以下修改

1)在小时中添加

A) fisher_11指标,设置为33,0.5,0.5

B) tcf平滑指标设置为17, 8, 0.7

c) 另外,我希望dinap_basic指标在与信号方向相反时不允许交易,即如果它上升,不允许进入买入信号,如果它下降,不允许进入卖出信号。

2) 在15分钟内添加

A) 超级趋势指标

B) 趋势主指标

资金管理

1) 开立2笔交易,每笔交易的止损为账户总额的3%(1.5%)。

2) 一笔在80点获利 或2.2%,第二笔在3.8%获利。

3) 在连续4次亏损后,第五次交易的手数增加一倍,然后在随后的交易中线性增加手数,直到连续两次获胜,然后恢复到默认手数。

4) 所有交易的追踪止损为12点(高于卖出,低于买入前蜡烛图的ATRSTOP_V1指标。

这就是全部,请帮助

附加的文件:
 

你本可以用一行代码实现完全相同的事情。

GlobalVariableSet("TRENDSET_"+Symbol());

你还可以加上时间框架,使其更加独特。

说实话,我不太清楚你的帖子的重点是什么。

尊敬的先生

卢克斯

 

如何使用iCustom调用H1的值?

你好。

我试图编写一个非常简单的指标,但我无法从H1中调用Laguerre值。

我想做的是。

使用1M TF

买入信号:Laguerre越过0.15水平向上,并且Laguerre H1 > 0.75

卖出信号:Laguerre越过0.75水平头向下,并且Laguerre H1 < 0.15

我做了一个简单的十字星指标,它可以工作,问题是当我试图检查Laguerre H1的值时:它是一个混乱的!我尝试了2种方法。

我尝试了2种方法。

第一种。

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 SeaGreen

#property indicator_color2 Red

#property indicator_width1 3

#property indicator_width2 3

double CrossUp[];

double CrossDown[];

extern bool SoundON=true;

double alertTag;

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

SetIndexStyle(0, DRAW_ARROW, EMPTY,3);

SetIndexArrow(0, 233);

SetIndexBuffer(0, CrossUp);

SetIndexStyle(1, DRAW_ARROW, EMPTY,3);

SetIndexArrow(1, 234);

SetIndexBuffer(1, CrossDown);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start() {

int limit, i;

int counted_bars=IndicatorCounted();

//---- check for possible errors

if(counted_bars<0) return(-1);

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++) {

if ( (iCustom(NULL,0,"Laguerre",0.66,9500,0,i) > 0.15) && (iCustom(NULL,0,"Laguerre",0.66,9500,0,i+1) < 0.15)

&&(iCustom(Symbol(),PERIOD_H1,"Laguerre",0.66,9500,0,i) > 0.75)) //check for buy signal

{

CrossUp = Close;

}

else if ( (iCustom(NULL,0,"Laguerre",0.66,9500,0,i) 0.75)

&& (iCustom(Symbol(),PERIOD_H1,"Laguerre",0.66,9500,0,i) < 0.15)) //check for sell signal

{

CrossDown = Close;

}

if (SoundON==true && i==1 && CrossUp > CrossDown && alertTag!=Time[0]){

Alert("SHORT signal on ",Symbol()," ",Period());

alertTag = Time[0];

}

if (SoundON==true && i==1 && CrossUp < CrossDown && alertTag!=Time[0]){

Alert("Long Signal on ",Symbol()," ",Period());

alertTag = Time[0];

}

}

return(0);

}[/CODE]

second one:

[CODE]//+------------------------------------------------------------------+

//| Shift.mq4 |

//| me |

//|

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

#property copyright "me"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Lime

#property indicator_color2 Red

#property indicator_width1 4

#property indicator_width2 4

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

bool Fact_Up = true; // Fact of report that market..

bool Fact_Dn = true; //..is bullish or bearish

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_ARROW);

SetIndexArrow(0,241);

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexEmptyValue(0,0.0);

SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(1,242);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexEmptyValue(1,0.0);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

//int limit;

int counted_bars=IndicatorCounted();

//---- last counted bar will be recounted

if(counted_bars>0) counted_bars--;

if(counted_bars<0) return(-1);

//limit=Bars-counted_bars;

//----

double MA; // MA value on 0 bar

double MA2;

double MA3;

double MA4;

//--------------------------------------------------------------------

double value1, value2, value3;

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

//---- main loop

//for(int i=0; i<limit; i++)

{value1=0.0;

value2=0.0;

value3=0.0;

//--------------------------------------------------------------------

// Checking if bullish

if( (iCustom(Symbol(),NULL,"Laguerre",0,i) > 0.15) && (iCustom(Symbol(),NULL,"Laguerre",0,i+1) < 0.15) && Fact_Up == true

&&(iCustom(Symbol(),PERIOD_H1,"Laguerre",0,i) > 0.75))

{

Fact_Dn = true; // Report about bullish market

Fact_Up = false; // Don't report bullish market

// Alert("BUY SIGNAL.");

value1=Open;

}

//--------------------------------------------------------------------

// Checking if bearish

if( (iCustom(Symbol(),NULL,"Laguerre",0,i) 0.75) && Fact_Dn == true

&&(iCustom(Symbol(),PERIOD_H1,"Laguerre",0,i) < 0.15))

{

Fact_Up = true; // Report about bearish market

Fact_Dn = false; // Don't report bearish market

// Alert("SELL SIGNAL.");

value2=Open;

}

ExtMapBuffer1=value1;

ExtMapBuffer2=value2;

}

//----

return(0);

}

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

两种方法都不起作用,问题出在红线 上,没有 红线就能完美运行

我试过 (iCustom(Symbol(),PERIOD_H1, "Laguerre",0,i) < .....)

(iCustom(Symbol(),PERIOD_H1, "Laguerre",0,0) < ....)

(iCustom(Symbol(),60, "Laguerre",0,i) < ....)

(iCustom(Symbol(),60, "Laguerre",0, 0) < .....)

我也试过用变量: (iCustom(Symbol(),PERIOD_H1, "Laguer re",0.66,9500,0,i)

iF i把。

Print(iCustom(Symbol(),60, "Laguerre",0,i)); 在 "if "之前它返回随机数...

但有了。Print(iCustom(Symbol(),60, "Laguerre",0,0)); 它返回H1的良好值。

现在问题仍然是一样的,如果我在 "if "里面使用iCustom(Symbol(),60, "Laguerre",0, 0);它就不起作用了......

问题出在 "for"、"i "和iCustom的 "shift "值上,但我想不出来。

我们非常欢迎你的帮助!

我附上了我使用的Laguerre指标,如果你想尝试一下。

如果有人准备从头开始重新编码,请不要犹豫。

这让我很头疼......

附加的文件:
laguerre.mq4  3 kb