if(0==0){//Pulls in order that meets the criteria for processing
int num=0;int pos=0;
for(int b=0;b<21;b++){// this (loopB) compares the ticket# of the selected order against the number stored in the ticket array
if(tsTicket==OrderTicket() ){
num++; pos=b;// if ticket numbers match, pos is the position in the array where the trailing data is stored
break;
}
}
if(num==0){ // if the loopB did not find a matching ticket number it is time to initialize the data
for(int j=0;j<21;j++){
if(tsTicket[j]==0){// this is looking for the earliest instance within the array to store the data
pos=j;
break;
}
}
tsTicket[pos]=OrderTicket();// setting the ticket number
tsok[pos]=false;// this is to determine when trailing kicks in
// Print("(",pos,") New ticket initialized = ",tsTicket[pos]);
}
if (OrderType()==OP_SELL) {
if (!tsok[pos] && (OrderOpenPrice()-Ask>=TSactivation*Point || TSactivation==0 ) ) {// if the trailing factor is false, but it has hit the activation point continue
tsPrice[pos]=Ask+TrailPips*Point;// this is the new trailinf stop price
tsok[pos]=true;// it's ok to proceed with trailing stop
if(TrailPips>8){// if this distance from the current price to the new stop, then modify the order.
ModifyStopLoss(Ask+TrailPips*Point,OrderTakeProfit());//modifies order
}
}
if (tsok[pos] && Ask+TrailPips*Point < tsPrice[pos] ){//if the position is gaining in profit
OKそれは動作しましたが、今問題はパフォーマンスです。全履歴をチェックするのは時間がかかる。1年半のバックテストをしてみて、遅いことに気がつきました。その理由は、履歴にあるすべての注文をチェックし、その終値と終値を比較しているからです。そこで、履歴の検索を制限して、最近の注文だけを検索させる方法はないでしょうか?どうにかして、パフォーマンスを上げることはできないでしょうか?
を試してみてください。
OrderSelect(HistoryTotal(),SELECT_BY_POS,MODE_HISTORY);
しかし、私はこの1つのためによく分からない、私はそれが全体の歴史の中で最後の順序をピックアップすると思います。![](https://c.mql5.com/forextsd/smiles/regular_smile.png)
乾杯
こんにちは、皆さん
どなたか助けてください。
EAを 作るためのインジケータがあるのですが・・・。
を試してみてください。
OrderSelect(HistoryTotal(),SELECT_BY_POS,MODE_HISTORY);
しかし、私はこの1つのためによく分からない、私はそれが全体の歴史の中で最後の順序をピックアップすると思います。![](https://c.mql5.com/forextsd/smiles/regular_smile.png)
乾杯編集された私の障害...それはでなければなりません。
OrderSelect(HistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) であるべきです。
二重投稿で申し訳ありませんが、本当に助けて欲しいのです...。
私はここで絶望しています。 一晩中自分の配列を動かそうとしているのですが、何も起こりません。 私は本当に自給自足しようとし、学習しようとしましたが、私はまだ私が行く必要がある場所に到達することはできません。 もし、どなたか私に慈悲を与え、手助けを貸していただけるなら...お願いします!!!!
私はグリッドスクリプトを実行しているが、私はシンボルで実行しているどのように多くのロットを追跡したいと思います。 私は私の総ポジションがロットサイズによって何であるかを追加することができるようにしたいと思います。 例えば、0.10, 0.10, 0.10, 0.20, 0.30, 私は0.90ロットに相当するものを持っていることを知ることができるようにしたいです。 また、最小ロットサイズと最大ロットサイズ...0.10と0.30も知りたい。
ArrayResize(OrderArray, i);
ArrayInitialize(OrderArray,0);
cnt = 0;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )
{
OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();
OrderArray[cnt][OPEN] = OrderOpenPrice();
OrderArray[cnt][LOTS] = OrderLots();
if(OrderType() == OP_BUY)
{
////// I can't get anything to work!!!!!!!
BuyLots += OrderArray[cnt][LOTS];
////// This returns Zero when I place BuyLots in my Comments
////// This returns error messages
MaxBuyLots =ArrayMaximum(OrderArray[LOTS],WHOLE_ARRAY,0);
}
二重投稿で申し訳ありませんが、私は本当に助けを必要としています....
私はここで絶望しています。 一晩中、自分の配列を動かそうとしていますが、何も起こりません。 私は本当に自給自足で、学ぼうとしましたが、まだ私が行くべき場所に到達することができません。 もし、どなたか私に慈悲を与え、手助けを貸していただけるなら...お願いします!!!!
私はグリッドスクリプトを実行しているが、私はシンボルで実行しているどのように多くのロットを追跡したいと思います。 私は私の総ポジションがロットサイズによって何であるかを追加することができるようにしたいと思います。 例えば、0.10, 0.10, 0.10, 0.20, 0.30, 私は0.90ロットに相当するものを持っていることを知ることができるようにしたいです。 また、最小ロットと最大ロットも知りたいのですが・・・0.10と0.30です。
問題は、arrayresize()が最初の要素のサイズのみを変更し、2番目の要素のサイズを変更しないことです。 明らかに、LOTS, PROFIT, OPENマクロはそれぞれ0,1,2でなければなりません。 また、forループのcountオブジェクトは(i)ですが、ブロックコードでは(cnt)を参照しています。
double OrderArray[][3];
ArrayResize( OrderArray, OrdersTotal() );
cnt = 0;
for (cnt = 0; cnt< OrdersTotal(); cnt++)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )
{
OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();
OrderArray[cnt][OPEN] = OrderOpenPrice();
OrderArray[cnt][LOTS] = OrderLots();
if(OrderType() == OP_BUY)
{
double BuyLots;
BuyLots += OrderArray[cnt][LOTS];
MaxBuyLots =ArrayMaximum(OrderArray);
}
ニコリシェンさんありがとうございます。
少しづつですが、近づいてきました。 BuyLotsは私が欲しいものを返してくれますが、ArrayMaximumはよく分からない奇妙な数字を出してきます。 最大のLotSizeを返さないのです。
私は本当に助けに感謝します。
ディ
Nicholishenさん、ありがとうございます。
少しづつですが、近づいてきました。 BuyLotsは私が欲しいものを返してくれますが、ArrayMaximumはよく分からない奇妙な数字を出してきます。 最大のLotSizeを返さないのです。
私は本当に助けを感謝します。
ディーのように、配列を別の配列に分割するか、配列の最大値を抽出するループを書く必要があります。
ArrayResize( OrderArray, OrdersTotal() );
cnt = 0;
for (cnt = 0; cnt< OrdersTotal(); cnt++)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )
{
OrderArrayProfit[cnt] = OrderProfit() + OrderSwap();
OrderArrayOpen[cnt] = OrderOpenPrice();
OrderArrayLots[cnt] = OrderLots();
if(OrderType() == OP_BUY)
{
double BuyLots;
BuyLots += OrderArrayLots[cnt];
MaxBuyLots =ArrayMaximum(OrderArrayLots);
}
[/CODE]
or
[CODE]double OrderArray[][3];
ArrayResize( OrderArray, OrdersTotal() );
cnt = 0;
for (cnt = 0; cnt< OrdersTotal(); cnt++)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() )
{
OrderArray[cnt][PROFIT] = OrderProfit() + OrderSwap();
OrderArray[cnt][OPEN] = OrderOpenPrice();
OrderArray[cnt][LOTS] = OrderLots();
if(OrderType() == OP_BUY)
{
double BuyLots;
BuyLots += OrderArray[cnt][LOTS];
}
double MBL;
for(int i=0;i<OrdersTotal();i++){
if(OrderArrayLots[LOTS]>MBL)MBL=OrderArrayLots[LOTS];
}
MaxBuyLots =MBL;
これは、トレーリングデータと対応する取引のチケット番号をペアにして、同じ通貨の複数の取引でタイトなトレーリングストップを追跡する関数の 別の例です - 配列を使用します。 多分、これはあなたにもいくつかのアイデアを与えるのに役立つことでしょう。
double tsPrice[21];
bool tsok[21];
int tkt3[20];
int SuperClose(){// superclose by nicholishen
int cnp=ordercnt();
for(int i=0;i<cnp;i++){
if(OrderMatch(i)){
if(0==0){//Pulls in order that meets the criteria for processing
int num=0;int pos=0;
for(int b=0;b<21;b++){// this (loopB) compares the ticket# of the selected order against the number stored in the ticket array
if(tsTicket==OrderTicket() ){
num++; pos=b;// if ticket numbers match, pos is the position in the array where the trailing data is stored
break;
}
}
if(num==0){ // if the loopB did not find a matching ticket number it is time to initialize the data
for(int j=0;j<21;j++){
if(tsTicket[j]==0){// this is looking for the earliest instance within the array to store the data
pos=j;
break;
}
}
tsTicket[pos]=OrderTicket();// setting the ticket number
tsok[pos]=false;// this is to determine when trailing kicks in
// Print("(",pos,") New ticket initialized = ",tsTicket[pos]);
}
if (OrderType()==OP_SELL) {
if (!tsok[pos] && (OrderOpenPrice()-Ask>=TSactivation*Point || TSactivation==0 ) ) {// if the trailing factor is false, but it has hit the activation point continue
tsPrice[pos]=Ask+TrailPips*Point;// this is the new trailinf stop price
tsok[pos]=true;// it's ok to proceed with trailing stop
if(TrailPips>8){// if this distance from the current price to the new stop, then modify the order.
ModifyStopLoss(Ask+TrailPips*Point,OrderTakeProfit());//modifies order
}
}
if (tsok[pos] && Ask+TrailPips*Point < tsPrice[pos] ){//if the position is gaining in profit
tsPrice[pos]=Ask+TrailPips*Point;
if(TrailPips>8){
ModifyStopLoss(Ask+TrailPips*Point,OrderTakeProfit());
}
}
if (tsok[pos] && Ask >= tsPrice[pos] ){// if the postion hits the stop price
if(CloseOrder(Ask)==STOP)return(STOP);
Print("Short Order ",tsTicket[pos]," Closed from TS");
}
}
else if (OrderType()==OP_BUY) {// reverse of SELL
if(!tsok[pos] && (Bid-OrderOpenPrice() >= TSactivation*Point || TSactivation==0 ) ) {
tsPrice[pos]=Bid-TrailPips*Point;
tsok[pos]=true;
if(TrailPips>8){
ModifyStopLoss(Bid-TrailPips*Point,OrderTakeProfit());
}
}
if (tsok[pos] && Bid-TrailPips*Point > tsPrice[pos] ){
tsPrice[pos]=Bid-TrailPips*Point;
if(TrailPips > 8){
ModifyStopLoss(Bid-TrailPips*Point,OrderTakeProfit());
}
}
if (tsok[pos] && Bid <= tsPrice[pos] ){
if(CloseOrder(Bid)==STOP)return(STOP);
Print("Long Order ",tsTicket[pos]," Closed from TS");
}
}
}
}
if(RefreshRates())return(STOP);
}
for(i=0;i<21;i++){// this searches the array for ticket numbers that are now obsolete due to an order that has closed
if(tsTicket>0){
bool found=false;
for(b=0;b<OrdersTotal();b++){
OrderSelect(b,SELECT_BY_POS);
if(tsTicket==OrderTicket()){
found=true;
break;
}
}
if(!found){// if there are matching ticket numbers in the trade pool and the array then nothing happens
tsTicket=0;tsPrice=0;tsok=false;// if there is an obolete ticket the the data is reset. And the next new ticket data can occupy this space
// Print("Array pos ",i," Cleaned");
}
}
}
return(0);
}
int ordercnt(){
int c;
for(int i=0;i<OrdersTotal();i++){
if(OrderSelect(i,SELECT_BY_POS)){
if(OrderMagicNumber()==ID && OrderSymbol()==Symbol()){
tkt3[c]=OrderTicket();
c++;
}
}
}
return(c);
}
//+------------------------------------------------------------------+
int curcnt(){
int c;
for(int i=0;i<OrdersTotal();i++){
if(OrderSelect(i,SELECT_BY_POS)){
if(OrderSymbol()==Symbol()){
c++;
return(c);
}
}
}
return(c);
}
//+------------------------------------------------------------------+
bool OrderMatch(int i){
if(OrderSelect(tkt3,SELECT_BY_TICKET)){
if(OrderMagicNumber()==ID && OrderSymbol()==Symbol()){
return(true);
}
}
return(false);
}いつもありがとうございます。
最終行から3行目をこのように変更しました。
にして、動作するようにしました。 もう寝る時間を過ぎてしまいましたが 明日起きたら、あなたのコードのロジックを勉強します。 しかし、私は頑固なので、くそArrayMaximum関数を どう使うか考えようと思います!!!。 しかし、私は頑固なので、このくそArrayMaximum関数をどう使うか考えるつもりです!!また、インデックス作成についてもっと読んで、私の古いやり方がいかにひどく間違っていたかを知る必要があるでしょうね。
ありがとうございました。
ディ
ありがとうございました。
最終行から3行目をこのように変更しました。
にして、動作するようにしました。 もう寝る時間を過ぎてしまいました。 明日起きたら、あなたのコードのロジックを勉強します。 しかし、私は頑固なので、くそArrayMaximum関数をどう使うか考えるつもりです!!!。 しかし、私は頑固なので、このくそArrayMaximum関数をどう使うか考えるつもりです!!また、インデックス作成についてもっと読んで、私の古いやり方がいかにひどく間違っていたかを知る必要があるでしょうね。
ありがとうございました。
ディーこの関数は、多次元の配列を使用しており、異なる種類のデータを保存しているため、max関数が 動作しない理由です。 そのデータの最大値を返すので、おそらく利益の数字か、本当の最大ロットサイズより高いものを返していたのでしょう。