스토캐스틱 - 페이지 6

 
king1898 :

이 그림에서 두 개의 화살표는 두 개의 신호를 생성해야 하지만 내 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의 버그인지 여부는 정확합니까?

 
king1898 :

angevoyageur님 , 감사합니다!

나는 이러한 변수 캐시를 출력하고 전에 말했지만, 신호를 보내야 할 시점에 동일하지만 K/D 값이 잘못되었지만 프로그램을 보면 이것이 MQL5의 버그인지 여부는 정확합니까?

질문이 기본질문인데 아래 부분에서 바시간 확인에 문제가 있나요?

 //--- 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 :
누가 날 도울 수 있죠? 미리 감사드립니다!

감사 합니다

나는 당신의 다른 답장을 확인했는데 당신이 맞을 수도 있습니다. 예, 현재의 신호가 잘못된 신호일 수 있으므로 닫힌 양초의 신호가 더 좋습니다. 열린 양초에서 거래하는 거래자가 있지만 아마도 일부 필터가 있을 것입니다.

나는 테스트를 시도합니다!

 

거래, 자동 거래 시스템 및 거래 전략 테스트에 관한 포럼

지표: 스토캐스틱 오실레이터

뉴디지털 , 2013.10.09 07:23

스토캐스틱으로 Forex 추세 거래 항목을 정확히 찾아내기

  • 상승 추세는 더 높은 고점과 더 높은 저점으로 구성됩니다. 거래자는 스토캐스틱을 사용하여 추세의 낮은 지지점에서 진입한 항목에 대해 보상할 우수한 위험을 찾을 수 있습니다.
  • 하락 추세는 낮은 고점과 낮은 저점으로 구성됩니다. Forex 거래자는 스토캐스틱을 사용하여 이러한 저항이 높은 지점에서 항목을 보상할 수 있는 우수한 위험을 찾을 수 있습니다.
  • 스토캐스틱은 외환 거래자에게 중지를 강화하거나, 포지션 규모를 줄이거나, 추세 거래에서 한 번 이익을 취하도록 경고하는 데 사용할 수 있습니다.

지금까지 우세한 일일 추세 방향으로 거래하는 거래자는 반대 추세를 거래하는 거래자보다 성공 비율이 더 높습니다. Forex 시장의 가장 큰 매력 중 하나는 트레이더가 정확한 진입 시간을 설정하고 위험을 제한하기 위해 보호 스탑을 사용하는 경우 수백 핍을 만들 수 있는 잠재력을 제공하는 긴 추세가 특징입니다.


그러나 거래자는 최대 이익을 위해 위험을 감수하고 진입할 위치를 어떻게 찾을 수 있습니까?

"추세는 끝날 때까지 친구입니다."라는 주문은 많은 거래 서적에서 찾을 수 있지만 많은 외환 트레이더는 추세를 친구로 만들지 않고 어떤 경우에는 추세가 적이 된 것 같습니다. 추세에 올바르게 진입한 거래자에게 제공되는 핍을 받는 쪽이 아니라 많은 거래자가 추세와 싸우면서 거래 손실 핍을 "주는" 쪽이 되었습니다.

사람들이 이상적인 짝을 만나기 위해 온라인 데이트 서비스로 눈을 돌리면서 외환 거래자들은 추세를 다시 친구로 만드는 방법으로 스토캐스틱을 사용할 수 있습니다.


일봉 차트의 상승세에서 스토캐스틱 %K 및 %D선이 수평 '20' 기준선 아래로 이동했다가 20선 위로 다시 올라가면 차익실현 조정이 끝나가고 있음을 나타냅니다. 확률적 교차는 또한 구매자가 시장에 다시 진입하기 시작했음을 알려줍니다. 또한 이것은 좋은 지원이 있음을 보여줍니다.

스토캐스틱을 사용하여 추세를 거래하는 방법

인내는 추세와 거래를 시도할 때 게임의 이름입니다. 추세에 너무 일찍 진입하면 거래자가 큰 손실을 입을 수 있습니다. 너무 늦게 입장하면 스윙이 완료되기 전에 이익이 줄어듭니다.

너무 이르거나 너무 늦지 않은 "Goldilocks" 진입을 찾기 위해 확률 지표를 사용하십시오. 강한 상승 추세가 발견되면 15, 5, 5 설정의 스토캐스틱이 20 수평 기준선 아래의 과매도 영역으로 이동할 때까지 기다리십시오. 다음으로, %K 및 %D 라인이 20 라인 위로 다시 이동할 때까지 기다립니다. 마지막 저점보다 몇 핍 아래에 스톱을 두고 매수하십시오. 정지 크기의 최소 두 배에 대한 제한을 설정하십시오.


일단 상승세에 있으면 트레이더는 최대한 많은 이익을 얻으려고 할 것입니다. 트레이더는 일반적으로 스토캐스틱이 과매수 영역으로 이동하면 오픈 포지션이나 트레일 스톱에서 이익을 얻습니다. 스토캐스틱이 과매수 영역에 있더라도 외환 통화 쌍은 계속해서 새로운 최고치를 달성할 수 있다는 점에 유의하는 것이 중요합니다.

따라서 다음에 추세를 보고 그것을 "친구"로 만드는 방법을 모를 때 스토캐스틱 지표가 여러분을 소개합니다! 이러한 스윙이 스토캐스틱에 의해 강조 표시되면 스톱 배치도 더 쉬워집니다. 상승 추세의 스토캐스틱 교차는 주요 추세에 합류할 항목을 정확히 찾아내는 데 도움이 될 수 있습니다.


 

거래, 자동 거래 시스템 및 거래 전략 테스트에 관한 포럼

흥미로운 것

세르게이 골루베프 , 2016.03.28 14:13

이것은 초보자에게 매우 좋은 EA입니다. 작동 방식에 대한 확률 지표를 배우는 거래자에게 적합합니다. EA는 이 EA 내부에 코딩된 다음 매개변수를 사용하여 스토캐스틱 지표의 과매수/과매도 수준에서 거래하고 있습니다.

  • 이 EA 내부에 코딩된 확률적 지표의 매개변수 : 5/3/3
  • EA에 코딩할 과매수/과매도 수준 : 80/20
ea_Stochastic_system - MetaTrader 4 전문가
  • " Advisor는 스토캐스틱 지표의 판독값을 분석하고, 구매 신호는 과매수 영역의 주요 및 신호 표시 라인의 교차점이며, 판매 교차 신호는 과매수 영역의 주요 지표 및 신호 라인입니다 ."

코더는 이 EA에 대한 세트 파일을 제안하여 이 세트 파일/매개변수에 따라 EURUSD M15 기간에 이 EA를 사용할 수 있습니다.

나는 그것이 어떻게 작동하는지 보기 위해 EA를 백테스트했습니다. 백테스팅 결과와 과매수/과매도 수준에 대한 아이디어가 포함된 차트를 찾으십시오.






 

안녕

나는 최근에 stochastic 에 관한 문제에 직면했습니다.

내가 직접 작성한 EA와 거래합니다. 매도를 위한 거래를 하기 위한 조건 중 하나는 Stoch Main at bar 1 < Stoch Signal Bar 1 입니다.

GBPUSD에 대한 첨부 파일을 보면 10:00에 Stoch Main Bar 1 > Stoch Signal Bar 1이지만 매도용 trdae가 열려 있음을 알 수 있습니다.

내가 Stochstic에 사용한 공식은

이중 StochMain1T30 = iStochastic(NULL,30,10,10,3,MODE_EMA,0,MODE_MAIN,1); // T30 모드_메인

이중 StochSignal1T30 = iStochastic(NULL,30,10,10,3,MODE_EMA,0,MODE_SIGNAL,1); // T30 모드_시그널

내가 의심하는 한 가지 가능성은 위의 StochMain1T30 < StochSignal1T30을 기반으로 하지만 차트에서 볼 수 있는 것과는 다릅니다.

위의 설명을 도와드릴까요?

브로커인 Oanda에게 전화를 걸어보니 그 포지션은 자신이 열지 않았고 EA가 열었습니다.

고맙습니다.

파일:
 

거래, 자동 거래 시스템 및 거래 전략 테스트에 관한 포럼

읽을거리 2014년 4월

세르게이 골루베프 , 2014.04.14 20:48

확률적 과정 이론: 금융 수학 및 위험 이론에 적용



이 책은 금융, 보험계리수학, 대기행렬이론, 위험이론을 포함하여 현대 확률과정 이론과 그 응용의 모든 주요 주제를 다루는 연습문제 모음집입니다.

이 책의 목적은 확률적 과정 이론과 관련 분야의 주요 주제를 더 깊이 이해하는 데 필요한 이론적이고 실용적인 자료를 독자에게 제공하는 것입니다.

이 책은 다양한 주제에 따라 챕터로 나뉘어져 있습니다. 각 장에는 문제, 힌트, 솔루션뿐만 아니라 문제 해결에 필요한 모든 자료를 제공하는 독립적인 이론 부분이 포함되어 있습니다. 문헌에 대한 참조도 제공됩니다.

연습 문제는 다양한 수준의 복잡성을 가지고 있으며 기본 개념과 기술을 공부하는 학생들에게 유용한 간단한 것부터 몇 가지 중요한 이론적 사실과 구성을 보여주는 고급까지 다양합니다.

이 책은 확률적 과정 이론과 그 응용 분야의 가장 큰 문제 모음 중 하나입니다. 이 책의 문제는 학부 및 대학원생은 물론 확률적 과정 이론 전문가에게 유용할 수 있습니다.