extern int Magic_Number = 412625; // set this to a unique number if you intend to use the script simulataneously across many charts on the same account.
extern int UserDefinedSpread = 0; // set this to 0 if you want to use market spread. valid value is >= 0
extern double LotSize = 0.1;
extern int Slippage = 3;
extern int StopLoss = 25; // If you set StopLoss to 0, no stop loss level will be placed.
extern int TakeProfit = 0; // If you set TakeProfit to 0, no stop loss level will be placed.
extern bool OneCancelsOther = true; // This determines if you want the script to stay running and track, then delete the opposite pending order when an order has executed.
extern int NumOfCandles = 3; // This determines how many previous candles you want the EA to look for the High Lows. (buy and sell prices). valid value is > 0
extern int PositionalMarginPips = 40; // The distance excluding spread from the high lows for the opening prices. valid value is >= 0
extern int intervalseconds = 1.0; //The time interval for the script to check your trades. allows fractional seconds.
非lagzigzag信号问题
嗨,kevin07。
非lagzigzag的警报是有效的,但它们没有对应的zigzag线。我已经收到了几个警报,但人字形线并没有画出来。另外,当我第一次加载该指标时,它给出了一个警报。你能不能看一下代码,看看你能不能发现问题所在?邮件提醒也很好用,谢谢你的加入。如果您能提供任何帮助,我将非常感激。
最好的问候,汤姆
nonlagzigzag
你好,tk748,当你加载indi时弹出的初始警报告诉你自上一个最高点或最低点(可能发生在几个蜡烛之前)以来的当前交易方向。很遗憾听到中间警报在下一条线被画出来之前就已经发出了。警报的IF语句可以有一个额外的过滤器来检查CurrentDirection != PreviousDirection,这样在下一条线被画出来之前就不会有额外的警报出现。(我正在完成我的EA,现在不能为你解决这个问题)。白天,我必须工作。在晚上,我必须睡觉。没有EA,我不会有很多(任何)交易。我的首要任务是使用人字形或波动性指标作为过滤器,以防止一些无利可图的交易开盘。
如果我在这个过程中发现如何添加这个额外的代码,我会让你知道。
最好的祝愿,kevin07
跨期交易脚本
我得到了这个脚本,但我希望能有一个设置定时器的选项,让它在伦敦开盘时进行交易......添加这个有多难,你能给我指出正确的方向,或给我看一下代码吗?
像往常一样...我很感谢您的帮助!!
#include
#include
#define LOOK_TO_BUY 1
#define LOOK_TO_SELL 2
extern int Magic_Number = 412625; // set this to a unique number if you intend to use the script simulataneously across many charts on the same account.
extern int UserDefinedSpread = 0; // set this to 0 if you want to use market spread. valid value is >= 0
extern double LotSize = 0.1;
extern int Slippage = 3;
extern int StopLoss = 25; // If you set StopLoss to 0, no stop loss level will be placed.
extern int TakeProfit = 0; // If you set TakeProfit to 0, no stop loss level will be placed.
extern bool OneCancelsOther = true; // This determines if you want the script to stay running and track, then delete the opposite pending order when an order has executed.
extern int NumOfCandles = 3; // This determines how many previous candles you want the EA to look for the High Lows. (buy and sell prices). valid value is > 0
extern int PositionalMarginPips = 40; // The distance excluding spread from the high lows for the opening prices. valid value is >= 0
extern int intervalseconds = 1.0; //The time interval for the script to check your trades. allows fractional seconds.
double BuyPrice = 0;
double SellPrice = 0;
int CustomSpread = 0;
bool KeepRunning = true;
int ticketToDelete = 0;
void GetPrices()
{
double HighestHigh = High[1];
if (NumOfCandles > 1)
{
for (int i=2; i<=NumOfCandles; i++)
{
if (High > HighestHigh)
{
HighestHigh = High;
}
}
}
BuyPrice = HighestHigh + (PositionalMarginPips * Point);
BuyPrice = NormalizeDouble(BuyPrice,Digits);
double LowestLow = Low[1];
if (NumOfCandles > 1)
{
for (i=2; i<=NumOfCandles; i++)
{
if (Low < LowestLow)
{
LowestLow = Low;
}
}
}
SellPrice = LowestLow - (PositionalMarginPips * Point);
BuyPrice = NormalizeDouble(BuyPrice,Digits);
}
void PlaceTrades()
{
double TakeProfitPrice, StopLossPrice;
if (TakeProfit==0)
{
TakeProfitPrice = 0;
}
else
{
TakeProfitPrice = BuyPrice + (TakeProfit * Point);
TakeProfitPrice = NormalizeDouble(TakeProfitPrice,Digits);
}
if (StopLoss == 0)
{
StopLossPrice = 0;
}
else
{
StopLossPrice = BuyPrice - (StopLoss * Point);
StopLossPrice = NormalizeDouble(StopLossPrice,Digits);
}
SendOrders (LOOK_TO_BUY, LotSize, BuyPrice, Slippage, StopLossPrice, TakeProfitPrice, "Straddle Buy", 0);
if (TakeProfit==0)
{
TakeProfitPrice = 0;
}
else
{
TakeProfitPrice = SellPrice - (TakeProfit * Point);
TakeProfitPrice = NormalizeDouble(TakeProfitPrice,Digits);
}
if (StopLoss == 0)
{
StopLossPrice = 0;
}
else
{
StopLossPrice = SellPrice + (StopLoss * Point);
StopLossPrice = NormalizeDouble(StopLossPrice,Digits);
}
SendOrders (LOOK_TO_SELL, LotSize, SellPrice, Slippage, StopLossPrice, TakeProfitPrice, "Straddle Sell", 0);
}
void SendOrders (int BuyOrSell, double LotSize, double PriceToOpen, double Slippage, double SL_Price, double TP_Price, string comments, datetime ExpirationTime)
{
int PositionType, ticket, errorType;
if (BuyOrSell == LOOK_TO_BUY)
{
if (PriceToOpen > Ask)
{
PositionType = OP_BUYSTOP;
}
if (PriceToOpen < Ask)
{
PositionType = OP_BUYLIMIT;
}
Print("Bid: "+Bid+" Ask: "+Ask+" | Opening Buy Order: "+Symbol()+", "+PositionType+", "+LotSize+", "+PriceToOpen+", "+Slippage+", "+SL_Price+", "+TP_Price+", "+comments+", "+Magic_Number+", "+ExpirationTime+", Green");
ticket=OrderSend(Symbol(),PositionType,LotSize,PriceToOpen,Slippage,SL_Price,TP_Price,comments,Magic_Number,ExpirationTime,CLR_NONE);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
Print("BUY order opened : ",OrderOpenPrice());
}
}
else
{
errorType = GetLastError();
Print("Error opening BUY order : ", ErrorDescription(errorType));
}
}
if (BuyOrSell == LOOK_TO_SELL)
{
if (PriceToOpen < Bid)
{
PositionType = OP_SELLSTOP;
}
if (PriceToOpen > Bid)
{
PositionType = OP_SELLLIMIT;
}
Print("Bid: "+Bid+" Ask: "+Ask+" | Opening Sell Order: "+Symbol()+", "+PositionType+", "+LotSize+", "+PriceToOpen+", "+Slippage+", "+SL_Price+", "+TP_Price+", "+comments+", "+Magic_Number+", "+ExpirationTime+", Red");
ticket=OrderSend(Symbol(),PositionType,LotSize,PriceToOpen,Slippage,SL_Price,TP_Price,comments,Magic_Number,ExpirationTime,CLR_NONE);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
Print("Sell order opened : ",OrderOpenPrice());
}
}
else
{
errorType = GetLastError();
Print("Error opening SELL order : ", ErrorDescription(errorType));
}
}
}
void GetSpread()
{
if (UserDefinedSpread <= 0)
{
CustomSpread = MarketInfo(Symbol(),MODE_SPREAD);
}
else
{
CustomSpread = UserDefinedSpread;
}
}
int GetNumberOfPending()
{
int count = 0;
int total = OrdersTotal();
if (total > 0)
{
for(int cnt=0;cnt<total;cnt++)
{
if(OrderSelect(cnt,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber() == Magic_Number)
{
if(OrderType() != OP_BUY && OrderType() != OP_SELL)
{
ticketToDelete = OrderTicket();
count++;
}
}
}
}
}
return (count);
}
void ManageTrades()
{
// If there's only one pending trade left, assume the other one is opened.
// So Delete this one.
if (GetNumberOfPending() == 1)
{
if (OrderDelete(ticketToDelete))
{
KeepRunning = false;
Alert ("Straddle script has ended");
}
}
}
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
GetSpread();
GetPrices();
PlaceTrades();
Alert ("Pending Trades Placed. Please Wait...");
int intervalMilliseconds = intervalseconds * 1000;
while (KeepRunning && OneCancelsOther)
{
Sleep(intervalMilliseconds);
ManageTrades();
}
//----
return(0);
}
//+------------------------------------------------------------------+
nonlagzigzag警报
嗨,kevin07。
感谢你在这个指标上所做的工作。也许在你的EA编码过程中,你会有一个想法,如何使信号 在适当的时间出现。在此期间,也许这里的其他人会有时间来解决这个问题。祝你的EA好运。
谢谢。
汤姆
请帮助我添加Matigale代码
我刚刚用这个网站制作了这个EA。Expert Advisor Builder for MetaTrader 4,基于简单的交易规则。
你可以试试这个EA,看看效果如何。请设置SL=100,TP=300,追踪止损=70,并在EUR/USD H4上运行。
请你帮助我用马蒂盖尔来交易这个系统。
使用一个金额,使100点=账户余额的2%。
如果交易n-1 亏损,则加倍交易n 的金额,直到盈利平仓。
非常感谢您!
我刚刚用这个网站制作了这个EA。MetaTrader 4的专家顾问生成器,基于简单的交易规则。
你可以试试这个EA来看看结果。请设置SL=100,TP=300,追踪止损=70,在欧元/美元H4上运行。
请您帮助我用马蒂盖尔来交易这个系统。
使用一个金额,使100点=账户余额的2%。
如果交易n-1 失败了,就把交易n 的金额翻倍,直到盈利平仓。
非常感谢您!朋友们,花点时间是值得的!这是没有马蒂格尔代码的交易结果。初始存款:10000;每笔交易1手。SL = 100; TP = 300; Trailing ST: 70; EUR/USD H4.
你是如何简化这段代码的?
如果a和b之间的差值<=c,那么交易=真,否则为假。
到目前为止,这是我所做的,如果有人能告诉我一个更短的代码方式。
if ( a >= b)
{
如果(a - b <= c ) trade = true。
如果(a - b > c) trade = false。
}
如果 ( a < b )
{
如果(b - a <= c ) trade = true;
如果 (b - a > c) trade = false;
}
试试这个(我假设c>=0)。
问候
mladen
你如何简化这段代码?
如果a和b之间的差值<=c,则交易=真,否则为假。
到目前为止,这是我所做的,如果有人能告诉我一个更短的方法来编写这个代码。
if ( a >= b)
{
如果(a - b <= c ) trade = true。
如果(a - b > c) trade = false。
}
如果 ( a < b )
{
如果(b - a <= c ) trade = true;
如果 (b - a > c) trade = false;
}试试这个(我假设c>=0)
问候
mladen谢谢你......我之前一直在寻找这样的东西......谢谢......。
测试 NonLagZigZag_Signal_v2 警报
嗨,kevin07。
谢谢......也许......你会对如何使信号在适当的时间出现有一个想法......。
谢谢。
汤姆嘿,汤姆。
我能够回到这个ZigZag indi并过滤掉中间的警报。我立即发送这个,还没有测试。如果你发现它有任何与警报有关的问题,请让我知道。
谢谢
kevin07