|
@@ -101,6 +101,11 @@ input bool enableTimeSession = false;
|
|
|
input string start_time_session = "01:00"; // Start Session
|
|
input string start_time_session = "01:00"; // Start Session
|
|
|
input string end_time_session = "23:59"; // End Session
|
|
input string end_time_session = "23:59"; // End Session
|
|
|
|
|
|
|
|
|
|
+input string string_0_2 = "<><><><><><> Trailing Setting<><><><><><>"; //__
|
|
|
|
|
+input bool indivial_trailing = false; // Indiviual Trailing
|
|
|
|
|
+input double ts_sl = 15; // Trailing Start in Pips
|
|
|
|
|
+input double ts = 5; // Trailing Stop in Pips
|
|
|
|
|
+
|
|
|
input string news = "<><><><><><> News Settings <><><><><><>"; // News
|
|
input string news = "<><><><><><> News Settings <><><><><><>"; // News
|
|
|
input NewsCloseOrder newsClose = CloseAllRunningOrder; // On News Action on Running Orders
|
|
input NewsCloseOrder newsClose = CloseAllRunningOrder; // On News Action on Running Orders
|
|
|
input bool High_Impact_News = true; //High Impact News
|
|
input bool High_Impact_News = true; //High Impact News
|
|
@@ -234,7 +239,7 @@ void OnDeinit(const int reason)
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
|
void OnTick()
|
|
void OnTick()
|
|
|
{
|
|
{
|
|
|
- static int status=-1,preStatus=-1;
|
|
|
|
|
|
|
+ static int status=-1,preStatus=-1;
|
|
|
if(!MQLInfoInteger(MQL_TESTER))
|
|
if(!MQLInfoInteger(MQL_TESTER))
|
|
|
{
|
|
{
|
|
|
status=returnNewsStatus(High_Impact_News
|
|
status=returnNewsStatus(High_Impact_News
|
|
@@ -349,6 +354,10 @@ void OnTick()
|
|
|
void mainActivity()
|
|
void mainActivity()
|
|
|
{
|
|
{
|
|
|
//---
|
|
//---
|
|
|
|
|
+ if(indivial_trailing)
|
|
|
|
|
+ {
|
|
|
|
|
+ Individual_Trailing();
|
|
|
|
|
+ }
|
|
|
double Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID);
|
|
double Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID);
|
|
|
double Ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
|
|
double Ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
|
|
|
|
|
|
|
@@ -866,5 +875,64 @@ bool spreadFilter()
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
|
//| |
|
|
//| |
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
+void Individual_Trailing()
|
|
|
|
|
+ {
|
|
|
|
|
+ int openedpositions;
|
|
|
|
|
+ double mySL,myResult;
|
|
|
|
|
+
|
|
|
|
|
+ openedpositions=PositionsTotal();
|
|
|
|
|
+ if((openedpositions>0))
|
|
|
|
|
+ {
|
|
|
|
|
+ int totalorders=PositionsTotal();
|
|
|
|
|
+ for(int i=0; i<totalorders; i++) // scan all orders and positions. ..
|
|
|
|
|
+ {
|
|
|
|
|
+ ulong ticket = PositionGetTicket(i);
|
|
|
|
|
+ if(PositionSelectByTicket(ticket))
|
|
|
|
|
+ {
|
|
|
|
|
+ if(PositionGetString(POSITION_SYMBOL)==Symbol() && PositionGetInteger(POSITION_MAGIC) ==magic_no) // only look if mygrid and symbol. ..
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ double SymbolAsk = SymbolInfoDouble(PositionGetString(POSITION_SYMBOL), SYMBOL_ASK);
|
|
|
|
|
+ double SymbolBid = SymbolInfoDouble(PositionGetString(POSITION_SYMBOL), SYMBOL_BID);
|
|
|
|
|
+ int SymbolDigits = (int)SymbolInfoInteger(PositionGetString(POSITION_SYMBOL), SYMBOL_DIGITS);
|
|
|
|
|
+ double SymbolTickSize = SymbolInfoDouble(PositionGetString(POSITION_SYMBOL), SYMBOL_TRADE_TICK_SIZE);
|
|
|
|
|
+ int type= (int)PositionGetInteger(POSITION_TYPE);
|
|
|
|
|
+
|
|
|
|
|
+ if(type==POSITION_TYPE_BUY) // its a long position
|
|
|
|
|
+ {
|
|
|
|
|
+ mySL=NormalizeDouble(SymbolAsk-(ts*SymbolTickSize*10),Digits()); // new SL
|
|
|
|
|
+ double startSl=PositionGetDouble(POSITION_PRICE_OPEN)+(ts_sl*SymbolTickSize*10);
|
|
|
|
|
+ if(PositionGetDouble(POSITION_SL) != mySL)
|
|
|
|
|
+ if(mySL>PositionGetDouble(POSITION_SL) && SymbolAsk>=startSl)
|
|
|
|
|
+ {
|
|
|
|
|
+ myResult=trade.PositionModify(ticket,mySL,PositionGetDouble(POSITION_TP)); //OrderModify(OrderTicket(),OrderOpenPrice(),mySL,OrderTakeProfit(),0,clrGreen);
|
|
|
|
|
+ if(!myResult)
|
|
|
|
|
+ {
|
|
|
|
|
+ Print(" Buy Trade Trailing Error: ",GetLastError());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(type==POSITION_TYPE_SELL)
|
|
|
|
|
+ {
|
|
|
|
|
+ mySL=NormalizeDouble(SymbolBid+(ts*SymbolTickSize*10),Digits()); // new SL
|
|
|
|
|
+ double startSlSell=PositionGetDouble(POSITION_PRICE_OPEN)-(ts_sl*SymbolTickSize*10);
|
|
|
|
|
+ if(PositionGetDouble(POSITION_SL) != mySL)
|
|
|
|
|
+ if(((mySL<PositionGetDouble(POSITION_SL)) || (PositionGetDouble(POSITION_SL)<SymbolTickSize)) && SymbolBid<=startSlSell)
|
|
|
|
|
+ {
|
|
|
|
|
+ myResult=trade.PositionModify(ticket,mySL,PositionGetDouble(POSITION_TP)); //OrderModify(OrderTicket(),OrderOpenPrice(),mySL,OrderTakeProfit(),0,clrRed);
|
|
|
|
|
+ if(!myResult)
|
|
|
|
|
+ {
|
|
|
|
|
+ Print(" Sell Trade Trailing Error: ",GetLastError());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//+------------------------------------------------------------------+
|