JS_Signal_Baes

Author: Copyright � 2009, js_sergey@list.ru
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 automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicatorMACD HistogramRelative strength indexStochastic oscillatorCommodity channel index
Miscellaneous
It plays sound alertsIt sends emails
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%
JS_Signal_Baes
//<=====================================================================+||
//                                                 JS_Signal_Baes.mq4 ||
//                                                             © 2009,||
//          Ïèøó òîðãîâûå ñèñòåìû    js_sergey@list.ru                ||
//<=====================================================================+||


#property copyright "Copyright © 2009, js_sergey@list.ru"
#property link      "JS_Signal_Baes"
//=======================================================================================<<
extern string SS1           = " ÍÀÑÒÐÎÉÊÈ ÌÌ ";
extern double Lot           =  0.01;   //Ìèíèìàëüíûé ëîò 
extern int    StopLoss      =  100;     //StopLoss avto Otstup
extern int    TakeProfit    =  300;    //Ìàêñèìàëüíûé ïðîôèò
extern bool   MM            =  True;   //Óïðàâëåíèå êàïèòàëîì True-âêë 
extern double Minsum        =  200;    //-$- îñòàíîâêà ðàáîòû ñîâåòíèêà
extern double Risk          =  5;      //Ïðîöåíò ñâîáîäíûõ ñðåäñòâ
extern int    Step          =  3;      //Ïðîñêàëüçûâàíèå öåíû
extern int    Magic         =  12321;
//=======================================================================================<<
extern int   MACD_Fast      =  8;
extern int   MACD_Slow      =  17;
extern int   MACD_Sig       =  9;
//=======================================================================================<<
extern int   CCI_Per        =  13;
//=======================================================================================<<
extern int   SH_K_Per       =  5;
extern int   SH_D_Per       =  3;
extern int   SH_Slow        =  3;
//=======================================================================================<<
extern int   MA_Fast        =  5;
extern int   MA_Slow        =  9;
extern int   MA_MODE        =  3;
//=======================================================================================<<
extern int   RSI_Per        =  9;
//=======================================================================================<<
extern string SS5           = "ÒÐÅÉËÈÍÃ ÒÅÍÈ";
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";   // Íàèìåíîâàíèå çâóêîâîãî ôàéëà
extern color  OpenBuy       =  BlueViolet; // Öâåò çíà÷êà îòêðûòèÿ Buy
extern color  OpenSell      =  DeepPink;   // Öâåò çíà÷êà îòêðûòèÿ Sell
extern color  ÑloseBuy      =  Blue;       // Öâåò çíà÷êà îòêðûòèÿ Buy
extern color  ÑloseSell     =  Red;        // Öâåò çíà÷êà îòêðûòèÿ Sell
//=======================================================================================<<
#include <stdlib.mqh>
#include <WinUser32.mqh>    // Ñòàíäàðòíàÿ áèáëèîòåêà ÌÒ4
  
double new_extremum;

int deinit()
{
ObjectDelete("time");
return(0);
}
int start()
{
int total=OrdersTotal(); // Êîëè÷åñòâî îðäåðîâ
if (total==0)  
Comment("Â òîðãîâëå îðäåðîâ íåò"); 
else      
Comment("Â òîðãîâëå èìååòñÿ ",total," îðäåðà.");

if(AccountFreeMargin()<Minsum) // äåíüãè êîí÷èëèñü
{
Print("äåíüãè êîí÷èëèñü = ", AccountFreeMargin());
return(0);  
} 
int cnt,ticket;
if(Bars<100)
{
Print("Ñëèøêèì ìàëî èñòîðèè ");
return(0);  
}
//==============================================================================================================================
double ma_a = iMA(NULL,1,  MA_Fast,0,MA_MODE,0,0);
double ma_b = iMA(NULL,1,  MA_Slow,0,MA_MODE,0,0);
double ma_c = iMA(NULL,5,  MA_Fast,0,MA_MODE,0,0);
double ma_d = iMA(NULL,5,  MA_Slow,0,MA_MODE,0,0);
double ma_e = iMA(NULL,15, MA_Fast,0,MA_MODE,0,0);
double ma_f = iMA(NULL,15, MA_Slow,0,MA_MODE,0,0);
double ma_g = iMA(NULL,30, MA_Fast,0,MA_MODE,0,0);
double ma_h = iMA(NULL,30, MA_Slow,0,MA_MODE,0,0);
double ma_i = iMA(NULL,60, MA_Fast,0,MA_MODE,0,0);
double ma_j = iMA(NULL,60, MA_Slow,0,MA_MODE,0,0);
double ma_k = iMA(NULL,240,MA_Fast,0,MA_MODE,0,0);
double ma_l = iMA(NULL,240,MA_Slow,0,MA_MODE,0,0);

double macd_a = iMACD(NULL, 1,  MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_MAIN, 0);
double macd_b = iMACD(NULL, 1,  MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_SIGNAL, 0);
double macd_c = iMACD(NULL, 5,  MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_MAIN, 0);
double macd_d = iMACD(NULL, 5,  MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_SIGNAL, 0);
double macd_e = iMACD(NULL, 15, MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_MAIN, 0);
double macd_f = iMACD(NULL, 15, MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_SIGNAL, 0);
double macd_g = iMACD(NULL, 30, MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_MAIN, 0);
double macd_h = iMACD(NULL, 30, MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_SIGNAL, 0);
double macd_i = iMACD(NULL, 60, MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_MAIN, 0);
double macd_j = iMACD(NULL, 60, MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_SIGNAL, 0);
double macd_k = iMACD(NULL, 240,MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_MAIN, 0);
double macd_l = iMACD(NULL, 240,MACD_Fast, MACD_Slow, MACD_Sig, 0, MODE_SIGNAL, 0);

double rsi_a = iRSI(NULL,1,  RSI_Per,0,0);
double rsi_b = iRSI(NULL,5,  RSI_Per,0,0);
double rsi_c = iRSI(NULL,15, RSI_Per,0,0);
double rsi_d = iRSI(NULL,30, RSI_Per,0,0);
double rsi_e = iRSI(NULL,60, RSI_Per,0,0);
double rsi_f = iRSI(NULL,240,RSI_Per,0,0);

double stoch_a = iStochastic(NULL, 1,  SH_K_Per, SH_D_Per, SH_Slow,1,0,MODE_MAIN,0);
double stoch_b = iStochastic(NULL, 5,  SH_K_Per, SH_D_Per, SH_Slow,1,0,MODE_MAIN,0);
double stoch_c = iStochastic(NULL, 15, SH_K_Per, SH_D_Per, SH_Slow,1,0,MODE_MAIN,0);
double stoch_d = iStochastic(NULL, 30, SH_K_Per, SH_D_Per, SH_Slow,1,0,MODE_MAIN,0);
double stoch_e = iStochastic(NULL, 60, SH_K_Per, SH_D_Per, SH_Slow,1,0,MODE_MAIN,0);
double stoch_f = iStochastic(NULL, 240,SH_K_Per, SH_D_Per, SH_Slow,1,0,MODE_MAIN,0);

double cci_a = iCCI(NULL, 1,  CCI_Per,0,0);
double cci_b = iCCI(NULL, 5,  CCI_Per,0,0);
double cci_c = iCCI(NULL, 15, CCI_Per,0,0);
double cci_d = iCCI(NULL, 30, CCI_Per,0,0);
double cci_e = iCCI(NULL, 60, CCI_Per,0,0);
double cci_f = iCCI(NULL, 240,CCI_Per,0,0);
//======== ×ÀÑÛ ===============================================================================================================
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,14, "Arial", DodgerBlue);
}
else
{
ObjectMove("time", 0, Time[0], Close[0]+0.0005);
}
Lot = GetLots();
//==============================================================================================================================
if(total<1) 
{
if (ma_a>ma_b && ma_c>ma_d && ma_e>ma_f && ma_g>ma_h && ma_i>ma_j && ma_k>ma_l &&
 rsi_a>50 && rsi_b>50 && rsi_c>50 && rsi_d>50 && rsi_e>50 && rsi_f>50 &&
 cci_a>0.0 && cci_b>0.0 && cci_c>0.0 && cci_d>0.0 && cci_e>0.0 && cci_f>0.0 &&
 stoch_a>40 && stoch_b>40 && stoch_c>40 && stoch_d>40 && stoch_e>40 && stoch_f>40 &&
 macd_a>macd_b && macd_c>macd_d  && macd_e>macd_f  && macd_g>macd_h && macd_i>macd_j && macd_k>macd_l)
{
ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,Step,Ask-StopLoss*Point,Ask+TakeProfit*Point,"BAY",Magic,0,OpenBuy);
if(ticket>0)
PlaySound(Sound_o);
SendMail(Symbol()+" BUY Order JS_Signal_Baes","BUY = "+Ask );
return(0); 
}
//==============================================================================================================================
if (ma_a<ma_b && ma_c<ma_d && ma_e<ma_f && ma_g<ma_h && ma_i<ma_j && ma_k<ma_l &&
 rsi_a<50 && rsi_b<50 && rsi_c<50 && rsi_d<50 && rsi_e<50 && rsi_f<50 &&
 cci_a<0.0 && cci_b<0.0 && cci_c<0.0 && cci_d<0.0 && cci_e<0.0 && cci_f<0.0 &&
 stoch_a<60 && stoch_b<60 && stoch_c<60 && stoch_d<60 && stoch_e<60 && stoch_f<60 &&
 macd_a<macd_b && macd_c<macd_d  && macd_e<macd_f  && macd_g<macd_h && macd_i<macd_j && macd_k<macd_l)
{
ticket=OrderSend(Symbol(),OP_SELL,Lot,Bid,Step,Bid+StopLoss*Point,Bid-TakeProfit*Point,"SELL",Magic,0,OpenSell);
if(ticket>0)
PlaySound(Sound_o);
SendMail(Symbol()+" SELL Order JS_Signal_Baes","SELL = "+Bid );
return(0);
}
return(0); 
}
//==============================================================================================================================
int i=0;
for(cnt=0;cnt<total;cnt++)
{
if (!(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;
{
if(OrderType()==OP_BUY)
{
if (ma_a<ma_b && ma_c<ma_d && ma_e<ma_f && ma_g<ma_h && ma_i<ma_j && ma_k<ma_l)
{
OrderClose(OrderTicket(),OrderLots(),Bid,Step,ÑloseBuy); // close position
return(0);
}
//=========Trailing=============================================================================================================
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(0);
}
//==============================================================================================================================
if (OrderType() == OP_SELL)
{
if (ma_a>ma_b && ma_c>ma_d && ma_e>ma_f && ma_g>ma_h && ma_i>ma_j && ma_k>ma_l)
{
OrderClose(OrderTicket(),OrderLots(),Ask,Step,ÑloseSell); // close position
return(0);
}}}
//=========Trailing=============================================================================================================
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; 
}}}}
//======= ManiMenedjment =======================================================================================================
double GetLots()
{
if(MM){if(Risk<0.1||Risk>100){Comment("Ñëèøêîì áîëüøîé ÐÈÑÊ! ÒÎÐÃÎÂËß ÏÐÅÊÐÀÙÅÍÀ.");
return(0);}
double MinLot = MarketInfo(Symbol(),MODE_MINLOT);
double MaxLot = MarketInfo(Symbol(),MODE_MAXLOT);
double Prots  = Risk/StopLoss;
double Lots=MathFloor(AccountFreeMargin()*Prots/MarketInfo(Symbol(),MODE_MARGINREQUIRED)/MarketInfo(Symbol(),
MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP);}
if(Lots<MinLot)Lots=MinLot;
if(Lots>MaxLot)Lots=MaxLot;               
if(MM==false){Lots=Lot;}
return(Lots);
}
//==============================================================================================================================

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---