如何编码? - 页 102

 

请详细解释一下这个问题

我也试过布尔值和if(),但乍一看没有用。

 

如果我没有看到更多,我就无法解释更多...

但你必须遵循基本原则...

double a=iCustom(indiA);

double b=iCustum(indiB);

double c=iCustom(indiC);

int ORDer=0。

if( a==1 && b>0 && c! =0 ) ORDer=1;

if( a==-1 && b<0 && c!=0 ) ORDer=-1;

if(ORDer==1) BUY();

if(ORDer==-1) SELL();

payback:
请解释一下这个问题,我也试过布尔值和if(),但一开始就没有成功。
 

OK OK OK!

这里有更多!

double

BuyValueCurrent,

SellValuePrevious,

SellValueCurrent,

BuyValuePrevious2,

BuyValueCurrent2,

SellValuePrevious2,

SellValueCurrent2,

BuyValueCurrent1min,

BuyValueCurrent5min,

BuyValueCurrent21min,

BuyValueCurrent25min,

SellValueCurrent1min,

SellValueCurrent5min,

SellValueCurrent21min,

SellValueCurrent25min,

TrendEnvUp,

TrendEnvDown,

TrendEnvUp1min,

TrendEnvUp5min,

TrendEnvDown1min,

TrendEnvDown5min,

Compra,

Vendi,

StopLong,

StopSell;

[/php]

the icustom funcions and buy sell

BuyValuePrevious = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,2);

BuyValueCurrent = iCustom(NULL,0,IndicatorName1,NumBars,1,0);

BuyValuePrevious2 = iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,2);

BuyValueCurrent2 = iCustom(NULL,0,IndicatorName2,NumBars,0,0);

SellValuePrevious = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);

SellValueCurrent = iCustom(NULL,0,IndicatorName1,NumBars,0,0);

SellValuePrevious2 = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);

SellValueCurrent2 = iCustom(NULL,0,IndicatorName2,NumBars,1,0);

BuyValueCurrent1min = iCustom(NULL,1,IndicatorName1,NumBars,1,0);

BuyValueCurrent5min = iCustom(NULL,5,IndicatorName1,NumBars,1,0);

BuyValueCurrent21min = iCustom(NULL,1,IndicatorName2,NumBars,0,0);

BuyValueCurrent25min = iCustom(NULL,5,IndicatorName2,NumBars,0,0);

SellValueCurrent1min = iCustom(NULL,1,IndicatorName1,NumBars,0,0);

SellValueCurrent5min = iCustom(NULL,5,IndicatorName1,NumBars,0,0);

SellValueCurrent21min = iCustom(NULL,1,IndicatorName2,NumBars,1,0);

SellValueCurrent25min = iCustom(NULL,5,IndicatorName2,NumBars,1,0);

TrendEnvUp = iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0); // trendenvelopes

TrendEnvDown = iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0); // trendenvelopes

TrendEnvUp1min = iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);

TrendEnvUp5min = iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);

TrendEnvDown1min = iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);

TrendEnvDown5min = iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);

BuyCondition = (BuyValueCurrent !=0 && BuyValueCurrent2 !=0 && TrendEnvUp != EMPTY_VALUE)&& (BuyValueCurrent1min !=0 && BuyValueCurrent21min !=0 && TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=0 && BuyValueCurrent25min !=0 && TrendEnvUp5min != EMPTY_VALUE) ;

SellCondition = (SellValueCurrent !=0 && SellValueCurrent2 !=0 && TrendEnvDown != EMPTY_VALUE)&& (SellValueCurrent1min != 0 && SellValueCurrent21min != 0 && TrendEnvDown1min != EMPTY_VALUE)&& (SellValueCurrent5min != 0 && SellValueCurrent25min != 0 && TrendEnvDown5min != EMPTY_VALUE) ;

StopLong = ((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));

StopSell = ((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE));

the exit condition

[php]

StopBuy = (SellValueCurrent !=0 && SellValueCurrent2 !=0 || TrendEnvDown != EMPTY_VALUE);

StopSell = (BuyValueCurrent !=0 && BuyValueCurrent2 !=0 || TrendEnvUp != EMPTY_VALUE);

 

改变这些...

所以,所有的条件都是假的,并保持假的,直到if()条件为真。

删除 "double "中的StopLong和StopSell,其他每个 "double "都可以保留。

这将为你做到这一点!

bool BuyCondition=false;

bool SellCondition=false。

bool StopLong=false;

bool StopSell=false。

如果((BuyValueCurrent !=0 && BuyValueCurrent2 !=0 && TrendEnvUp !=EMPTY_VALUE) && (BuyValueCurrent1min !=0 && BuyValueCurrent21min !)=0 && TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=0 && BuyValueCurrent25min !=0 && TrendEnvUp5min != EMPTY_VALUE)){BuyCondition=true;}

如果((SellValueCurrent !=0 && SellValueCurrent2 !=0 && TrendEnvDown != EMPTY_VALUE) && (SellValueCurrent1min !=0 && SellValueCurrent21min != 0 && TrendEnvDown1min != EMPTY_VALUE) && (SellValueCurrent5min != 0 && SellValueCurrent25min != 0 && TrendEnvDown5min != EMPTY_VALUE))。{SellCondition=true;}

如果((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE)) {StopLong=true;}.

如果((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE)) {StopSell=true;}。

payback:
ok ok ok!

这里有更多!

double

BuyValueCurrent,

SellValuePrevious,

SellValueCurrent,

BuyValuePrevious2,

BuyValueCurrent2,

SellValuePrevious2,

SellValueCurrent2,

BuyValueCurrent1min,

BuyValueCurrent5min,

BuyValueCurrent21min,

BuyValueCurrent25min,

SellValueCurrent1min,

SellValueCurrent5min,

SellValueCurrent21min,

SellValueCurrent25min,

TrendEnvUp,

TrendEnvDown,

TrendEnvUp1min,

TrendEnvUp5min,

TrendEnvDown1min,

TrendEnvDown5min,

Compra,

Vendi,

StopLong,

StopSell;

[/php]the icustom funcions and buy sell

BuyValuePrevious = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,2);

BuyValueCurrent = iCustom(NULL,0,IndicatorName1,NumBars,1,0);

BuyValuePrevious2 = iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,2);

BuyValueCurrent2 = iCustom(NULL,0,IndicatorName2,NumBars,0,0);

SellValuePrevious = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);

SellValueCurrent = iCustom(NULL,0,IndicatorName1,NumBars,0,0);

SellValuePrevious2 = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,1,2);

SellValueCurrent2 = iCustom(NULL,0,IndicatorName2,NumBars,1,0);

BuyValueCurrent1min = iCustom(NULL,1,IndicatorName1,NumBars,1,0);

BuyValueCurrent5min = iCustom(NULL,5,IndicatorName1,NumBars,1,0);

BuyValueCurrent21min = iCustom(NULL,1,IndicatorName2,NumBars,0,0);

BuyValueCurrent25min = iCustom(NULL,5,IndicatorName2,NumBars,0,0);

SellValueCurrent1min = iCustom(NULL,1,IndicatorName1,NumBars,0,0);

SellValueCurrent5min = iCustom(NULL,5,IndicatorName1,NumBars,0,0);

SellValueCurrent21min = iCustom(NULL,1,IndicatorName2,NumBars,1,0);

SellValueCurrent25min = iCustom(NULL,5,IndicatorName2,NumBars,1,0);

TrendEnvUp = iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0); // trendenvelopes

TrendEnvDown = iCustom(NULL,0,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0); // trendenvelopes

TrendEnvUp1min = iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);

TrendEnvUp5min = iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,0,0);

TrendEnvDown1min = iCustom(NULL,1,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);

TrendEnvDown5min = iCustom(NULL,5,IndicatorName4,Ma_Period,Ma_Shift,Ma_Method,Applied_Price,Deviation,1,0);

BuyCondition = (BuyValueCurrent !=0 && BuyValueCurrent2 !=0 && TrendEnvUp != EMPTY_VALUE)&& (BuyValueCurrent1min !=0 && BuyValueCurrent21min !=0 && TrendEnvUp1min != EMPTY_VALUE) && (BuyValueCurrent5min !=0 && BuyValueCurrent25min !=0 && TrendEnvUp5min != EMPTY_VALUE) ;

SellCondition = (SellValueCurrent !=0 && SellValueCurrent2 !=0 && TrendEnvDown != EMPTY_VALUE)&& (SellValueCurrent1min != 0 && SellValueCurrent21min != 0 && TrendEnvDown1min != EMPTY_VALUE)&& (SellValueCurrent5min != 0 && SellValueCurrent25min != 0 && TrendEnvDown5min != EMPTY_VALUE) ;

StopLong = ((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));

StopSell = ((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE));

the exit condition

[php]

StopBuy = (SellValueCurrent !=0 && SellValueCurrent2 !=0 || TrendEnvDown != EMPTY_VALUE);

StopSell = (BuyValueCurrent !=0 && BuyValueCurrent2 !=0 || TrendEnvUp != EMPTY_VALUE);

 

谢谢,我今天晚上会试一下。

 

有一个愚蠢的问题,{}里面的所有东西都是你的评论,还是我必须写? 为什么?为什么是{;}而不是{};?

还有,我还能使用这个语句吗?

if(SellCondition)

{

ticket = subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order

subCheckError(ticket,"SELL");

LastTrade = "SELL";

return(0);

[/php]

or i have to write:

[php]

if(SellCondition = true)

{

ticket = subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order

subCheckError(ticket,"SELL");

LastTrade = "SELL";

return(0);

 

需要帮助来编码一个简单的EA,请...

大家好。

我想感谢过去帮助过我的所有人。现在,我有一个新的请求。

谁能帮我编码这个EA,以下是参数。

我的EA是基于一个十字星和一个内线的。

对于一个内杠:

在下一个条形图的高点处设置买入止损/买入限价。

在下一交易日的低点处设置卖出止损/卖出限价。

澄清一下。

内栏是0栏(零)。

下一个条形是我们要放置买入和卖出限制 或停止的地方。

下一个条形是触发多头或空头的地方。

在一个小时的图表中,如果我们在上午9点有一个内杠,那么我们在上午10点的高点和低点设置买入止损或限价和卖出止损。多头或空头将在上午11点被触发,前提是价格高于或低于上午10点的水平。

对于一个十字路口:

在前一交易日的高点处设置买入止损/买入限价。

在前一交易日的低点处设置卖出止损/卖出限价。

澄清一下。

斗极线是0条(零)。

前一个条形或道氏条形之前的条形是我们要在高点和低点设置买入和卖出限制或止损的地方。

道吉线之后的柱子是触发做多或做空的地方。

在一个小时的图表中,如果我们在上午9点有道吉线,那么我们在上午8点的高点和低点设置买入止损或限价和卖出止损。多头或空头将在上午10点被触发,前提是价格高于或低于上午8点的柱状。

...也许,这不是那么简单。如果是这样的话,我在两周前就会这样做了。

谢谢。

最好的问候。

前进之星

 

这些不是评论,这是代码。

它们是你的if()语句的一部分。

如果(SellCondition){

...

return(0)。

}

如果(SellCondition==true){

...

return(0);

}

两个语句都可以,你可以使用其中一个...

但请注意,每个if()语句都以}结束。

在你提供的代码中并没有显示。

另一个例子。

if(a==b){c=1; d=2; return(0); }

payback:
为什么是{;}而不是{};呢?

我还可以使用这个语句吗?

if(SellCondition)

{

ticket = subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order

subCheckError(ticket,"SELL");

LastTrade = "SELL";

return(0);

[/php]

or i have to write:

[php]

if(SellCondition = true)

{

ticket = subOpenOrder(OP_SELL,NewStopLossSell,TakeProfit,TicketComment); // open SELL order

subCheckError(ticket,"SELL");

LastTrade = "SELL";

return(0);

 

ahhhhh 我完全理解 thx!!!!

我在大学里复习我的C,也是一样的。

 

找到了一些指标,可以开始使用...

也有一个EA,但我认为它的表现不是很好,只是做了一个快速测试...

附加的文件: