I suggest to discuss the following topic: how relevant is trading on multiple Symbols and/or Timeframes within one Expert Advisor?
I am currently sitting and thinking - should I post symbol_lib and Expert Advisor template, designed for this very purpose =) and I think there is no such need... If I trade on different accounts - I will still have to run several terminals, and if I trade on one - I will just open several windows. And there would be less confusion, it seems...
It will be interesting to hear opinions and arguments to them ;)
int CurPrice_p=Bid/Point; //текущая цена в пунктах
int CurSLoss=OrderStopLoss( )/Point; //текущий стоплосс в пунктах
int TS=40; //значение трейлингстопа в пунктах
if(TS>=5)
{
int TStep=2; //минимальный шаг трейлинг стопа
if(TStep<1) TStep=1; //проверка шага трейлинга
{
if(MathAbs(CurPrice_p-CurSLOss)>=TS+TStep)
{
if(CurPrice_p>CurSLOss)
{
double NewSLoss=(CurPrice_p-TS)*Point;
изменить уровень стоплосс ордера на новый
}
if(CurPrice_p>CurSLOss)
{
NewSLoss=(CurPrice_p+TS)*Point;
изменить уровень стоплосс ордера на новый
}
}
}
}
Regarding trailing stop, maybe we should do the following
this is an idea ... it is more than a thought - it is an idea )) The next day I will go over the errors that have been collected by the Expert Advisor and think about implementing trading functions. I will share with you next week ;)
I propose to discuss the following topic: How relevant is it to trade on multiple Seals and/or Timeframes within the same Expert Advisor?
As a result of voting ( 1 against (komposter), 0 in favor, the rest abstained ) I have decided not to post multisymbol trading trash in this thread =) If anybody is still interested, write and share the library ;-|
Here is a small, and in my opinion useful, utility for visual analysis of positions after a backtest run. Maybe this idea will be further developed for on-line analysis of trading history and parsing of other people's statements. To use: 1. Write this file with the extension mqh, Tracert.mqh in the folder experts\include\ 2. Add the line #include <Tracert.mqh>
#property copyright "Rosh, conversed only" #property link
3. Insert SetTrace() at the very beginning in the start() block ;
int start() { int ticket, total,totalExpert; //------------------------------------------------------ //to simplify and accelerate the code, let's save the necessary // indicator data in temporary variables SetTrace();
4. After the EA run, open the file and get something like this:
The utility code itself:
//+------------------------------------------------------------------+
//| Tracert.mq4 |
//| Rosh |
//| http://forexsystems.ru/phpBB/index.php |
//+------------------------------------------------------------------+
#property copyright "Rosh"
#property link "http://forexsystems.ru/phpBB/index.php"
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
double tr_AOPLong,tr_AOPShort;
double tr_LongLots,tr_ShortLots;
int tr_CurrLongOrders,tr_CurrShortOrders;
int tr_Total,tr_Counter;
int tr_PrevLongOrders,tr_PrevShortOrders;
int tr_CurrTotalOpenedOrders,tr_PrevTotalOpenedOrders;
double tr_CurrBalance,tr_PrevCurrBalance;
color tr_ProfitColor=Lime, tr_LossColor=DeepPink,tr_LongAOPColor=Blue,tr_ShortAOPColor=Red, tr_CurrCloseColor;
int tr_CloseLabelArrow=108, tr_AOPLabelArrow=159;
bool tr_CloseLong,tr_CloseShort;
double tr_CloseLabelPrice;
int tr_CloseLabelShift=20;
int tr_CounterCloseLabel=0,tr_CounterAOPLabel=0;
int tr_Bars;
void SetTrace()
{
//----
if (IsTesting()&&(tr_Bars!=Bars))
{
tr_CloseLong=false;
tr_CloseShort=false;
tr_AOPLong=0.0;
tr_AOPShort=0.0;
tr_LongLots=0.0;
tr_ShortLots=0.0;
tr_CloseLabelShift=iATR(NULL,0,50,1)*3.0/10.0/Point;
if (tr_CurrBalance==0.0)
{
tr_CurrBalance=AccountBalance();
tr_PrevCurrBalance=AccountBalance();
}
//----------------Проверка открытых позиций ---------------------------
tr_CurrLongOrders=0;
tr_CurrShortOrders=0;
tr_CurrTotalOpenedOrders=0;
tr_Total=OrdersTotal();
if (tr_Total>0)// есть открытые позиции
{
for (tr_Counter=0;tr_Counter<tr_Total;tr_Counter++)// подсчет открытых позиций
{
OrderSelect(tr_Counter, SELECT_BY_POS, MODE_TRADES);
if (OrderType()==OP_BUY)
{
tr_CurrLongOrders++;
tr_AOPLong=tr_AOPLong+OrderLots()*OrderOpenPrice();
tr_LongLots=tr_LongLots+OrderLots();
}
if (OrderType()==OP_SELL)
{
tr_CurrShortOrders++;
tr_AOPShort=tr_AOPShort+OrderLots()*OrderOpenPrice();
tr_ShortLots=tr_ShortLots+OrderLots();
}
}// подсчет открытых позиций
//--------------- усреднение ---------------------
if (tr_CurrLongOrders>0) tr_AOPLong=tr_AOPLong/tr_LongLots;
if (tr_CurrShortOrders>0)tr_AOPShort=tr_AOPShort/tr_ShortLots;
//--------------- усреднение ---------------------
if (tr_AOPLong>0.0)
{
ObjectCreate("AOP"+tr_CounterAOPLabel,OBJ_ARROW,0,Time[1],tr_AOPLong);// не совсем корректно, но пока пойдет
ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_ARROWCODE,tr_AOPLabelArrow);
ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_COLOR,tr_LongAOPColor);
tr_CounterAOPLabel++;
}
if (tr_AOPShort>0.0)
{
ObjectCreate("AOP"+tr_CounterAOPLabel,OBJ_ARROW,0,Time[1],tr_AOPShort);// не совсем корректно, но пока пойдет
ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_ARROWCODE,tr_AOPLabelArrow);
ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_COLOR,tr_ShortAOPColor);
tr_CounterAOPLabel++;
}
// Print("Long=",tr_CurrLongOrders," tr_AOPLong=",tr_AOPLong," *** Short=",tr_CurrShortOrders," tr_AOPShort=",tr_AOPShort);
tr_CurrTotalOpenedOrders=tr_CurrLongOrders+tr_CurrShortOrders;
if ((tr_CurrTotalOpenedOrders!=tr_PrevTotalOpenedOrders)||(tr_PrevLongOrders!=tr_CurrLongOrders)||(tr_PrevShortOrders!=tr_CurrShortOrders)) // изменилось колчиство ордеров в рынке
{
if (tr_PrevLongOrders>tr_CurrLongOrders) // изменилось число ордеров в Long
{
tr_CloseLong=true;
tr_CloseLabelPrice=High[1]+tr_CloseLabelShift*Point;
}
if (tr_PrevShortOrders>tr_CurrShortOrders) // изменилось число ордеров в Short
{
tr_CloseShort=true;
tr_CloseLabelPrice=Low[1]-tr_CloseLabelShift*Point;
}
tr_PrevLongOrders=tr_CurrLongOrders;
tr_PrevShortOrders=tr_CurrShortOrders;
tr_PrevTotalOpenedOrders=tr_CurrTotalOpenedOrders;
}
}// есть открытые позиции
//---------------- Проверка изменения Баланса
tr_CurrBalance=AccountBalance();
if (tr_CurrBalance!=tr_PrevCurrBalance)// проверка изменения Balance
{
if (tr_CurrBalance-tr_PrevCurrBalance>0.0) tr_CurrCloseColor=tr_ProfitColor; else tr_CurrCloseColor=tr_LossColor;
tr_PrevCurrBalance=tr_CurrBalance;
//------------------ установка Метки закрытия --------------------
ObjectCreate("Close"+tr_CounterCloseLabel,OBJ_ARROW,0,Time[1],tr_CloseLabelPrice);
ObjectSet("Close"+tr_CounterCloseLabel,OBJPROP_ARROWCODE,tr_CloseLabelArrow);
ObjectSet("Close"+tr_CounterCloseLabel,OBJPROP_COLOR,tr_CurrCloseColor);
tr_CounterCloseLabel++;
//------------------ установка Метки закрытия --------------------
}// проверка изменения Balance
}//(IsTesting())
//----
tr_Bars=Bars;
return(0);
}
//+------------------------------------------------------------------+
Due to the release of the tester (a little late though), I'm posting trade_lib_tester and info_lib_tester. Because their usual versions don't want to be tested =))) Use the same. Just change the old names in the lines of inludes to the new ones.
Could you post all these files, both latest and earlier, somewhere on viac or alpari or forexitems or finlists - in general, where you can attach files. It would also be easier to find. Thanks in advance.
Dear komposter! <br / translate="no">. Could you please put all these files and recent and earlier ones somewhere on viac or alpari or forexitems or finlist - in general, where you can attach files. It would also be easier to find. Thanks in advance.
There are a lot of changes. And a huge one at that. Error tolerance is at a whole new level, information is more complete, interface is more friendly ;) ...
In general, we can say, that it is absolutely new library =) Feel free to use it ;)
how relevant is trading on multiple Symbols and/or Timeframes within one Expert Advisor?
I am currently sitting and thinking - should I post symbol_lib and Expert Advisor template, designed for this very purpose =)
and I think there is no such need... If I trade on different accounts - I will still have to run several terminals, and if I trade on one - I will just open several windows. And there would be less confusion, it seems...
It will be interesting to hear opinions and arguments to them ;)
int CurPrice_p=Bid/Point; //текущая цена в пунктах int CurSLoss=OrderStopLoss( )/Point; //текущий стоплосс в пунктах int TS=40; //значение трейлингстопа в пунктах if(TS>=5) { int TStep=2; //минимальный шаг трейлинг стопа if(TStep<1) TStep=1; //проверка шага трейлинга { if(MathAbs(CurPrice_p-CurSLOss)>=TS+TStep) { if(CurPrice_p>CurSLOss) { double NewSLoss=(CurPrice_p-TS)*Point; изменить уровень стоплосс ордера на новый } if(CurPrice_p>CurSLOss) { NewSLoss=(CurPrice_p+TS)*Point; изменить уровень стоплосс ордера на новый } } } }this is an idea ... it is more than a thought - it is an idea ))
The next day I will go over the errors that have been collected by the Expert Advisor and think about implementing trading functions. I will share with you next week ;)
How relevant is it to trade on multiple Seals and/or Timeframes within the same Expert Advisor?
As a result of voting ( 1 against (komposter), 0 in favor, the rest abstained ) I have decided not to post multisymbol trading trash in this thread =)
If anybody is still interested, write and share the library ;-|
To use:
1. Write this file with the extension mqh, Tracert.mqh in the folder experts\include\
2. Add the line #include <Tracert.mqh>
"http://*****************"
3. Insert SetTrace() at the very beginning in the start() block ;
int start() { int ticket, total,totalExpert; //------------------------------------------------------ //to simplify and accelerate the code, let's save the necessary // indicator data in temporary variables SetTrace();4. After the EA run, open the file and get something like this:
The utility code itself:
//+------------------------------------------------------------------+ //| Tracert.mq4 | //| Rosh | //| http://forexsystems.ru/phpBB/index.php | //+------------------------------------------------------------------+ #property copyright "Rosh" #property link "http://forexsystems.ru/phpBB/index.php" //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ double tr_AOPLong,tr_AOPShort; double tr_LongLots,tr_ShortLots; int tr_CurrLongOrders,tr_CurrShortOrders; int tr_Total,tr_Counter; int tr_PrevLongOrders,tr_PrevShortOrders; int tr_CurrTotalOpenedOrders,tr_PrevTotalOpenedOrders; double tr_CurrBalance,tr_PrevCurrBalance; color tr_ProfitColor=Lime, tr_LossColor=DeepPink,tr_LongAOPColor=Blue,tr_ShortAOPColor=Red, tr_CurrCloseColor; int tr_CloseLabelArrow=108, tr_AOPLabelArrow=159; bool tr_CloseLong,tr_CloseShort; double tr_CloseLabelPrice; int tr_CloseLabelShift=20; int tr_CounterCloseLabel=0,tr_CounterAOPLabel=0; int tr_Bars; void SetTrace() { //---- if (IsTesting()&&(tr_Bars!=Bars)) { tr_CloseLong=false; tr_CloseShort=false; tr_AOPLong=0.0; tr_AOPShort=0.0; tr_LongLots=0.0; tr_ShortLots=0.0; tr_CloseLabelShift=iATR(NULL,0,50,1)*3.0/10.0/Point; if (tr_CurrBalance==0.0) { tr_CurrBalance=AccountBalance(); tr_PrevCurrBalance=AccountBalance(); } //----------------Проверка открытых позиций --------------------------- tr_CurrLongOrders=0; tr_CurrShortOrders=0; tr_CurrTotalOpenedOrders=0; tr_Total=OrdersTotal(); if (tr_Total>0)// есть открытые позиции { for (tr_Counter=0;tr_Counter<tr_Total;tr_Counter++)// подсчет открытых позиций { OrderSelect(tr_Counter, SELECT_BY_POS, MODE_TRADES); if (OrderType()==OP_BUY) { tr_CurrLongOrders++; tr_AOPLong=tr_AOPLong+OrderLots()*OrderOpenPrice(); tr_LongLots=tr_LongLots+OrderLots(); } if (OrderType()==OP_SELL) { tr_CurrShortOrders++; tr_AOPShort=tr_AOPShort+OrderLots()*OrderOpenPrice(); tr_ShortLots=tr_ShortLots+OrderLots(); } }// подсчет открытых позиций //--------------- усреднение --------------------- if (tr_CurrLongOrders>0) tr_AOPLong=tr_AOPLong/tr_LongLots; if (tr_CurrShortOrders>0)tr_AOPShort=tr_AOPShort/tr_ShortLots; //--------------- усреднение --------------------- if (tr_AOPLong>0.0) { ObjectCreate("AOP"+tr_CounterAOPLabel,OBJ_ARROW,0,Time[1],tr_AOPLong);// не совсем корректно, но пока пойдет ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_ARROWCODE,tr_AOPLabelArrow); ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_COLOR,tr_LongAOPColor); tr_CounterAOPLabel++; } if (tr_AOPShort>0.0) { ObjectCreate("AOP"+tr_CounterAOPLabel,OBJ_ARROW,0,Time[1],tr_AOPShort);// не совсем корректно, но пока пойдет ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_ARROWCODE,tr_AOPLabelArrow); ObjectSet("AOP"+tr_CounterAOPLabel,OBJPROP_COLOR,tr_ShortAOPColor); tr_CounterAOPLabel++; } // Print("Long=",tr_CurrLongOrders," tr_AOPLong=",tr_AOPLong," *** Short=",tr_CurrShortOrders," tr_AOPShort=",tr_AOPShort); tr_CurrTotalOpenedOrders=tr_CurrLongOrders+tr_CurrShortOrders; if ((tr_CurrTotalOpenedOrders!=tr_PrevTotalOpenedOrders)||(tr_PrevLongOrders!=tr_CurrLongOrders)||(tr_PrevShortOrders!=tr_CurrShortOrders)) // изменилось колчиство ордеров в рынке { if (tr_PrevLongOrders>tr_CurrLongOrders) // изменилось число ордеров в Long { tr_CloseLong=true; tr_CloseLabelPrice=High[1]+tr_CloseLabelShift*Point; } if (tr_PrevShortOrders>tr_CurrShortOrders) // изменилось число ордеров в Short { tr_CloseShort=true; tr_CloseLabelPrice=Low[1]-tr_CloseLabelShift*Point; } tr_PrevLongOrders=tr_CurrLongOrders; tr_PrevShortOrders=tr_CurrShortOrders; tr_PrevTotalOpenedOrders=tr_CurrTotalOpenedOrders; } }// есть открытые позиции //---------------- Проверка изменения Баланса tr_CurrBalance=AccountBalance(); if (tr_CurrBalance!=tr_PrevCurrBalance)// проверка изменения Balance { if (tr_CurrBalance-tr_PrevCurrBalance>0.0) tr_CurrCloseColor=tr_ProfitColor; else tr_CurrCloseColor=tr_LossColor; tr_PrevCurrBalance=tr_CurrBalance; //------------------ установка Метки закрытия -------------------- ObjectCreate("Close"+tr_CounterCloseLabel,OBJ_ARROW,0,Time[1],tr_CloseLabelPrice); ObjectSet("Close"+tr_CounterCloseLabel,OBJPROP_ARROWCODE,tr_CloseLabelArrow); ObjectSet("Close"+tr_CounterCloseLabel,OBJPROP_COLOR,tr_CurrCloseColor); tr_CounterCloseLabel++; //------------------ установка Метки закрытия -------------------- }// проверка изменения Balance }//(IsTesting()) //---- tr_Bars=Bars; return(0); } //+------------------------------------------------------------------+Use the same. Just change the old names in the lines of inludes to the new ones.
files are located at http://forum.viac.ru/viewtopic.php?t=2973
Could you post all these files, both latest and earlier, somewhere on viac or alpari or forexitems or finlists - in general, where you can attach files. It would also be easier to find. Thanks in advance.
Could you please put all these files and recent and earlier ones somewhere on viac or alpari or forexitems or finlist - in general, where you can attach files. It would also be easier to find. Thanks in advance.
http://forum.viac.ru/viewtopic.php?t=2973
I will move the descriptions with instructions later...
testing speed increased more than 10 times
There are a lot of changes. And a huge one at that.
Error tolerance is at a whole new level, information is more complete, interface is more friendly ;) ...
In general, we can say, that it is absolutely new library =)
Feel free to use it ;)