Price Data Components
Orders Execution
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Profitability Reports
AUD/USD
Oct 2024 - Jan 2025
0.00 %
Total Trades
2
Won Trades
0
Lost trades
0
Win Rate
0.00 %
Expected payoff
28.00
Gross Profit
56.00
Gross Loss
0.00
Total Net Profit
56.00
-100%
-50%
0%
50%
100%
JS_SISTEM
//<=====================================================================+||
// 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 SLoss = 80; //StopLoss avto Otstup
extern int TakeProfit = 400; //Ìàêñèìàëüíûé ïðîôèò
extern bool MM = True;//Óïðàâëåíèå êàïèòàëîì True-âêë
extern double Risk = 2; //Ïðîöåíò ñâîáîäíûõ ñðåäñòâ
extern int Slippage = 3; //Ïðîñêàëüçûâàíèå öåíû
extern int Magic = 7777777;
//======================================================================||
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 bool Trlinloss = false; // ñëåäóåò ëè òðàëèòü íà ó÷àñòêå ëîññîâ (ìåæäó êóðñîì ñòîïëîññà è îòêðûòèÿ)
//======================================================================||
extern string SS6 = " --- öâåò ñèìâîëîâ ---";
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[];
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/(SLoss+(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_S = iMA(NULL,0,5,0,3,0,0);
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;
int rash_3 = (ima_S - ima_c)/Point;
int rash_4 = (ima_c - ima_S)/Point;
int StopLoss = rash_3+SLoss;
int StopLosb = rash_4+SLoss;
//=====×àñû==============================================================================================================
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 + StopLosb*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 (Trlinloss==true)
{
if ((((new_extremum - Indent*Point)>OrderStopLoss()) || (OrderStopLoss()==0)) &&
(new_extremum - Indent*Point<Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point))
if (!OrderModify(OrderTicket(),OrderOpenPrice(),new_extremum - Indent*Point,OrderTakeProfit(),OrderExpiration()))
Print("Íå óäàëîñü ìîäèôèöèðîâàòü îðäåð ¹",OrderTicket(),". Îøèáêà: ",GetLastError());
}
else
{
if ((((new_extremum - Indent*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()))
Print("Íå óäàëîñü ìîäèôèöèðîâàòü îðäåð ¹",OrderTicket(),". Îøèáêà: ",GetLastError());
}}
//=====ÁËÎÊ=================================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 (Trlinloss==true)
{
if ((((new_extremum + (Indent + MarketInfo(Symbol(),MODE_SPREAD))*Point)<OrderStopLoss()) || (OrderStopLoss()==0)) &&
(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()))
Print("Íå óäàëîñü ìîäèôèöèðîâàòü îðäåð ¹",OrderTicket(),". Îøèáêà: ",GetLastError());
}
else
{
if ((((new_extremum + (Indent + 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()))
Print("Íå óäàëîñü ìîäèôèöèðîâàòü îðäåð ¹",OrderTicket(),". Îøèáêà: ",GetLastError());
}}}}
//======================================================================================================================
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);
}
//======================================================================================================================
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
---