JK_sinkhro
Download scriptThis automated trading script is designed to manage and execute trades on the financial markets by analyzing historical price trends, managing active positions in real-time, and enforcing strict risk parameters.
Below is a breakdown of how the logic functions:
Market Analysis & Entry Logic
The system determines whether to enter a trade based on the momentum of recent price action. It scans a specific number of previous candles (defined by the user) to count how many closed "up" (bullish) versus "down" (bearish).
- Trend Detection: If the number of bullish candles outweighs the bearish ones, the system identifies an upward trend. Conversely, if bearish candles are more frequent, it identifies a downward trend.
- Time-Specific Execution: To ensure trades occur during optimal market conditions, the script incorporates a time filter. It is programmed to look for entries only during specific hours of the day (customizable by the user), specifically targeting moments within a 5-minute window at those times.
- Order Limits: The system keeps track of the total number of open positions to ensure it does not exceed a predefined maximum limit, protecting the account from over-exposure.
Trade Management & Protection
Once a trade is active, the script continuously monitors it to protect profits and minimize losses:
- Dynamic Position Sizing: The script can automatically calculate the trade volume (lot size) based on your current available account balance and a specific risk percentage. This ensures that every trade remains proportional to your account size.
- Profit Taking: It utilizes two levels of profit targets. While there is a primary goal, it also monitors a secondary target to manage exits efficiently as the market moves in your favor.
- Trailing Stop Mechanism: One of the core features is the "Trailing Stop." As a trade becomes profitable, the script automatically moves the stop-loss order forward. This allows the trade to "breathe" while ensuring that if the price suddenly reverses, you lock in a significant portion of your gains rather than letting the profit evaporate.
Summary of Automation
By combining trend analysis, precise time filters, and automated trade management (like trailing stops and dynamic lot sizing), this script is designed to remove emotional decision-making from trading. It systematically identifies opportunities based on historical momentum and automatically manages those positions to safeguard your capital.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| JK_sinkhro.mq4 |
//| JK. |
//| |
//+------------------------------------------------------------------+
extern double TakeProfit = 100; // ÍÅ ÈÑÏÎËÜÇÓÅÒÑß
extern double TakeProfit2 = 36; // ÏÐÈ ÄÎÑÒÈÆÅÍÈß ÝÒÎÃÎ ÏÐÎÔÈÒÀ ÇÀÊÐÛÂÀÅÒ ÏÎÇÓ
extern double Stoploss = 82; //ÁÅÇ ÊÎÌÅÍÒÀÐÈÅÂ
extern double Lots = 0.1; //ÒÓÒ ÒÎÆÅ ÂÑÅ ÄÎËÆÍÎ ÁÛÒÜ ÏÎÍßÒÍÎ
extern double TrailingStop = 30; //ÎÏÒÈÌÀËÜÍÎE ÇÍÀ×ÅÍÈÅ ÌÎÆÅÒÅ ÏÎÄÁÈÐÀÒÜ, ÍÎ ÌÍÅ ÁÎËÜØÅ ÏÎÍÐÀÂÈËÎÑÜ ÁÅÇ ÒÐÀËÀ
extern double per=18; //ÊÎËËÈ×ÅÑÒÂÎ ÀÍÀËÈÇÈÐÓÅÌÛÕ ÑÂÅ×ÅÊ
extern double per2=8; //ÍÅ ÈÑÏÎËÜÇÓÅÒÑß
extern double chas=2; //Ñìåùåíèå âðåìåíè
extern double totalt=1000; //ÎÄÍÎÂÐÅÌÅÍÍÎ ÎÒÊÐÛÒÛÕ ÏÎÇ ÌÎÆÅÒ ÁÛÒÜ ÍÅ ÁÎËÅÅ ×ÅÌ
extern double mm=0; // ìì
extern double risk=10; //ðÈÑÊ Î ÌÌ
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int cnt, ticket, total;
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(TakeProfit<0)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}
double Lotsi;
if (mm!=0)
{
Lotsi=NormalizeDouble(AccountFreeMargin()*risk/100001,1);
if (Lotsi<0.1) Lotsi=0.1;
}
else Lotsi=Lots;
//if ((CurTime()-OrderOpenTime())<61) return(0);
int up, down; up=0; down=0;
for(cnt=1;cnt<per;cnt++)
if (Open[cnt]>Close[cnt]) up=up+1;
for(cnt=1;cnt<per;cnt++)
if (Open[cnt]<Close[cnt]) down=down+1;
int j;
j=0;
total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) // check for symbol
{j=1;
if(OrderType()==OP_BUY)
{
if(Bid-OrderOpenPrice()>=TakeProfit2*Point)
{
OrderClose(OrderTicket(),OrderLots(),Bid,0,Violet); return(0);
}
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); return(0);
}
}
}
}
else
{
if(OrderOpenPrice()-Ask>=TakeProfit2*Point)
{
OrderClose(OrderTicket(),OrderLots(),Ask,0,Violet); return(0);
}
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); return(0);
}
}
}
}
}
}
if (total<totalt)
{ if(up>down && (22+(chas)==Hour()|| 19+(chas)==Hour()) &&Minute()<5)// && j==1)
{
OrderSend(Symbol(),OP_BUY,Lotsi,Ask,0,Bid-Stoploss*Point,Ask+TakeProfit*Point,"jk_prof",16384,0,Green); return(0);
}
if(up<down && (22+(chas)==Hour()|| 19+(chas)==Hour()) && Minute()<5)// && j==1)
{
OrderSend(Symbol(),OP_SELL,Lotsi,Bid,3,Ask+Stoploss*Point,Bid-TakeProfit*Point,"macd sample",16384,0,Red); return(0);
}
}
return(0);
}
// the end.
Profitability Reports
Expected payoff
Average expected payoff across the available backtests for each symbol.
Comments