JS_SISTEM_2

Profit factor:
0.68
This script is designed to automatically trade on the Forex market using the MetaTrader platform.  It's like having a robot that watches the market and makes decisions for you based on a set of pre-defined rules.

Here's a breakdown of what it does:

**1. Initial Setup and Money Management:**

*   It first checks if you have enough money in your account to trade. If your account balance falls below a specified minimum, the robot stops trading to prevent further losses.
*   It then calculates the size of the trade (the "lot size") it should make based on how much money you have and how much risk you're willing to take.  You can set a risk percentage, and the robot will adjust the trade size to potentially gain that percentage of your available funds while trying to limit potential losses if the trade goes wrong.  You can also choose to disable this automatic money management and set a fixed lot size.
*   It sets up basic trading parameters like slippage (the acceptable difference between the requested price and the actual price when the order is executed) and a "magic number" to identify its own trades.

**2. Market Analysis:**

*   The script uses several technical indicators, which are like pre-built analysis tools, to analyze the currency pair's price movements.
    *   **Moving Averages (MA):** These smooth out the price data to show the general trend. The script uses three moving averages with different time periods.
    *   **OsMA (Oscillator of a Moving Average):** This indicator measures the difference between two moving averages of an oscillator. It helps to identify when the market is overbought or oversold.
    *   **RVI (Relative Vigor Index):** This indicator measures the strength of a trend by comparing the closing price to the opening price over a certain period.

**3. Trading Logic:**

*   The script's core function is to determine when to buy or sell a currency pair. It does this by comparing the values of the technical indicators against pre-set rules.
    *   **Buy Signal:** If the OsMA is positive, the RVI indicates an upward trend, the moving averages are in a specific order, and a calculated value is below a threshold, the script considers it a buy signal.
    *   **Sell Signal:** If the OsMA is negative, the RVI indicates a downward trend, the moving averages are in a specific order, and a calculated value is below a threshold, the script considers it a sell signal.

**4. Order Execution:**

*   If the script detects a buy or sell signal, it checks if there are already open orders of the same type. If there are, it doesn't open a new one. It also closes any opposing orders.
*   The script then calculates the stop-loss (the price at which to automatically close the trade to limit losses) and take-profit (the price at which to automatically close the trade to secure profits) levels.
*   Finally, it sends an order to the broker to buy or sell the currency pair at the current market price.

**5. Trailing Stop:**

*   The script includes a trailing stop feature.  This automatically adjusts the stop-loss order as the price moves in a favorable direction. This helps to lock in profits and protect against potential reversals. The trailing stop is based on the recent price movement (highs for sell orders, lows for buy orders) over a defined number of bars (periods) on a specific timeframe.

**6. Alerts and Information:**

*   The script can play a sound when it opens an order.
*   It displays information on the chart, such as the volatility of the currency pair and a countdown timer.

**In summary,** this script is a trading robot that uses technical indicators to analyze the market and automatically place trades based on a set of rules. It also includes features to manage risk and protect profits. You provide the initial settings and the robot attempts to execute the strategy.
Price Data Components
Series array that contains open time of each barSeries array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Indicators Used
Moving Average of OscillatorRelative Vigor indexMoving average indicator
Miscellaneous
It plays sound alerts
9 Views
0 Downloads
0 Favorites
JS_SISTEM_2
//<=====================================================================+||
//                                                      JS_SISTEM.mq4 ||
//                                                             © 2009,||
//                    Ïèøó òîðãîâûå ñèñòåìû    js_sergey@list.ru      ||
//<=====================================================================+||
#define major   1
#define minor   0

//======================================================================||
extern string SS1        =  " ÍÀÑÒÐÎÉÊÈ ÌÌ ";
extern double Minsum     =  100; //-$- îñòàíîâêà ðàáîòû ñîâåòíèêà
extern double Lots       =  0.01;//Ìèíèìàëüíûé ëîò
extern int    StopLoss   =  135;  //StopLoss avto Otstup
extern int    TakeProfit =  400; //Ìàêñèìàëüíûé ïðîôèò
extern bool   MM         =  True;//Óïðàâëåíèå êàïèòàëîì True-âêë 
extern double Risk       =  5;   //Ïðîöåíò ñâîáîäíûõ ñðåäñòâ
extern int    Slippage   =  3;   //Ïðîñêàëüçûâàíèå öåíû
extern int    Volot      =  48;  //Ñêîëüêî áàðîâ ïîêàç âîëîòèëüíîñòü
extern int    Magic      =  12321;
//======================================================================||
extern string SS2        =  " MA ÍÀÑÒÐÎÉÊÈ ";
extern int    Razk       =  28;//EURUSD-28: GBRUSD-39:
extern int    MA_1       =  55;
extern int    MA_2       =  89;
extern int    MA_3       =  144;
//======================================================================||
extern string SS3        =  " OsMA ÍÀÑÒÐÎÉÊÈ ";
extern int    fast       =  13;
extern int    slow       =  55;
extern int    signal     =  21;
//======================================================================||
extern string SS4        =  " RVI ÍÀÑÒÐÎÉÊÈ ";
extern int    RVI_Per    =  55;
extern double RVI_max    =  0.05;
extern double RVI_min    = -0.05;
//======================================================================||
extern string SS5        =  "ÒÐÅÉËÈÍÃ ÒÅÍÈ";
extern bool   Trailing   =  True;
extern int    Tmfrm      =  30; // ïåðèîä, ïî áàðàì êîòîðîãî ñëåäóåò òðàëèòü 
extern int    Bars_n     =  13; // êîë-âî áàðîâ, ïî êîòîðûì ñëåäóåò òðàëèòü
extern int    Indent     =  1;  // îòñòóï îò òåíè áàðà, íà êîòîðîì ðàçìåùàåòñÿ ñòîïëîññ
//======================================================================||
extern string SS6        =  " --- UseSound ---";
extern bool   UseSound   =  True;         // Èñïîëüçîâàòü çâóêîâîé ñèãíàë
extern string Sound_o    =  "ok.wav";     // Íàèìåíîâàíèå çâóêîâîãî ôàéëà
//======================================================================||
#include <stdlib.mqh>
#include <stderror.mqh>
double new_extremum,Rsmin,Rsmax;
int AvgRange;
string comm;
double s1[];
//======================================================================||
int deinit()
{
ObjectDelete("time");
return(0);
}
void start() 
{
if(AccountFreeMargin()<Minsum) // äåíüãè êîí÷èëèñü
{
Print("äåíüãè êîí÷èëèñü = ", AccountFreeMargin());
return(0);  
} 
//========ManiMenedjment=================================================================================================
if(MM){if(Risk<0.1||Risk>100){Comment("Invalid Risk Value.");
return(0);}
else{Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*(Risk/(StopLoss+(Ask-Bid))*100.0)*Point*100.0)/(Ask*MarketInfo(Symbol(),
MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT);}}
if(MM==false){Lots=Lots;}
//=======================================================================================================================
if (Trailing) TrailPositions();  
double OsMA1  = iOsMA(NULL,0,fast,slow,signal,PRICE_CLOSE,0);
double RVI_M  = iRVI(NULL,0,RVI_Per,PRICE_CLOSE,MODE_MAIN);
double RVI_S  = iRVI(NULL,0,RVI_Per,PRICE_CLOSE,MODE_SIGNAL);
double ima_a  = iMA(NULL,0,MA_1,0,3,0,0);
double ima_b  = iMA(NULL,0,MA_2,0,3,0,0);
double ima_c  = iMA(NULL,0,MA_3,0,3,0,0);
int   rash_1  = (ima_a - ima_c)/Point;
int   rash_2  = (ima_c - ima_a)/Point;
//=======================================================================================================================
Rsmax = High[iHighest(NULL, 0, MODE_HIGH, Volot, 0)]; 
Rsmin = Low[iLowest(NULL, 0, MODE_LOW, Volot, 0)];  
AvgRange = (Rsmax - Rsmin)/ Point;
comm = "Âîëîòèëüíîñòü:  " + AvgRange + " ïóíêòîâ" + "\n";
Comment(comm);
//=====×àñû==============================================================================================================
double f;
int m,s,k;
m=Time[0]+Period()*60-CurTime();
f=m/60.0;
s=m%60;
m=(m-m%60)/60;
ObjectDelete("time");
if(ObjectFind("time") != 0)
{
ObjectCreate("time", OBJ_TEXT, 0, Time[0], Close[0]+ 0.0005);
ObjectSetText("time","             "+m+":"+s,8, "Arial", DodgerBlue);
}
else
{
ObjectMove("time", 0, Time[0], Close[0]+0.0005);
}
//=======================================================================================================================
int BuyCnt = 0;
int SellCnt = 0;
int cnt = OrdersTotal();
for (int i=0; i < cnt; i++)
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;
int type = OrderType();
if (type == OP_BUY) BuyCnt++;
if (type == OP_SELL) SellCnt++;
}
double price, sl, tp;
//=======================================================================================================================
if (OsMA1>0.0 && RVI_M>RVI_S && RVI_S>=RVI_max && ima_a>ima_b && ima_b>ima_c && rash_1<Razk)
{  
if (BuyCnt > 0) return;
if (CloseOrders(OP_SELL) > 0) return;
price = Ask;
sl = If(StopLoss > 0, price - StopLoss*Point,0);
tp = If(TakeProfit > 0, price + TakeProfit*Point,0);
Buy(Symbol(), GetLots(), price, sl, tp, Magic);
return;
}
//======================================================================================================================
if (OsMA1<0.0 && RVI_M<RVI_S && RVI_S<=RVI_min && ima_a<ima_b && ima_b<ima_c && rash_2<Razk)
{ 
if (SellCnt > 0) return;
if (CloseOrders(OP_BUY) > 0) return;
price = Bid;
sl = If(StopLoss > 0, price + StopLoss*Point,0);
tp = If(TakeProfit > 0, price - TakeProfit*Point,0);
Sell(Symbol(), GetLots(), price, sl, tp, Magic);
return;
}}
//======================================================================================================================
double If(bool cond, double if_true, double if_false)
{
if (cond) return (if_true);
return (if_false);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
double GetLots() 
{
return (Lots);
}
int CloseOrders(int type) 
{  
int cnt = OrdersTotal();
for (int i=cnt-1; i >= 0; i--) 
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;
if (OrderType() != type) continue; 
if (type == OP_BUY) 
{
RefreshRates();
CloseOrder(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID));
continue;
}
if (type == OP_SELL) 
{
RefreshRates();
CloseOrder(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK));
continue;
}}
int orders = 0;
cnt = OrdersTotal();
for (i = 0; i < cnt; i++) 
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;
if (OrderType() == type) orders++;
}
return (orders); 
}
//======================================================================================================================
void TrailPositions() 
{
int cnt = OrdersTotal();
for (int i=0; i<cnt; i++) 
{
if (!(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;
//=====ÁËÎÊ==================================TrailingStop===============================================
if (OrderType() == OP_BUY)
{
for(i=1;i<=Bars_n;i++)
{
if (i==1) new_extremum = iLow(NULL,Tmfrm,i);
else 
if (new_extremum>iLow(NULL,Tmfrm,i)) new_extremum = iLow(NULL,Tmfrm,i);
}         
if ((((new_extremum - Bars_n*Point)>OrderStopLoss()) || (OrderStopLoss()==0)) && ((new_extremum - Indent*Point)>OrderOpenPrice()) 
&& (new_extremum - Indent*Point<Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point))
if (!OrderModify(OrderTicket(),OrderOpenPrice(),new_extremum - Indent*Point,OrderTakeProfit(),OrderExpiration()))
return; 
}
//=====ÁËÎÊ=================================TrailingStop=================================================
if (OrderType() == OP_SELL)
{
for(i=1;i<=Bars_n;i++)
{
if (i==1) new_extremum = iHigh(NULL,Tmfrm,i);
else 
if (new_extremum<iHigh(NULL,Tmfrm,i)) new_extremum = iHigh(NULL,Tmfrm,i);
}         
if ((((new_extremum + (Bars_n + MarketInfo(Symbol(),MODE_SPREAD))*Point)<OrderStopLoss()) || (OrderStopLoss()==0)) && 
((new_extremum + (Indent + MarketInfo(Symbol(),MODE_SPREAD))*Point)<OrderOpenPrice()) && 
(new_extremum + (Indent + MarketInfo(Symbol(),MODE_SPREAD))*Point>Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point))
if (!OrderModify(OrderTicket(),OrderOpenPrice(),new_extremum + (Indent + MarketInfo(Symbol(),MODE_SPREAD))*Point,OrderTakeProfit(),OrderExpiration()))
return; 
}}}
//======================================================================================================================
int SleepOk = 2000;
int SleepErr = 6000;
int Buy(string symbol, double lot, double price, double sl, double tp, int magic, string comment="") 
{
int dig = MarketInfo(symbol, MODE_DIGITS);
price = NormalizeDouble(price, dig);
sl = NormalizeDouble(sl, dig);
tp = NormalizeDouble(tp, dig);
    
string _lot = DoubleToStr(lot, 2);
string _price = DoubleToStr(price, dig);
string _sl = DoubleToStr(sl, dig);
string _tp = DoubleToStr(tp, dig);
//======================================================================================================================
int res = OrderSend(symbol, OP_BUY, lot, price, Slippage, sl, tp, comment, magic, 0);
PlaySound(Sound_o);
if (res >= 0)
{
Sleep(SleepOk);
return (res);
} 	
int code = GetLastError();
Print("Error opening BUY order: ", ErrorDescription(code), " (", code, ")");
Sleep(SleepErr);
return (-1);
}
int Sell(string symbol, double lot, double price, double sl, double tp, int magic, string comment="") 
{
int dig = MarketInfo(symbol, MODE_DIGITS);
price = NormalizeDouble(price, dig);
sl = NormalizeDouble(sl, dig);
tp = NormalizeDouble(tp, dig);
string _lot = DoubleToStr(lot, 2);
string _price = DoubleToStr(price, dig);
string _sl = DoubleToStr(sl, dig);
string _tp = DoubleToStr(tp, dig);
//======================================================================================================================
int res = OrderSend(symbol, OP_SELL, lot, price, Slippage, sl, tp, comment, magic, 0);
PlaySound(Sound_o);
if (res >= 0)
{
Sleep(SleepOk);
return (res);
} 	
int code = GetLastError();
Print("Error opening SELL order: ", ErrorDescription(code), " (", code, ")");
Sleep(SleepErr);
return (-1);
}
bool CloseOrder(int ticket, double lot, double price) 
{
if (!OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES)) return(false);
int dig = MarketInfo(OrderSymbol(), MODE_DIGITS);
string _lot = DoubleToStr(lot, 2);
string _price = DoubleToStr(price, dig);
Print("CloseOrder ", ticket, ", ", _lot, ", ", _price, ", ", Slippage);
bool res = OrderClose(ticket, lot, price, Slippage);
if (res)
{
Sleep(SleepOk);
return (res);
} 	
int code = GetLastError();
Print("CloseOrder failed: ", ErrorDescription(code), " (", code, ")");
Sleep(SleepErr);
return (false);
}
//======================================================================================================================

Profitability Reports

EUR/USD Jul 2025 - Sep 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%
USD/JPY Jan 2025 - Jul 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%
USD/CHF Jan 2025 - Jul 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%
USD/CAD Jan 2025 - Jul 2025
0.00
Total Trades 1
Won Trades 0
Lost trades 1
Win Rate 0.00 %
Expected payoff -4.72
Gross Profit 0.00
Gross Loss -4.72
Total Net Profit -4.72
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
3.71
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff 14.64
Gross Profit 60.12
Gross Loss -16.20
Total Net Profit 43.92
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -2.92
Gross Profit 0.00
Gross Loss -8.77
Total Net Profit -8.77
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.00
Total Trades 1
Won Trades 1
Lost trades 0
Win Rate 100.00 %
Expected payoff 8.00
Gross Profit 8.00
Gross Loss 0.00
Total Net Profit 8.00
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 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%
AUD/USD Jan 2025 - Jul 2025
1.48
Total Trades 3
Won Trades 1
Lost trades 2
Win Rate 33.33 %
Expected payoff 4.77
Gross Profit 44.00
Gross Loss -29.70
Total Net Profit 14.30
-100%
-50%
0%
50%
100%
USD/CAD 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%

Comments