Hello, how do I write a robot (which topics in the tutorial should I use so I don't have to read everything) that opens a buy order with a trailing stop, and if the trailing stop triggers, it also opens a new one (i.e. it gets double lot in trailing stop), but when the stop triggers, a new trailing stop is placed.
Question how to calculate a series of losing orders ????
I want to know how many orders in a row closed at a stop to check tactics... and especially the last
Guys, I really need it .....
This is how I calculate it for me:
Iteration = how many times an order in a row has closed at a stop if a stop in your sense is a loss-making close.
//---------------------расчет по истории ордеров номера очередной итерации-----------------------------------------------
Iteration = 0; // зануляем инерации перед их учетом в цикле по истории
Sum_Loss = 0; // суммарный убыток по этим итерациямdatetime
Time_at_History_Current = 0,
Time_at_History_Previos = 0;
if(OrdersHistoryTotal() != 0)
{
for(int counter = OrdersHistoryTotal()-1; counter >= 0; counter--)
{
OrderSelect(counter, SELECT_BY_POS, MODE_HISTORY);
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if(OrderType() == OP_BUY || OrderType() == OP_SELL)
{
if(OrderProfit() < 0) // если убыток по выбранному ордеру, то считаем суммарный и записываем время закрытия ордера// для последующего его анализа при подсчете количества итераций
{
double lastLoss = OrderProfit();
Sum_Loss=Sum_Loss+lastLoss; // считаем общий убыток по закрытым подряд убыточным ордерам
Time_at_History_Current = OrderCloseTime();
}
//Print(" Time_at_History_Current_в цикле = ", TimeToStr(Time_at_History_Current, TIME_DATE|TIME_SECONDS));//Print(" Time_at_History_Previos_в цикле = ", TimeToStr(Time_at_History_Previos, TIME_DATE|TIME_SECONDS));if(Time_at_History_Current != Time_at_History_Previos) // если они не равны, то считаем итерации и делаем их равными
{
Time_at_History_Previos = Time_at_History_Current ;
Iteration++;
//Print("Iteration at History в условии сравнения = ", Iteration);
}
else// они равны, то проверяем, дополнительно, наличие профита по выбранному следующему ордеру и выходим из цикла
{
if(OrderProfit() >= 0)
break;
}
}
}
}
}
VOLDEMAR: Thanks ! But as I understand it, this code finds the whole series in the history regardless of whether it was 100 trades ago or 5 .....
No. The selection from the closest closed one goes deep into the history, and when a closed one turns into a profit, the series is interrupted with the output of the number of consecutive losing trades = Iteration.
Question: can OrderSend() return a value of "0", or less than "-1" after execution? Has anyone encountered anything like this? Or is the information given in the "documentation" correct:
int OrderSend(
string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)
Basic function used to open a position or set a pending order. Returns the ticket number that is assigned to the order by the trade server, or -1 in case of failure.
P.S.: working as a Telepath, looking for an error in someone else's code...
I made a virtual trawl with horizontal lines, in the tester it works fine, but during optimisation the tester apparently does not work with these lines, why?
Question how to calculate a series of losing orders ????
I want to know how many orders in a row closed at a stop to test the tactic... and especially the last
Guys, I really need it .....
Question how to calculate a series of losing orders ????
I want to know how many orders in a row closed at a stop to check tactics... and especially the last
Guys, I really need it .....
This is how I calculate it for me:
Iteration = how many times an order in a row has closed at a stop if a stop in your sense is a loss-making close.
Thanks ! But as I understand it, this code finds the whole series in the history regardless of whether it was 100 trades ago or 5 .....
No. The selection from the closest closed one goes deep into the history, and when a closed one turns into a profit, the series is interrupted with the output of the number of consecutive losing trades = Iteration.
Good afternoon.
Would this be the right combination?
I liked this one:)
I like this one:)
is there an error here ?
I need to return the value of the bar where Spread==0,
If no such value is found, return -1.
Hello.
Question: can OrderSend() return a value of "0", or less than "-1" after execution? Has anyone encountered anything like this? Or is the information given in the "documentation" correct:
Returns the ticket number that is assigned to the order by the trade server, or -1 in case of failure.