[英]How to group a lot exponent in MQL4 / MT4?
我設法獲得了正常的批次指數,但我需要通過對圖片中的示例進行分組來對其進行一些更改。 有人可以指導我如何獲得批量指數但使用分組技術 Group= 5 Exponent= 1.8嗎?
double GroupExponent(int type)
{
double lot=0,exponent=1.8,group=5,initialLot=0.01;
if(type==OP_SELL)
............. //<---- Do i need to loop this area ?
lot= initialLot * MathPow(exponent,TotalSell());
return lot;
}
int TotalSell()
{
int Sell=0;
for(int trade=OrdersTotal()-1; trade>=0; trade--)
{
if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))continue;
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL))
Sell++;
}
return Sell;
}
不,你不需要循環。 您可以像這樣獲得圖層系統:
double GroupExponent(int type)
{
double lot=0,exponent=1.8,initialLot=0.01;
int group = 5;
if(type==OP_SELL)
{
lot = NormalizeDouble(initialLot * MathPow(exponent, (TotalSell() - 1) / group), 2);
}
return lot;
}
int TotalSell()
{
int Sell=0;
for(int trade=OrdersTotal()-1; trade>=0; trade--)
{
if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))continue;
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL))
Sell++;
}
return Sell;
}
注意:只有當Layer == 1
等於TotalSell() == 1
這才會按預期工作。 如果Layer == 1
等於TotalSell() == 0
,則不需要從TotalSell()
內的MathPow()
減去 1。
問: “如何在 MQL4 / MT4 中對大量指數進行分組?”
好吧,從技術上講,指數 = 1.8本身並不是指數,而是一個縮放常數,它被普通序數取冪。
請參閱與上表匹配的批量大小的計算公式:
|
|>>> for aLayerNUMBER in range( 1, 11 ):
... aVolumeInLOTs = 0.01 * ( 1.8 ** ( aLayerNUMBER - 1 ) )
... print "LAYER: {0: >2d} - {1: >5.2f} Lots".format( aLayerNUMBER,
... aVolumeInLOTs
... )
...
LAYER: 1 - 0.01 Lots
LAYER: 2 - 0.02 Lots
LAYER: 3 - 0.03 Lots
LAYER: 4 - 0.06 Lots
LAYER: 5 - 0.10 Lots
LAYER: 6 - 0.19 Lots
LAYER: 7 - 0.34 Lots
LAYER: 8 - 0.61 Lots
LAYER: 9 - 1.10 Lots
LAYER: 10 - 1.98 Lots
+0:01:07.587141
13:31:06
|
|>>>
在 MQL4 中,最常見的是:
double aVolumeInLOTs = NormalizeDouble( 0.01 * MathPow( 1.8, aLayerNUMBER - 1 ), 2 );
分組是(此處)5 筆交易的組,每筆都具有相同的規模/交易量,
再次在 ( 0.01, 0.02, 0.03, 0.06, 0.10, 0.19, 0.34, 0.61, 1.10, 1.98, 3.57, 6.42, 11.56, 20.82, 0.06, 0.10, 0.19, 0.34, 0.61, 1.10, 1.98, 3.57, 6.42, 11.56, 20.82, 0.06, 36, 36, 36, 36, 39, 37, 36, 36
拼圖的最后一部分是一個原因,從哪里停止生產 5 筆交易組(為什么在第四組 5 筆交易時停止,每個 0.06 手,而不是繼續進行下去)。
該信息不存在於問題中,因此顯然對我們來說仍然是不可確定的,除非添加更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.