アスク! - ページ 135

 
Kalenzo:
あなたは物事を複雑にしすぎているようです。1つの大きな関数の代わりに、いくつかの短いコード部分を使用してみてください。これはあなたにいくつかのヒントを与えるはずです。

ご教授ありがとうございます。教えていただいたコードを追加してみたのですが、正直言って迷っています。コードを追加した後、EAが問題のスルーを示しています。構文を調べてみたのですが、よくわかりません。

また、int start()関数の中で関数を 使用することについて質問がありました。これは許されるのでしょうか?関数内で初期化されたバイラブルは他の関数から見ることができないのでは?

そこで

int start()

{

関数( int x)

{

// 何かをする

return(x)

// 何かをする ... "xはstart()関数の中で呼び出せるのか?

return0;

}

私のEAのソースを添付します。あなたの助けは非常に高く評価されています。

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

//| CCCCCCCCIEA.mq4 aka 8xCIEA.mq4 |

//| By CuTzPR |

//|------------------------------------------------------------------+

#property copyright "CuTzPR@Forex-TSD"

//---- input parameters

extern double Risk_Percent=10;

extern bool Turned_On=true;

extern bool Allow_Risk=false;

extern bool TimeFilter=false;

extern double FromHourTrade=0; //Adjust for Broker GMT Time

extern double ToHourTrade=23; //Adjust for Broker GMT Time

extern double TP=20; // Take Profit Level

extern int MaxLong=5,MaxShort=5;

extern int MaxOpenOrders=10;

extern double Magic=10000;

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

//| expert start function |

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

int start()

{

int ticket;

double Lots;

bool Canopen,BlockTrade;

double Poin; // This variable was included to solve the problem where some brokers use 6 digit quotes instead of 5

static datetime timeprev; // Portion of coded was added to alloy only one trade per bar.

datetime CMT; //Close time of last trade

int total=OrdersTotal();

double Spread=Ask-Bid;

//This portion of code was added to only allow one trade per bar.

if(timeprev==Time[0])

{

return(0); //only execute on new bar

}

else if (timeprev==0)

{

timeprev=Time[0]; // do nothing if freshly added to chart

return(0);

}

else

{

timeprev=Time[0];

}

// End of alllow one trade per bar code

//*****Following code was added to control the Risk per trade.

if (Allow_Risk==true)

Lots=MathCeil(AccountFreeMargin() * Risk_Percent / 10000) / 10;

else Lots=0.1;

//End of Risk Code

//The following code was also included to solve the 6 digit broker quoting

if (Point == 0.00001) Poin = 0.0001; //6 digits

else if (Point == 0.001) Poin = 0.01; //3 digits (for Yen based pairs)

else Poin = Point; //Normal

//End Point Code

// Custom Functions

double cci=iCCI(NULL,PERIOD_M5,5,PRICE_TYPICAL,0);

double SATL=iCustom(NULL,PERIOD_H1,"$SATL",0,1);

// End of Custom Function

//Start of total count of open Long and Short Orders.

int totalOrders (totalBuy)

{

int totalNumber= 0;

for (int cnt = total ; cnt >=0 ; cnt-- )

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if (OrderMagicNumber() == Magic && OrderType() == OP_BUY)

totalNumber++;

}

return (totalNumber);

}

int totalOrders (totalSell)

{

int totalNumber = 0;

for (int cnt = total ; cnt >=0 ; cnt-- )

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if (OrderMagicNumber() == Magic && OrderType() == OP_SELL)

totalNumber++;

}

return(totalNumber);

}

int totalBuy = totalOrders(totalBuy);

int totalSell = totalOrders(totalSell);

int EAopenOrders=totalBuy+totalSell;

//End of total Open Long and Short count code

// Time filter Code

if (TimeFilter==true)

{

if (!(Hour() >= FromHourTrade && Hour() <= ToHourTrade && Minute() <=2))

BlockTrade=true;

else BlockTrade=false;

}

//End of time Filter code

// Are trades allowed to be opened?

if(EAopenOrders<=MaxOpenOrders && BlockTrade==false && Turned_On==true)

Canopen=true;

else if(EAopenOrders>MaxOpenOrders || BlockTrade==true || Turned_On==false)

Canopen=false;

// End of Allow code

//*****Trade Open Order Functions

if(Canopen==true)

{

if (totalBuy<=MaxLong)

{

if (cci>-100 && SATL<Ask)

{

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"CCI0",Magic,0,Blue);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

Print("BUY order opened : ",OrderOpenPrice());

}

else Print ("Error opening BUY order : ",GetLastError());

return (0);

}

}

else if (totalSell<=MaxShort)

{

if (cciBid)

{

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"CCI",Magic,0,Red);

if (ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))

Print ("Sell order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL Order : ",GetLastError());

return (0);

}

}

}// End of Trade Open Order Functions

//****Close Orders if they are profitable

for (int cnt = total ; cnt >=0 ; cnt-- )

{

OrderSelect(0,SELECT_BY_POS,MODE_TRADES);

if (OrderMagicNumber()==Magic)

{

if(OrderType()==OP_BUY && TP != 0 && totalBuy!= 0)

{

if(Bid >= ((OrderOpenPrice()+TP*Poin)+Spread))

{

OrderClose(OrderTicket(),OrderLots(),Bid,3,Green); // Long position closed.

CMT=OrderCloseTime();

return(0);

}

}

}

if (OrderMagicNumber()==Magic)

{

if(OrderType()==OP_SELL && TP != 0 && totalSell!=0 )

{

if(Ask <= ((OrderOpenPrice()-TP*Poin)+Spread))

{

OrderClose(OrderTicket(),OrderLots(),Ask,3,Green); // Short position closed.

CMT=OrderCloseTime();

return(0);

}

}

}

} // Close Profitable trades loop closed

}// End of Start function

あなたの助けは非常に感謝されます。

 
Limstylz:
こんにちは、皆さん。

当初は新しいスレッドとして投稿したのですが、別のプログラミングのスレッドに移動され(ちなみに移動に異論はありません)、そのスレッドの投稿者の多さのため、現在迷子になっているようです。

おそらく、ここの誰かが私を助けることができますか?

Limstylzは、このAsk!スレッド39ページを見てください。あなたの助けになるような情報があるかもしれません。幸運を祈ります。

 

ありがとうございます。

cutzpr:
Limstylz このAsk!スレッドの39ページを見てみてください。あなたの助けになるような情報があるかもしれません。幸運を祈ります。

血まみれのインターネット接続が一日中ダウンしていたので、一度だけ自分の 脳細胞を使う必要があったんだ。

とにかく、int start () についてのあなたの質問に答えるために...これはEAの本体で、1ティックごとに 継続的に更新されます(正しいと思います)。

あなたのコードは少し混乱しています...問題が発生している場所を説明できますか? 私自身はMQL4を学んだばかりですが、問題を分解していただければ、お役に立てるかもしれません。

 

これの何が問題なのでしょうか?

このインディケータを自分のメタにコピーすると、メタを開くのに5分以上かかるのですが、削除してメタを再び開くと、また正常になります。

ファイル:
 

ありがとうございます!!!素晴らしいです!

 

図面に戻る

 

エキスパートアドバイザーにカスタムインジケータを 埋め込む

こんにちは、人々は、エキスパートアドバイザーに下記のカスタムインジケータを追加する方法を知っている誰?そうすれば私達はファイルからそれを呼ぶためにicustomを使用する必要がないようにか。

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

//| ARSI.mq4

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

#property copyright "Alexander Kirilyuk M."

#property link ""

#property indicator_separate_window

//#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

extern int ARSIPeriod = 14;

//---- buffers

double ARSI[];

int init()

{

string short_name = "ARSI (" + ARSIPeriod + ")";

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ARSI);

//SetIndexDrawBegin(0,ARSIPeriod);

return(0);

}

int start()

{

int i, counted_bars = IndicatorCounted();

int limit;

if(Bars <= ARSIPeriod)

return(0);

if(counted_bars < 0)

{

return;

}

if(counted_bars == 0)

{

limit = Bars;

}

if(counted_bars > 0)

{

limit = Bars - counted_bars;

}

double sc;

for(i = limit; i >= 0; i--)

{

sc = MathAbs(iRSI(NULL, 0, ARSIPeriod, PRICE_CLOSE, i)/100.0 - 0.5) * 2.0;

if( Bars - i <= ARSIPeriod)

ARSI = Close;

else

ARSI = ARSI + sc * (Close - ARSI);

}

Print ("Try2 : " , ARSI[0], ":", ARSI[1]);

return(0);

}
 
yast77:
こんにちは、皆さん、エキスパートアドバイザーに下のカスタムインディケータを追加する方法を知っていますか?そのため、ファイルからそれを呼び出すためにicustomを使用する必要はありません?
//+------------------------------------------------------------------+

//| ARSI.mq4

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

#property copyright "Alexander Kirilyuk M."

#property link ""

#property indicator_separate_window

//#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 DodgerBlue

extern int ARSIPeriod = 14;

//---- buffers

double ARSI[];

int init()

{

string short_name = "ARSI (" + ARSIPeriod + ")";

SetIndexStyle(0,DRAW_LINE);

SetIndexBuffer(0,ARSI);

//SetIndexDrawBegin(0,ARSIPeriod);

return(0);

}

int start()

{

int i, counted_bars = IndicatorCounted();

int limit;

if(Bars <= ARSIPeriod)

return(0);

if(counted_bars < 0)

{

return;

}

if(counted_bars == 0)

{

limit = Bars;

}

if(counted_bars > 0)

{

limit = Bars - counted_bars;

}

double sc;

for(i = limit; i >= 0; i--)

{

sc = MathAbs(iRSI(NULL, 0, ARSIPeriod, PRICE_CLOSE, i)/100.0 - 0.5) * 2.0;

if( Bars - i <= ARSIPeriod)

ARSI = Close;

else

ARSI = ARSI + sc * (Close - ARSI);

}

Print ("Try2 : " , ARSI[0], ":", ARSI[1]);

return(0);

}

このインジケータを呼び出すには、EA内でiCustom関数を 使用する必要があります。

iCustom(Symbol(),0, "ARSI",ARSIPeriod,0,0);

赤色で表示されている数字は、見たいバーです。必要に応じて変更してください。

FerruFx

 
FerruFx:
このインディケータを呼び出すには、EAでiCustom関数を使用する必要があります。

iCustom(Symbol(),0, "ARSI",ARSIPeriod,0,0);

赤で囲った数字が見たいバーです。必要に応じて変更してください。

FerruFx

ご回答ありがとうございます。はい、私は我々がicustom関数を使用することができることを知っているが、私が知っているように、我々は、インジケータからコーディングを入力することにより、指標の機能を埋め込むことができ、次のウェブサイトExpert Advisorsの指標の埋め込み(iCustom代替)www.metatrader.info、それについてcodersguruによって説明したが、ARSI指標について、私はエキスパートアドバイザーにそれを埋め込む方法はよく分からない。どんな推薦でもありがとうございます!

 

10points3の改善

皆さん、こんにちは。

私たちは10points3の改良を試みています。最後の3番目のトレードをクローズするためにコードを変更する必要があります。こちらの最後の投稿を参照してください。

https://www.mql5.com/en/forum/174975/page259。

私たちはここで良い結果を得ています。