ストキャスティック - ページ 6

 
king1898:

この画像では、2つの矢印が2つのシグナルを生成するはずですが、私のEAは送信できません、なぜですか?

あなたのコードをすべて見ることができないので、なんとも言えません。バッファの値をプリントアウトして確認 することができます。
 
#property copyright "Copyright 2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//-------------------------------------------------------------------


//-------------------------------------------------------------------
#include <Trade\Trade.mqh>
//--- input parameters
input int      StopLoss=-100;      // Stop Loss$
//input int      TakeProfit=100;   // Take Profit
//input int      KD_Period=9;     // KD Period
input int      K_Period=9;     // K Period
input int      D_Period=3;     // D Period
//input int      MA_Period=8;      // Moving Average Period
input int      EA_Magic=12345;   // EA Magic Number
//input double   Adx_Min=22.0;     // Minimum ADX Value
//---
//---input double Lot=0.01;   // Lots to Trade
input double MaxPosition=3.00;  //Max position
input double P1=0.12;    //P1 position1
input double P2=0.32;
input double P3=0.77;
input double P4=1.92;
input double P5=2.85;
input double P6=3.57;
//
input double PF1=10;     //PF1 profit1
input double PF2=50;
input double PF3=100;
input double PF4=500;
input double PF5=800;
input double PF6=1500;

//

//--- Other parameters
int KDHandle; // handle for our stochastic indicator
//int maHandle;  // handle for our Moving Average indicator
double K[],D[]; // Dynamic arrays to hold the values of K,D values for each bars
//double maVal[]; // Dynamic array to hold the values of Moving Average for each bars
double p_close; // Variable to store the close value of a bar
int STP, TKP;   // To be used for Stop Loss & Take Profit values
double TTL_profit;  //to be used for Total profit
//double hisBuyLot=0.05;
//double hisSellLot=0.05;
double TTLBuy_position;
double TTLSell_position;
int Buytimes;  //to be use for buy times
int Selltimes; // to be used for sell times
bool special_close_p=false;
double special_profit=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Get handle for KD indicator
   KDHandle=iStochastic(NULL,0,K_Period,D_Period,3,MODE_SMA,STO_LOWHIGH);
//--- Get the handle for Moving Average indicator
//   maHandle=iMA(_Symbol,_Period,MA_Period,0,MODE_EMA,PRICE_CLOSE);
//--- What if handle returns Invalid Handle
   if(KDHandle<0)
     {
      Alert("Error Creating Handles for indicators - error: ",GetLastError(),"!!");
      return(-1);
     }

//--- Let us handle currency pairs with 5 or 3 digit prices instead of 4
   //STP = StopLoss;
   //TKP = TakeProfit;
   //if(_Digits==5 || _Digits==3)
   //  {
   //   STP = STP*10;
   //   TKP = TKP*10;
   //  }
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- Release our indicator handles
   IndicatorRelease(KDHandle);
//   IndicatorRelease(maHandle);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- Do we have enough bars to work with
   if(Bars(_Symbol,_Period)<60) // if total bars is less than 60 bars
     {
      Alert("We have less than 60 bars, EA will now exit!!");
      return;
     }  

// We will use the static Old_Time variable to serve the bar time.
// At each OnTick execution we will check the current bar time with the saved one.
// If the bar time isn't equal to the saved time, it indicates that we have a new tick.

   static datetime Old_Time;
   datetime New_Time[1];
   bool IsNewBar=false;

// copying the last bar time to the element New_Time[0]
   int copied=CopyTime(_Symbol,_Period,0,1,New_Time);
   if(copied>0) // ok, the data has been copied successfully
     {
      if(Old_Time!=New_Time[0]) // if old time isn't equal to new bar time
        {
         IsNewBar=true;   // if it isn't a first call, the new bar has appeared
         if(MQL5InfoInteger(MQL5_DEBUGGING)) Print("We have new bar here ",New_Time[0]," old time was ",Old_Time);
         Old_Time=New_Time[0];            // saving bar time
        }
     }
   else
     {
      Alert("Error in copying historical times data, error =",GetLastError());
      ResetLastError();
      return;
     }

//--- EA should only check for new trade if we have a new bar
   if(IsNewBar==false)
     {
      return;
     }

//--- Do we have enough bars to work with
   int Mybars=Bars(_Symbol,_Period);
   if(Mybars<60) // if total bars is less than 60 bars
     {
      Alert("We have less than 60 bars, EA will now exit!!");
      return;
     }

//--- Define some MQL5 Structures we will use for our trade
   MqlTick latest_price;      // To be used for getting recent/latest price quotes
   MqlTradeRequest mrequest;  // To be used for sending our trade requests
   MqlTradeResult mresult;    // To be used to get our trade results
   MqlRates mrate[];          // To be used to store the prices, volumes and spread of each bar
   ZeroMemory(mrequest);      // Initialization of mrequest structure
/*
     Let's make sure our arrays values for the Rates, KD Values 
     is store serially similar to the timeseries array
*/
// the rates arrays
   ArraySetAsSeries(mrate,true);
// the KD Kvalues array
   ArraySetAsSeries(K,true);
// the KD Dvalues array
   ArraySetAsSeries(D,true);
// the ADX values arrays
//   ArraySetAsSeries(adxVal,true);
// the MA-8 values arrays
//   ArraySetAsSeries(maVal,true);


//--- Get the last price quote using the MQL5 MqlTick Structure
   if(!SymbolInfoTick(_Symbol,latest_price))
     {
      Alert("Error getting the latest price quote - error:",GetLastError(),"!!");
      return;
     }

//--- Get the details of the latest 3 bars,default period,
   if(CopyRates(_Symbol,_Period,0,3,mrate)<0)
     {
      Alert("Error copying rates/history data - error:",GetLastError(),"!!");
      ResetLastError();
      return;
     }

//--- Copy the new values of our indicators to buffers (arrays) using the handle
   if(CopyBuffer(KDHandle,0,0,2,K)<0 || CopyBuffer(KDHandle,1,0,2,D)<0)
     {
      Alert("Error copying Stochastic KD indicator Buffers - error:",GetLastError(),"!!");
      ResetLastError();
      return;
     }
//     
   double Buy_order=0.02;  //Buy order 
   double Sell_order=0.02;
   
//--- we have no errors, so continue
//--- Do we have positions opened already?
   bool Buy_opened=false;  // variable to hold the result of Buy opened position
   bool Sell_opened=false; // variables to hold the result of Sell opened position

   if(PositionSelect(_Symbol)==true) // we have an opened position
     {
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
        {
         Buy_opened=true;  //It is a Buy
         //Print("here - " , PositionsTotal());
         Print("1-Buy_opened - Total Buy position is ", PositionGetDouble(POSITION_VOLUME));
         TTLBuy_position=PositionGetDouble(POSITION_VOLUME);
        }
      else if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
        {
         Sell_opened=true; // It is a Sell
         //Print("here - " , PositionsTotal());
         Print("1-Sell_opened - Total Sell position is ", PositionGetDouble(POSITION_VOLUME));
         TTLSell_position=PositionGetDouble(POSITION_VOLUME);
        }
     }

// Copy the bar close price for the previous bar prior to the current bar, that is Bar 1
   p_close=mrate[1].close;  // bar 1 close price
   


/*
    1. Check for a long/Buy Setup : k/d cross 20 
*/
//--- Declare bool type variables to hold our Buy Conditions
   bool Buy_Condition_1 = (K[0]>=D[0] && K[1]<=D[1]); // k>=D and K1<=D1
   bool Buy_Condition_2 = (K[1]<=20 && D[0]<=20); // k1<=20 and d<=20

   
//--- Check buy condition   
   if(Buy_Condition_1 && Buy_Condition_2)
     {
         Print("Buy-1:When buy OK, K0 is:",K[0]," D0 is:",D[0]," K1 is:",K[1]," D1 is:",D[1]);
 

angevoyageur ありがとうございます

私はこれらの変数のキャッシュを印刷し、私は前に言った、同じですが、それは信号を送信する必要があります時に、K / D値が間違っているが、それはMQL5のバグであるかどうか、correntですプログラムを見てください?

 
king1898:

angevoyageur ありがとうございます

私はこれらの変数のキャッシュを印刷し、私は前に言った、同じですが、それは信号を送信する必要があります時に、K / D値が間違っているが、それはMQL5のバグであるかどうか、correntプログラムを見てください 行う?

質問は基本的な質問ですが、下の部分でバータイムをチェックする際に問題があるのでしょうか?

//--- Do we have enough bars to work with
   if(Bars(_Symbol,_Period)<60) // if total bars is less than 60 bars
     {
      Alert("We have less than 60 bars, EA will now exit!!");
      return;
     }  

// We will use the static Old_Time variable to serve the bar time.
// At each OnTick execution we will check the current bar time with the saved one.
// If the bar time isn't equal to the saved time, it indicates that we have a new tick.

   static datetime Old_Time;
   datetime New_Time[1];
   bool IsNewBar=false;

// copying the last bar time to the element New_Time[0]
   int copied=CopyTime(_Symbol,_Period,0,1,New_Time);
   if(copied>0) // ok, the data has been copied successfully
     {
      if(Old_Time!=New_Time[0]) // if old time isn't equal to new bar time
        {
         IsNewBar=true;   // if it isn't a first call, the new bar has appeared
         if(MQL5InfoInteger(MQL5_DEBUGGING)) Print("We have new bar here ",New_Time[0]," old time was ",Old_Time);
         Old_Time=New_Time[0];            // saving bar time
        }
     }
   else
     {
      Alert("Error in copying historical times data, error =",GetLastError());
      ResetLastError();
      return;
     }

//--- EA should only check for new trade if we have a new bar
   if(IsNewBar==false)
     {
      return;
     }

//--- Do we have enough bars to work with
   int Mybars=Bars(_Symbol,_Period);
   if(Mybars<60) // if total bars is less than 60 bars
     {
      Alert("We have less than 60 bars, EA will now exit!!");
      return;
     }
 
king1898:

基本的な質問ですが、バータイムのチェックに問題はないのでしょうか?

誰が私を助けることができますか?前もってありがとうございます!
 
king1898:
私はテストしてみます!誰が私を助けることができますか?事前にありがとうございました

おかげでangevoyageur

私はあなたの別の応答をチェックし、あなたが正しいかもしれません:はい、閉じたろうそくの信号が良いですが、現在の信号が偽の信号である可能性があるとしてしかし、いくつかのフィルタと、おそらくオープンキャンドルで取引するトレーダーがあります。

私はテストしてみます

 

取引、自動取引システム、取引戦略のテストに関するフォーラム

インジケーターストキャスティック・オシレーター

ニューデジタル, 2013.10.09 07:23

ストキャスティクスでFXのトレンドトレードのエントリーをピンポイントに狙う

  • 上昇トレンドは、高値と安値で構成されています。ストキャスティクスは、トレンドの下値支持線で、リスクとリターンのバランスに優れたエントリーを見つけるために使用されます。
  • 下降トレンドは、高値と安値で構成されています。トレーダーはストキャスティクスを使って、これらの抵抗の高いポイントで、優れたリスクとリターンを得るためのエントリーを見つけることができます。
  • ストキャスティクスは、トレンドトレードにおいて、ストップの強化、ポジションサイズの縮小、利益確定のいずれかをトレーダーに警告するために使用することができます。

日足のトレンドの方向にトレードするトレーダーは、カウンタートレンドの方向にトレードするトレーダーよりも、圧倒的に高い成功率を持っています。外国為替市場の最大の魅力の一つは、トレンドが長いことであり、エントリータイミングを正確に計り、ストップでリスクを抑えれば、数百ピップス稼ぐことができる可能性があることです。


しかし、トレーダーはどのように最大の利益を得るためにリスクを伴うエントリー場所を見つけることができますか?

トレンドは終わるまで友達だ」というマントラは多くのトレーディング本に書かれていますが、多くのFXトレーダーはトレンドを友達にはしておらず、場合によってはトレンドが敵になってしまっているようです。多くのトレーダーは、トレンドに正しく乗ったトレーダーに与えられるpipsを受け取る側ではなく、トレンドと戦いながらpipsを失う「与える側」になってしまっているのです。

そんな時、ストキャスティクスを利用すれば、トレンドを味方につけることができます。


日足チャートで上昇トレンドにあるとき、ストキャスティクスの%Kと%Dが水平の基準線「20」の下に移動し、20の上に戻ってくるのは、利益確定の修正が終わりつつあることを示しています。また、ストキャスティクスのクロスアップは、買い手が再び市場に参入し始めていることを告げています。さらに、これは良いサポートがあることを示しています。

ストキャスティクスを使ったトレンドトレードの方法

トレンドに乗るには、忍耐が必要です。トレンドに乗るのが早すぎると、大きなドローダウンにさらされる可能性があります。また、トレンドに乗るのが遅れると、スイングが終了するまでに得られる利益が少なくなります。

ストキャスティクスを利用して、早すぎず遅すぎずの「ゴルディロックス」エントリーを見つけましょう。強い上昇トレンドが見つかったら、15、5、5で設定したストキャスティクスが、水平基準線20の下の売られすぎの領域に移動するのを待ちます。次に、%Kラインと%Dラインが20ラインの上に戻るのを待ちます。最後の安値の数ピップ下にストップを置いて、ロングでエントリーします。ストップの少なくとも2倍の大きさの指値を設定します。


上昇トレンドのポジションについたら、トレーダーはできるだけ多くの利益を得ようとします。通常、ストキャスティクスが買われすぎの領域に入ると、トレーダーはオープンポジションで利益を得るか、トレールストップを行います。しかし、ストキャスティクスが買われすぎの領域にあっても、通貨ペアは高値を更新し続けることがあることに注意が必要です。

トレンドが見えても、それをどう味方につければいいかわからないときは、ストキャスティクスを活用してください。ストキャスティクスによってこれらのスイングが強調されれば、ストップの配置も容易になります。 上昇トレンドにあるストキャスティクスのクロスオーバーは、大きなトレンドに参加するためのピンポイントなエントリーを助けることができます。


 

トレーディング、自動売買システム、トレーディング戦略のテストに関するフォーラム

何か面白いこと

セルゲイ・ゴルベブ, 2016.03.28 14:13

ストキャスティクスがどのように機能するかについて学んでいるトレーダーにとって、これは初心者にとって非常に良いEAです。このEAは、ストキャスティクスの買われすぎ、売られすぎのレベルを、このEAの中にあるようにコード化された次のパラメータで取引しています。

  • このEAの中でコード化されたストキャスティクス指標のパラメータ:5/3/3
  • EAでコード化される買われすぎ/売られすぎのレベル:80/20
ea_Stochastic_system - MetaTrader 4 用エキスパート
  • "アドバイザーは、指標ストキャスティックの読みを分析し、買いのための信号は、売られ過ぎゾーンでメインと信号インジケータラインの交差点であり、販売の交差点のための信号は、買われ過ぎゾーンでメインと信号ライン です。"

このEAをEURUSD M15のタイムフレームで使用するには、このセットファイル/パラメータを使用する必要があります。

このEAがどのように機能するかを確認するために、バックテストを行ってみました。バックテストの結果と、買われすぎ/売られすぎのレベルに関するアイデアを含むいくつかのチャートをご覧ください。






 

こんにちは

最近、ストキャスティクスに関する 問題に遭遇しました。

私は自分で書いたEAでトレードしています。売りのトレードをエントリーする条件の一つに、バー1のストキャスメイン<ストキャスシグナルバー1というものがあります。

GBPUSDの添付ファイルから、10:00にStoch Main Bar 1 > Stoch Signal Bar 1となっていますが、売りのtrdaeが開かれていることがわかります。

Stochsticに使った計算式は

double StochMain1T30 = iStochastic(NULL,30,10,10,3,MODE_EMA,0,MODE_MAIN,1); // T30のMODE_MAIN

double StochSignal1T30 = iStochastic(NULL,30,10,10,3,MODE_EMA,0,MODE_SIGNAL,1);//T30のMODE_SIGNAL

私が疑う可能性としては、上記のStochMain1T30 < StochSignal1T30に基づいていますが、これはチャート上に表示されているものではありません。

上記を説明するのを手伝ってくれませんか?

ブローカーのOandaに電話したところ、そのポジションは彼らによってオープンされたものではなく、EAによってオープンされたものであると言われました。

ありがとうございました。

ファイル:
 

トレーディング、自動売買システム、トレーディング戦略のテストに関するフォーラム

読んでいて面白いもの 2014年4月号

セルゲイ・ゴルベフ, 2014.04.14 20:48

Theory Of Stochastic Processes : 金融数学とリスク理論への応用を中心に



本書は、金融、保険数理、待ち行列理論、リスク理論など、現代の確率過程の理論とその応用における主要なトピックをすべて網羅した演習集である。

本書の目的は、読者が確率過程の理論とその関連分野の主要なトピックをより深く理解するために必要な理論と実践的な材料を提供することである。

本書は,様々なトピックにしたがって章立てされている.各章には、問題、ヒント、解答、および問題を解くために必要なすべての材料を与える自己完結型の理論部分が含まれています。また、文献の紹介もあります。

練習問題には様々なレベルがあり、基本的な概念や技術を学ぶ学生にとって有用な簡単なものから、重要な理論的事実や構造を明らかにする非常に高度なものまで、様々なものが用意されています。

本書は,確率過程の理論とその応用に関する問題集としては,最大級のものである.本書は,確率過程の理論とその応用に関する最大級の問題集であり,学部生,大学院生,そして確率過程の専門家にとって有用なものである.