Orders Execution
0
Views
0
Downloads
0
Favorites
Profitability Reports
AUD/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
0
Won Trades
0
Lost trades
0
Win Rate
0.0 %
Expected payoff
0.00
Gross Profit
0.00
Gross Loss
0.00
Total Net Profit
0.00
-100%
-50%
0%
50%
100%
GBP/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
0
Won Trades
0
Lost trades
0
Win Rate
0.0 %
Expected payoff
0.00
Gross Profit
0.00
Gross Loss
0.00
Total Net Profit
0.00
-100%
-50%
0%
50%
100%
Steping Stop & Reverse
// Steping Stop & Reverse.mq4
// Ñîâåòíèê
/*Ñîâåòíèê "Øàãàþùèé ñòîï ñ ðàçâîðîòîì"
ïðèìåð
Îòêðûâàåòñÿ ïîçèöèÿ â ëþáóþ ñòîðîíó (ïåðâàÿ), äàëåå ïîñëå ñðàáàòûâàíèÿ ëîñÿ èä¸ò ïåðåâîðîò.
(ïîçèöèÿ â ïðîòèâîïîëîæíóþ ñòîðîíó)
Ïîñëå îòêðûòèÿ ïîçèöèè ïðîôèò ñòàâèòñÿ íà 70ï. à ëîñü èä¸ò çà öåíîé â -10ï..
Ìåíÿåòñÿ (ïåðåñòàâëÿåòñÿ) ëîñü òàê æå êàæäûå 10 ï., à íå âñ¸ âðåìÿ.
StepStop áîëüøå èëè ðàâíî, ÷åì ìèíèìàëüíûé óðîâåíü ñòîïîâ ïëþñ ñïðåä.
Óðîâåíü ñòîïîâ ïîêàçûâàåòñÿ â æóðíàëå "Ýêñïåðòû" ïðè ñòàðòå ñîâåòíèêà.
*/
#property copyright "mandorr@gmail.com"
#include <stdlib.mqh>
extern int TakeProfit=70;
extern int StepStop=10;
extern double Lots=0.1;
extern bool MoneyManagement=false;
extern int MarginPercent=20;
int level_sell_stop;
int level_buy_stop;
void init()
{
int minstop=MarketInfo(Symbol(),MODE_STOPLEVEL);
Print("Óðîâåíü ñòîïîâ: "+minstop);
}
void start()
{
if (!IsTradeAllowed()) return;
level_buy_stop=0;
level_sell_stop=0;
StepingStop();
StepingPendings();
if (TotalBuy ()==0 && TotalBuyStop ()==0) SetBuyStop ();
if (TotalSell()==0 && TotalSellStop()==0) SetSellStop();
Comment("Level Buy Stop=",level_buy_stop*Point,"\n","Level Sell Stop=",level_sell_stop*Point);
}
void StepingStop()
{
if (StepStop<1) return;
int ask, bid, open, stop, x;
double loss;
for (int i=0; i<OrdersTotal(); i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()==OP_BUY)
{
bid=MathRound(Bid/Point);
open=MathRound(OrderOpenPrice()/Point);
stop=MathRound(OrderStopLoss()/Point);
x=(bid-open)/StepStop; x--; x*=StepStop;
level_sell_stop=open+x;
if (stop>=open+x) continue;
loss=(open+x)*Point;
OrderModify(OrderTicket(),OrderOpenPrice(),loss,OrderTakeProfit(),0,CLR_NONE);
}
if (OrderType()==OP_SELL)
{
ask=MathRound(Ask/Point);
open=MathRound(OrderOpenPrice()/Point);
stop=MathRound(OrderStopLoss()/Point);
x=(open-ask)/StepStop; x--; x*=StepStop;
level_buy_stop=open-x;
if (stop>0 && stop<=open-x) continue;
loss=(open-x)*Point;
OrderModify(OrderTicket(),OrderOpenPrice(),loss,OrderTakeProfit(),0,CLR_NONE);
}
}
}
void StepingPendings()
{
int ask, bid, open;
double price, loss, profit;
for (int i=0; i<OrdersTotal(); i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()==OP_BUYSTOP)
{
if (level_buy_stop==0) continue;
open=MathRound(OrderOpenPrice()/Point);
if (open<=level_buy_stop) continue;
price=level_buy_stop*Point;
loss=price-StepStop*Point;
profit=0; if (TakeProfit>0) profit=price+TakeProfit*Point;
OrderModify(OrderTicket(),price,loss,profit,0,CLR_NONE);
}
if (OrderType()==OP_SELLSTOP)
{
if (level_sell_stop==0) continue;
open=MathRound(OrderOpenPrice()/Point);
if (open>=level_sell_stop) continue;
price=level_sell_stop*Point;
loss=price+StepStop*Point;
profit=0; if (TakeProfit>0) profit=price-TakeProfit*Point;
OrderModify(OrderTicket(),price,loss,profit,0,CLR_NONE);
}
}
}
void SetBuyStop()
{
double lots=LotsCounting();
double price=Bid+StepStop*Point;
double loss=price-StepStop*Point;
double profit=0; if (TakeProfit>0) profit=price+TakeProfit*Point;
int ticket=OrderSend(Symbol(),OP_BUYSTOP,lots,price,0,loss,profit,"",0,0,CLR_NONE);
if (ticket<1) Print("Set a pending order failed with error #",GetLastError()," ",ErrorDescription(GetLastError()));
}
void SetSellStop()
{
double lots=LotsCounting();
double price=Ask-StepStop*Point;
double loss=price+StepStop*Point;
double profit=0; if (TakeProfit>0) profit=price-TakeProfit*Point;
int ticket=OrderSend(Symbol(),OP_SELLSTOP,lots,price,0,loss,profit,"",0,0,CLR_NONE);
if (ticket<1) Print("Set a pending order failed with error #",GetLastError()," ",ErrorDescription(GetLastError()));
}
int TotalBuy()
{
int count=0;
for (int i=0; i<OrdersTotal(); i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()==OP_BUY) count++;
}
return (count);
}
int TotalBuyStop()
{
int count=0;
for (int i=0; i<OrdersTotal(); i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()==OP_BUYSTOP) count++;
}
return (count);
}
int TotalSell()
{
int count=0;
for (int i=0; i<OrdersTotal(); i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()==OP_SELL) count++;
}
return (count);
}
int TotalSellStop()
{
int count=0;
for (int i=0; i<OrdersTotal(); i++)
{
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()==OP_SELLSTOP) count++;
}
return (count);
}
double LotsCounting()
{
double lots=Lots;
if (MoneyManagement)
{
double lotsize=MarketInfo(Symbol(),MODE_LOTSIZE);
double freemargin=AccountFreeMargin();
lots=0; if (lotsize>0) lots=NormalizeDouble((MarginPercent*freemargin/lotsize),1);
}
if (lots>10) lots=NormalizeDouble(lots,0);
if (lots<0.1) lots=0.1;
return (lots);
}
// End
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---