0
我正在學習MQL4。我在IQOptions註冊二元期權交易。如何解決MQL4中N-bars階段的分形,類似於IQOptions分形指標?
我打算爲自己的交易系統自己寫一些指標。我非常喜歡分形,不是來自MQL4支持的分形邏輯,但非常熱衷於IQOptions特定的分形。
在MQL4中,找到我們使用的分形除了偏移之外,它沒有采用任何參數。
我相信自己,它只是發現3分以上的分形。做了很多功課,我意識到IQOptions指標不僅僅是分形。請查找附件截圖。
我寫了很多程序,我在下面添加了一個最近的程序。我需要一些幫助來弄清楚它在那裏。我附上的圖片來自IQOption截圖,分形超過20巴時期。
//+------------------------------------------------------------------+
//| Bulls.mq4 |
//| Copyright 2005-2014, MetaQuotes Software Corp. |
//| http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "2005-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Fractals Tanya"
#property strict
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_width1 1
#property indicator_width2 1
#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
//--- input parameter
input int B_F=20;
//extern int AllB=240;
//--- buffers
double ExtFractalsUPBuffer[];
double ExtFractalsDownBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit(void)
{
//--- 1 additional buffer used for counting.
IndicatorBuffers(2);
IndicatorDigits(Digits);
//--- indicator line
SetIndexBuffer(0, ExtFractalsUPBuffer);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 234);
SetIndexLabel(0, NULL);
SetIndexEmptyValue(0, 0.0);
SetIndexBuffer(1, ExtFractalsDownBuffer);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 233);
SetIndexLabel(1, NULL);
SetIndexEmptyValue(1, 0.0);
SetIndexDrawBegin(0,B_F);
SetIndexDrawBegin(1,B_F);
IndicatorShortName("FractalsTanya");
IndicatorDigits(Digits);
}
//+------------------------------------------------------------------+
//| Bulls Power |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int limit=rates_total-prev_calculated;
//---
if(rates_total<=B_F || B_F<=0)
return(0);
//---
if(prev_calculated>0)
limit++;
int i=0,j=0,k=0;
double upFratal=0.0;
double downFratal=0.0;
int x=0; int y=0;
for(int t=0; t<limit+B_F; t++)
{
double upTempFractal=iFractals(NULL,Period(),MODE_UPPER,t);
double downTempFractal=iFractals(NULL,Period(),MODE_LOWER,t);
if(upTempFractal!=0&&upTempFractal>upFratal)
{
upFratal=upTempFractal;
j=t;
}
if(downTempFractal!=0.0&&downFratal==0.0)
{
downFratal=downTempFractal;
}
if(downTempFractal!=0.0&&downTempFractal<=downFratal)
{
downFratal=downTempFractal;
k=t;
}
i++;
if(i==B_F)
{
if(upFratal!=0.0)
{
if(x==0||(j-x)>=B_F)
{
x=j;
ExtFractalsUPBuffer[j]=upFratal;
}
}
if(downFratal!=0.0)
{
if(y==0||(k-y)>=B_F)
{
y=k;
ExtFractalsDownBuffer[k]=downFratal;
}
}
i=0;
upFratal=0.0;
downFratal=0.0;
}
}
/*for(int t=0; t<limit; t++)
{
double upFratal=iFractals(NULL,Period(),MODE_UPPER,t);
double downFratal=iFractals(NULL,Period(),MODE_LOWER,t);
if(upFratal!=0.0)ExtFractalsUPBuffer[t]=upFratal;
else if(downFratal!=0.0)ExtFractalsDownBuffer[t]=downFratal;
}*/
return(rates_total);
}
你能否澄清一下,你有什麼問題 - 你在MCVE-的代碼面臨什麼樣的問題,與你試圖解決一些行爲/功能,但以前的到目前爲止,結果並沒有顯示出有用的結果? – user3666197
其實,我在定製分形方法後最終解決了這個問題。我發佈的屏幕截圖雖然是我期望的行爲,但我不認爲它是一個真正的分形邏輯。我們可以通過找到每個(i + 20/2)燭光高/低值並檢查所有i + 20到i + 10蠟燭和i + 10到i蠟燭高/低於i + 10燭高/低價值 – VyshuRam