//+------------------------------------------------------------------+ //| SearchOrder function | //+------------------------------------------------------------------+ int SearchOrder (int MagicNumber,int Order_Type) { //---- int Ticket=-1; for ( int i = OrdersTotal() - 1; i >= 0; i -- ) { if ( !OrderSelect( i, SELECT_BY_POS ) ) {Print("OrderSelect(",i,",SELECT_BY_POS) - Error #",GetLastError()); continue; } if (OrderSymbol()!=Symbol())continue; if (OrderMagicNumber()!=MagicNumber )continue; if ( OrderType()==Order_Type) Ticket=OrderTicket(); } //---- return(Ticket); } // End of SearchFunction //+------------------------------------------------------------------+ //| CloseOrder function | //+------------------------------------------------------------------+ void CloseOrder(int Order_Ticket) { //---- if (!OrderSelect(Order_Ticket,SELECT_BY_TICKET ) ) Print("OrderSelect(",OrderTicket(), ",SELECT_BY_POS) - Error #",GetLastError() ); //- if(OrderType()==OP_BUY) if (!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue)) Print("OrderClose(",OrderTicket(), ",SELL) - Error #",GetLastError() ); if(OrderType()==OP_SELL) if (!OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Blue)) Print("OrderClose(",OrderTicket(), ",SELL) - Error #",GetLastError() ); //---- } // End of CloseOrder //+------------------------------------------------------------------+ //| TrailStop function | // refer to https://book.mql4.com/trading/ordermodify | //+------------------------------------------------------------------+ void TrailStop() { string Text=""; bool Modify=false; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderType()<=1 ) { int Tip=OrderType(); double SL=OrderStopLoss(); // SL of the selected order double TP =OrderTakeProfit(); // TP of the selected order double Price =OrderOpenPrice(); // Price of the selected order int Ticket=OrderTicket(); // Ticket of the selected order. double TS=Trail_Stop; // Initial value int Min_Dist=MarketInfo(Symbol(),MODE_STOPLEVEL);//Min. distance if (TS<Min_Dist) TS=Min_Dist; // If less than allowed // New value of TS switch(Tip) // By order type Tip ==0 { case 0 : // Order Buy if (NormalizeDouble(SL,Digits)< NormalizeDouble(Bid-TS*Point,Digits)) // If it is lower than we want { SL=Bid-TS*Point; // then modify SL price Text="Buy Trail Stop "; // Text for Buy order trail stop Modify=true; // To be modified } break; // Exit 'switch' case 1 : // Order Sell,Tip ==1 if (NormalizeDouble(SL,Digits)> NormalizeDouble(Ask+TS*Point,Digits) // If it is higher than we want || NormalizeDouble(SL,Digits)==0)//or equal to zero,it means we did not set stop less when open order { SL=Ask+TS*Point; // then modify it Text="Sell Trail Stop "; // Text for Sell Modify=true; // To be modified } break; // Exit 'switch' } // End of 'switch' //--------------------------------------------------- 5 -- if(Modify == true) { // Alert ("Modification ",Text,Ticket,". Awaiting response.."); bool Ans=OrderModify(Ticket,Price,SL,TP,0,Blue);//Modify it! } //--------------------------------------------------- 6 -- if (Ans==true) // Got it! :) { // Alert ("Order ",Text,Ticket," is modified:)"); break; // From modification cycle. } //--------------------------------------------------- 7 -- if(Ans==false) { int Error=GetLastError(); // Failed :( switch(Error) // Overcomable errors { case 130:Alert("Wrong stops. Retrying."); RefreshRates(); // Update data continue; // At the next iteration case 136:Alert("No prices. Waiting for a new tick.."); while(RefreshRates()==false) // To the new tick Sleep(1); // Cycle delay continue; // At the next iteration case 146:Alert("Trading subsystem is busy. Retrying "); Sleep(500); // Simple solution RefreshRates(); // Update data continue; // At the next iteration // Critical errors case 2 : Alert("Common error."); break; // Exit 'switch' case 5 : Alert("Old version of the client terminal."); break; // Exit 'switch' case 64: Alert("Account is blocked."); break; // Exit 'switch' case 133:Alert("Trading is prohibited"); break; // Exit 'switch' // default: Alert("Occurred error ",Error); break; //Other errors Exit 'switch' default: break; //Other errors Exit 'switch' } // End switch } // End if Ans==false } // End for } // End if } // Een TrailStop function
Can any one put these two indicators together into one EA. When both indicators show green=long, when both are red = short.
Files:
trendlord.ex4
4 kb
I've been trading it on the M30, H1, and H4 succefully -- manually. But if someone could put it on an EA that would be cool!
OldZ:
Hey there, did you try the EA with "Every Tick"?. I have had poor test-to-reality experiences when I back test using "Control Points".
Your advisor's back test is extreme bad and I want to known how you get such report.
If I use control point, my advisor also get good result:
商品 | EURUSD (Euro vs US Dollar) | ||||
时间周期 | 1 小时图 2010.07.08 07:00 - 2010.12.28 14:00 (2010.07.01 - 2011.01.01) | ||||
复盘模型 | 控制点(基于最近的小一级时段内的12个控制点的分形插值计算) | ||||
参数 | STDPeriod=50; SDLPeriod=100; Stoploss=80; ShockWave=12; ShockWaveTP=4; ShockWaveTP2=12; OneLots=5; MaxLots=10; | ||||
经测试过的柱数 | 3481 | 用于复盘的即时价数量 | 61394 | 复盘模型的质量 | n/a |
输入图表错误 | 1704 | ||||
起始资金 | 10000.00 | ||||
总净盈利 | 90934.00 | 总获利 | 424738.00 | 总亏损 | -333804.00 |
盈利比 | 1.27 | 预期盈利 | 531.78 | ||
绝对亏损 | 1679.50 | 最大亏损 | 47908.50 (45.85%) | 相对亏损 | 55.31% (12750.00) |
交易单总计 | 171 | 卖单 (获利百分比) | 87 (49.43%) | 买单 (获利百分比) | 84 (50.00%) |
盈利交易(占总百分比) | 85 (49.71%) | 亏损交易(占总百分比) | 86 (50.29%) | ||
最大: | 获利交易 | 18602.00 | 亏损交易 | -4060.00 | |
平均: | 获利交易 | 4996.92 | 亏损交易 | -3881.44 | |
最大: | 连续获利金额 | 8 (39202.50) | 连续亏损金额 | 6 (-23998.00) | |
最多: | 连续获利次数 | 39202.50 (8) | 连续亏损次数 | -23998.00 (6) | |
平均: | 连续获利 | 2 | 连续亏损 | 2 |
serpentsnoir:
Hey there, did you try the EA with "Every Tick"?. I have had poor test-to-reality experiences when I back test using "Control Points".
Hey there, did you try the EA with "Every Tick"?. I have had poor test-to-reality experiences when I back test using "Control Points".
I think it depends on your codes and your broker limitation instead of "Every Tick".

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register