あなたのコード形式では読みにくいのですが、ひとつには、これをトレーリングストップに使うにはどうしたらいいのか、ということです。注文はまだ開いていなければならないので、OrderClosePrice()は存在しないのです。
( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= ( StartTrailingStop + CummulativeValue )
Figureが何なのかわからないけど......OrderClosePrice==0がオープンオーダーで、OrderClosePrice - OrderOpenPriceがまだオープンオーダーだとマイナスになることをわかっていて書いたの?
他のスクリプトでは、OrderClosePrice - OrderOpenPrice またはその逆を使用しても問題なく動作しています。
誰か手を貸してくれませんか、実はもうすぐなんです。私は個人的に私のコーディングで間違っているとは思わないが、私はちょうどそれがすべての時間を正しく動作しない理由を知らない。
私はすべてを1つにまとめてから長いEAです、今私の目がかなりぼやけていることを少し許してください。
図では、各特定のペアのポイントの値を返します。
これはトレーリング部分です。
//+------------------------------------------------------------------+ //| Program's global variables | //+------------------------------------------------------------------+ extern double StartTrailingStop = 15.0 ; extern double TrailingStop = 5.0 ; extern double CummulativeValue = 5.0 ; extern int NumberOfTrail = 10 ; double Figure ; //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| Program's sub-function | //+------------------------------------------------------------------+double PointsDetection() { Figure = 0.0 ; if ( MarketInfo ( OrderSymbol() , MODE_POINT ) == 0.01 || MarketInfo ( OrderSymbol() , MODE_POINT ) == 0.001 ) { Figure = 0.01 ; } else { if ( MarketInfo ( OrderSymbol() , MODE_POINT ) == 0.0001 || MarketInfo ( OrderSymbol() , MODE_POINT ) == 0.00001 ) { Figure = 0.0001 ; } } return ( Figure ) ; }
//+------------------------------------------------------------------+ //| Program's sub-function | //+------------------------------------------------------------------+ void ProcessTrailingStop() { bool Result ; for ( int x = ( OrdersTotal() - 1 ) ; x >= 0 ; x-- ) { if ( OrderSelect ( x , SELECT_BY_POS , MODE_TRADES ) == True ) { PointsDetection() ; if ( OrderType() == OP_BUY ) { for ( int xai = 0 ; xai < NumberOfTrail ; xai++ ) { if ( xai == 0 ) { if ( ( ( ( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= StartTrailingStop ) && ( ( OrderStopLoss() == 0 ) || ( OrderStopLoss() < ( OrderOpenPrice() + ( TrailingStop * Figure ) ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() + ( TrailingStop * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; } } if ( xai == 1 ) { if ( ( ( ( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= ( StartTrailingStop + CummulativeValue ) ) && ( OrderStopLoss() == ( OrderOpenPrice() + ( TrailingStop * Figure ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() + ( ( TrailingStop + CummulativeValue ) * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; } } if ( xai >= 2 ) { if ( ( ( ( OrderClosePrice() - OrderOpenPrice() ) / Figure ) >= ( StartTrailingStop + ( CummulativeValue * xai ) ) ) && ( OrderStopLoss() == ( OrderOpenPrice() + ( ( TrailingStop + ( CummulativeValue * ( xai - 1 ) ) ) * Figure ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() + ( ( TrailingStop + ( CummulativeValue * xai ) ) * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; } } } } else { if ( OrderType() == OP_SELL ) { for ( int xaii = 0 ; xaii < NumberOfTrail ; xaii++ ) { if ( xaii == 0 ) { if ( ( ( ( OrderOpenPrice() - OrderClosePrice() ) / Figure ) >= StartTrailingStop ) && ( ( OrderStopLoss() == 0 ) || ( OrderStopLoss() > ( OrderOpenPrice() - ( TrailingStop * Figure ) ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() - ( TrailingStop * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; } } if ( xaii == 1 ) { if ( ( ( ( OrderOpenPrice() - OrderClosePrice() ) / Figure ) >= ( StartTrailingStop + CummulativeValue ) ) && ( OrderStopLoss() == ( OrderOpenPrice() - ( TrailingStop * Figure ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() - ( ( TrailingStop + CummulativeValue ) * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; } } if ( xaii >= 2 ) { if ( ( ( ( OrderOpenPrice() - OrderClosePrice() ) / Figure ) >= ( StartTrailingStop + ( CummulativeValue * xaii ) ) ) && ( OrderStopLoss() == ( OrderOpenPrice() - ( ( TrailingStop + ( CummulativeValue * ( xaii - 1 ) ) ) * Figure ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() - ( ( TrailingStop + ( CummulativeValue * xaii ) ) * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; } } } } } } }
たぶん、そこに:
( OrderStopLoss() == ( OrderOpenPrice() - ( TrailingStop * Figure ) )
https://forum.mql4.com/45053
多分、サーバーエラーを避けるために、このようにコード化されるべきでしょう。
figure = PointsDetection(); if ( ( ( ( OrderOpenPrice() - OrderClosePrice() ) / Figure ) >= StartTrailingStop ) && ( ( OrderStopLoss() == 0 ) || ( OrderStopLoss() >= OrderOpenPrice() ) || ( OrderStopLoss() > ( OrderOpenPrice() - ( TrailingStop * Figure ) ) ) ) ) { Result = OrderModify ( OrderTicket() , OrderOpenPrice() , ( OrderOpenPrice() - ( TrailingStop * Figure ) ) , OrderTakeProfit() , 0 , Color ) ; if( result == true ) break; }
買い注文の 場合。
( OrderStopLoss() < ( OrderOpenPrice() + ( TrailingStop * Figure ) )

取引の機会を逃しています。
- 無料取引アプリ
- 8千を超えるシグナルをコピー
- 金融ニュースで金融マーケットを探索
私はEAをトレイルしていました、私はデモでテストしたとき、私は買い注文だけが正しくそれを得た(と思う)、一方、売り注文は 一度だけストップロスを移動しました。私はまだ問題がどこにあるか見つけることができません。
** コードを編集しました **