[求助]怎么修改这个脚本的最低下单手数
网上找到的脚本,下单最低手数0.1,怎么改成0.01,先谢谢了。
//+---------------------------------------------+
//| BatchOpen.mq4 |
//| [email protected] |
//| www.talkfx.com |
//+---------------------------------------------+
#property copyright "[email protected]"
#property link "www.talkfx.com"
#property show_inputs
#include
extern bool ActionBuy = true;
extern double RangeStart = 1.1850;
extern double RangeEnd = 1.1870;
extern double TotalLots = 1.0;
extern int OrderCount = 5;
extern int Slippage = 0;
extern double StopLoss = 0.0;
extern double TakeProfit = 0.0;
extern string Comments = "BatchOpen Auto Generated";
extern datetime Expiration = 0;
extern int Delay = 0;
#define BATCH_OPEN_MAGIC 06021610
//+---------------------------------------------+
//|script program start function |
//+---------------------------------------------+
int ActionType = 0;
int start()
{
//----
//inputs checking
if (OrderCount < 2) {
MessageBox("Not enough OrderCount, must be greater than 1 at least");
return (-1);
}
double LotsPerOrder, LotsLeft;
int i, n;
n = TotalLots * 10/OrderCount;
LotsPerOrder = n;
LotsPerOrder /= 10;
LotsLeft = TotalLots - LotsPerOrder * OrderCount;
if (LotsPerOrder < 0.1) {
MessageBox("Not enough TotalLots or too many OrderCount, each order must be 0.1 lots at least");
return (-1);
}
if (LotsPerOrder + LotsLeft >= 10000) {
MessageBox("Too many TotalLots, each order must be less than 10000 lots");
return (-1);
}
n = NormalizeDouble((MathAbs(RangeStart - RangeEnd) * MathPow(10, Digits)), 0)/(OrderCount-1);
if (n < 1) {
MessageBox("Too many OrderCount, each order must have 1 pips diff at least");
}
double volume, price;
string symbol;
int cmd, magic, ticket, cnt, failed;
symbol = Symbol();
magic = BATCH_OPEN_MAGIC;
volume = LotsPerOrder;
cnt = 0;
failed = 0;
for (i = 0; i < OrderCount; i++) {
price = RangeStart + i * n * Point;
if (i == OrderCount-1) {
volume += LotsLeft;
//price = RangeEnd;
}
RefreshRates();
if (ActionBuy) {
if (price < Ask) {
cmd = OP_BUYLIMIT;
} else {
cmd = OP_BUYSTOP;
}
} else {
if (price < Bid) {
cmd = OP_SELLSTOP;
} else {
cmd = OP_SELLLIMIT;
}
}
ticket = OrderSend(symbol, cmd, volume, price, Slippage, StopLoss,
TakeProfit, Comments, magic, Expiration, CLR_NONE);
if (ticket < 0) {
Print("Failed to place order at price " + price + ", Error: " + ErrorDescription(GetLastError()));
failed++;
} else {
cnt++;
}
Sleep(Delay);
}
//----
Print(cnt + " orders placed, " + OrderCount + " requested, " + failed + " failed");
return(0);
}
//+---------------------------------------------+
发表于:2018-03-03 12:13只看该作者
2楼
LotsPerOrder /= 10;
这个代码的意思是要分10份,所以,就算把这个代码
LotsPerOrder < 0.1
从 0.1 改成 0.01
依然跑不掉要有0.1手。
但你可以试试开个美分账户,这样就能用更小的下单量跑了。
3楼
hizz 发表于 2018-3-3 20:13
LotsPerOrder /= 10; 这个代码的意思是要分10份,所以,就算把这个代码 LotsPerOrder < 0.1
韬客社区www.talkfx.co
发表于:2018-03-04 00:57只看该作者
4楼
本帖最后由 scalping 于 2018-3-4 09:04 编辑
TotalLots/OrderCount
1.0/5=0.2,挂5个单,加起来到1手,就是说每个单是0.2手。就是这个个关系。
修改TotalLots参数为0.05,不用改程序。只能帮你到这儿。
发表于:2018-03-04 01:49只看该作者
5楼
n = TotalLots * 10/OrderCount;
LotsPerOrder = n;
LotsPerOrder /= 10;
LotsLeft = TotalLots - LotsPerOrder * OrderCount;
-----------------------------
不明白 n = TotalLots * 10/OrderCount;
LotsPerOrder = n;
推出:
LotsPerOrder =TotalLots * 10/OrderCount;
LotsPerOrder /= 10;
推出:
LotsPerOrder =TotalLots /OrderCount;
LotsLeft = TotalLots - LotsPerOrder * OrderCount;
推出
LotsLeft = TotalLots - TotalLots /OrderCount * OrderCount;
推出
LotsLeft =TotalLots - TotalLots
推出
LotsLeft =0
LotsLeft 恒等于0
LotsLeft 什么鬼
韬客社区www.talkfx.co
发表于:2018-03-04 02:01只看该作者
6楼
int i, n;
n = TotalLots * 10/OrderCount;
LotsPerOrder = n;
LotsPerOrder /= 10;
LotsLeft = TotalLots - LotsPerOrder * OrderCount;
if (LotsPerOrder < 0.1) {
MessageBox("Not enough TotalLots or too many OrderCount, each order must be 0.1 lots at least");
return (-1);
}
if (LotsPerOrder + LotsLeft >= 10000) {
----------------------
n是整数
LotsLeft 是 n个订单之后剩余的不够一单的数量
算这个没有什么意义
删了就是
下面:
int i;
LotsPerOrder = TotalLots /OrderCount;
if (LotsPerOrder < 0.01) {
MessageBox("Not enough TotalLots or too many OrderCount, each order must be 0.1 lots at least");
return (-1);
}
if (LotsPerOrder >= 10000) {
韬客社区www.talkfx.co
7楼
谢楼上两位
韬客社区www.talkfx.co