Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.69 KB | None | 0 0
  1.  
  2. //+------------------------------------------------------------------+
  3. //| Giga.mq4 |
  4. //| mine |
  5. //| https://www.mql5.com |
  6. //+------------------------------------------------------------------+
  7. #property copyright "mine"
  8. #property link "https://www.mql5.com"
  9. #property version "1.00"
  10. #property strict
  11.  
  12. // Indicator parameters
  13. string IndiVersion="lel";
  14.  
  15.  
  16. string TimeFrameSettings="——————————————————————————————";
  17. int TimeFramePeriod=0; // Timeframe: 0,1,5,15,30,60,240,1440 etc. Current Timeframe=0.
  18. int TimeFrameAuto=0; // Automatically select higher TF. M15 and M30 -> H1. Off=0, 1st HTF=1, 2nd HTF=2
  19. string TVISettings="——————————————————————————————";
  20. int TVIr=12;
  21. int TVIs=12;
  22. int TVIu=5;
  23. string TVILabel="TVI";
  24. string CCISettings="——————————————————————————————";
  25. int CCIPeriod=20;
  26. double CCIThreshold=60;
  27. string CCILabel="CCI";
  28. string T3_8Settings="——————————————————————————————";
  29. int T3_8Period=8;
  30. int T3_8BarCount=1500;
  31. string T3_8Label="T3..";
  32. string GannHiLoSettings="——————————————————————————————";
  33. int GannHiLoPeriod=10;
  34. string GannHiLoLabel="GHL";
  35. string AlertSettings="——————————————————————————————";
  36. bool AlertOnBarClose=True; // Alert only when an open bar closes
  37. bool AlertPopup=False; // Enable popup window & sound on alert
  38. bool AlertEmail=False; // Enable send email on alert
  39. string AlertSubject=""; // Email Subject. Null string ("") will result in a preconfigured subject.
  40. string DisplaySettings="——————————————————————————————";
  41. color DisplayLabelColor=White; // Color of Histogram Id labels
  42.  
  43. double gadTVIUp[];
  44. double gadTVIDn[];
  45. double gadCCIUp[];
  46. double gadCCIDn[];
  47. double gadT3Up[];
  48. double gadT3Dn[];
  49. double gadGHLUp[];
  50. double gadGHLDn[];
  51.  
  52. // Labels
  53. double gadGap[4];
  54.  
  55. // Globals
  56. int giRepaintBars;
  57. string gsIndicatorName;
  58. bool gbInit;
  59.  
  60.  
  61. bool isLastLineBlue = false;
  62.  
  63. extern int pointsForProfit = 500;
  64. extern int pointsForLos = 100;
  65. extern double LotValue = 0.01;
  66.  
  67.  
  68. int LosCounter;
  69. extern int linearPersent = 50;
  70. bool isPossibleToBuy;
  71. bool isPossibleToSell;
  72. int orderBuy = 123;
  73. int orderSell = 123;
  74.  
  75. bool orderBuyClose = true;
  76. bool orderSellClose = true;
  77.  
  78.  
  79. //от 0 до 0.5;
  80. extern double coefficientOfStopLossShift = 0.1;
  81.  
  82.  
  83. extern double summToBuy;
  84. extern double summToSell;
  85. extern double coeff0;
  86. extern double coeff1;
  87. extern double coeff2;
  88. extern double coeff3;
  89. extern double coeff4;
  90. extern double coeff5;
  91. extern double coeff6;
  92. extern double coeff7;
  93. extern double coeff8;
  94. double coeff9;
  95. //Анализатор 2000 pro v1.0
  96.  
  97.  
  98.  
  99.  
  100. double indicators[10];
  101. double coefficients[10];
  102. int currentTimeFrame;
  103. int nextTimeFrame;
  104. void TuneTimeFrame()
  105. {
  106. currentTimeFrame = 0;
  107. nextTimeFrame = 0;
  108. int timeFrames[10]; //(1,5,15,30,60,240,1440,10080,43200);
  109. timeFrames[0] = 1;
  110. timeFrames[1] = 5;
  111. timeFrames[2] = 15;
  112. timeFrames[3] = 30;
  113. timeFrames[4] = 60;
  114. timeFrames[5] = 240;
  115. timeFrames[6] = 1440;
  116. timeFrames[7] = 10080;
  117. timeFrames[8] = 43200;
  118. timeFrames[9] = 43200;
  119.  
  120. for(int i = 0; i<9;i++)
  121. {
  122. if (Period() == timeFrames[i])
  123. {
  124. currentTimeFrame = timeFrames[i];
  125. nextTimeFrame = timeFrames[i+1];
  126. break;
  127. }
  128. }
  129. }
  130.  
  131.  
  132. //+------------------------------------------------------------------+
  133. //| Expert initialization function |
  134. //+------------------------------------------------------------------+
  135. int OnInit()
  136. {
  137. //---
  138. //Настройка входных данных
  139.  
  140.  
  141. coefficients[0] = coeff0;
  142. coefficients[1] = coeff1;
  143. coefficients[2] = coeff2;
  144. coefficients[3] = coeff3;
  145. coefficients[4] = coeff4;
  146. coefficients[5] = coeff5;
  147. coefficients[6] = coeff6;
  148. coefficients[7] = coeff7;
  149. coefficients[8] = coeff8;
  150. coefficients[9] = coeff9;
  151.  
  152. //---
  153. return(INIT_SUCCEEDED);
  154. }
  155. //+------------------------------------------------------------------+
  156. //| Expert deinitialization function |
  157. //+------------------------------------------------------------------+
  158. void OnDeinit(const int reason)
  159. {
  160. //---
  161.  
  162. }
  163. //+------------------------------------------------------------------+
  164. //| Expert tick function |
  165. //+------------------------------------------------------------------+
  166.  
  167. void OnTick()
  168. {
  169.  
  170. TuneTimeFrame();
  171.  
  172. indicators[0] = (int)iCustom(NULL,0,"GenesisMatrix 2.21_1",IndiVersion,TimeFrameSettings,TimeFramePeriod, TimeFrameAuto,TVISettings,TVIr,TVIs,TVIu,TVILabel,CCISettings,CCIPeriod,CCIThreshold,CCILabel,T3_8Settings,T3_8Period,T3_8BarCount,T3_8Label,GannHiLoSettings,GannHiLoPeriod,GannHiLoLabel,AlertSettings,AlertOnBarClose,AlertPopup,AlertEmail,AlertSubject,DisplaySettings,DisplayLabelColor,0,1) > 0.01;
  173. indicators[1] = (int)iCustom(NULL,0,"GenesisMatrix 2.21_1",IndiVersion,TimeFrameSettings,TimeFramePeriod, TimeFrameAuto,TVISettings,TVIr,TVIs,TVIu,TVILabel,CCISettings,CCIPeriod,CCIThreshold,CCILabel,T3_8Settings,T3_8Period,T3_8BarCount,T3_8Label,GannHiLoSettings,GannHiLoPeriod,GannHiLoLabel,AlertSettings,AlertOnBarClose,AlertPopup,AlertEmail,AlertSubject,DisplaySettings,DisplayLabelColor,2,1) > 0.01;
  174. indicators[2] = (int)iCustom(NULL,0,"GenesisMatrix 2.21_1",IndiVersion,TimeFrameSettings,TimeFramePeriod, TimeFrameAuto,TVISettings,TVIr,TVIs,TVIu,TVILabel,CCISettings,CCIPeriod,CCIThreshold,CCILabel,T3_8Settings,T3_8Period,T3_8BarCount,T3_8Label,GannHiLoSettings,GannHiLoPeriod,GannHiLoLabel,AlertSettings,AlertOnBarClose,AlertPopup,AlertEmail,AlertSubject,DisplaySettings,DisplayLabelColor,4,1) > 0.01;
  175. indicators[3] = (int)iCustom(NULL,0,"GenesisMatrix 2.21_1",IndiVersion,TimeFrameSettings,TimeFramePeriod, TimeFrameAuto,TVISettings,TVIr,TVIs,TVIu,TVILabel,CCISettings,CCIPeriod,CCIThreshold,CCILabel,T3_8Settings,T3_8Period,T3_8BarCount,T3_8Label,GannHiLoSettings,GannHiLoPeriod,GannHiLoLabel,AlertSettings,AlertOnBarClose,AlertPopup,AlertEmail,AlertSubject,DisplaySettings,DisplayLabelColor,6,1) > 0.01;
  176. indicators[4] = iStochastic(NULL,currentTimeFrame,11,3,3,MODE_SMA,0,1,1) / 100;
  177. indicators[5] = iStochastic(NULL,currentTimeFrame,11,3,3,MODE_SMA,0,0,1) / 100;
  178. indicators[6] = iStochastic(NULL, nextTimeFrame,11,3,3,MODE_SMA,0,1,1) / 100;
  179. indicators[7] = iStochastic(NULL, nextTimeFrame,11,3,3,MODE_SMA,0,0,1) / 100;
  180. double high = High[1];
  181. double low = Low[1];
  182. indicators[8] = high - low;
  183. double summ = 0;
  184. for(int i = 0; i < 9; i++)
  185. summ += indicators[i] * coefficients[i];
  186. isPossibleToBuy = false;
  187. isPossibleToSell = false;
  188. if (summ < summToBuy)
  189. isPossibleToBuy = true;
  190. else if (summ > summToSell)
  191. isPossibleToSell = true;
  192.  
  193.  
  194.  
  195.  
  196. SetStopLossLinear();
  197. //--------------------------------------------------------
  198. //Проверка начала изменения тренда по индикаторам.
  199. //--------------------------------------------------------
  200.  
  201.  
  202.  
  203. if(isPossibleToBuy)
  204. {
  205. int x = OrderClose(orderSell,LotValue,Ask,4,Blue);
  206. orderSellClose = true;
  207. }
  208.  
  209. if(isPossibleToSell)
  210. {
  211. orderBuyClose = true;
  212. int x = OrderClose(orderBuy,LotValue,Bid,4,Red);
  213. }
  214.  
  215.  
  216. //--------------------------------------------------------------
  217. //Покупка и продажа, если возможно.
  218. //--------------------------------------------------------------
  219. if (isPossibleToBuy && (!OrderSelect(orderBuy, SELECT_BY_TICKET)||OrderCloseTime() != 0))
  220. {
  221. double pointsForLocalMin = (Ask - getMin(LosCounter)) * (1 + coefficientOfStopLossShift);
  222. double pointsForForGlobalMin = pointsForLos * Point;
  223. if (pointsForLocalMin < pointsForForGlobalMin)
  224. pointsForLocalMin = pointsForForGlobalMin;
  225. orderBuy = OrderSend(Symbol(),OP_BUY,LotValue,Ask,5,Ask - pointsForLocalMin,Bid + pointsForProfit*Point,NULL,228,0,Blue);
  226.  
  227. orderBuyClose = false;
  228. isPossibleToBuy = false;
  229. return;
  230. }
  231. if (isPossibleToSell && (!OrderSelect(orderSell, SELECT_BY_TICKET)||OrderCloseTime() != 0))
  232. {
  233. double pointsForLocalMax = (getMax(LosCounter) - Bid) * (1 + coefficientOfStopLossShift);
  234. double pointsForForGlobalMax = pointsForLos * Point;
  235. if (pointsForLocalMax > pointsForForGlobalMax)
  236. pointsForLocalMax = pointsForForGlobalMax;
  237.  
  238. orderSell = OrderSend(Symbol(),OP_SELL,LotValue,Bid,5,Bid + pointsForLocalMax,Ask - pointsForProfit*Point,NULL,228,0,Red);
  239. orderSellClose = false;
  240. isPossibleToSell = false;
  241. return;
  242. }
  243. }
  244. //+------------------------------------------------------------------+
  245. double getMin(int count)
  246.  
  247. {
  248. double min = Low[1];
  249. for (int i = 1 ; i < count; i++)
  250. {
  251. if (Low[i]<min) min = Low[i];
  252. }
  253. return min;
  254. }
  255.  
  256. double getMax(int count)
  257.  
  258. {
  259. double max = High[1];
  260. for (int i = 1 ; i< count; i++)
  261. {
  262. if (High[i]>max) max = High[i];
  263. }
  264. return max;
  265. }
  266.  
  267. void SetStopLossLinear()
  268. {
  269. double k = Point * linearPersent / 100.0;
  270. if(!orderBuyClose)
  271. {
  272. if (!OrderSelect(orderBuy, SELECT_BY_TICKET)) return;
  273.  
  274. OrderSelect(orderBuy, SELECT_BY_TICKET);
  275.  
  276. if ((Bid - pointsForLos * k > OrderOpenPrice())&&(Bid - pointsForLos * k > OrderStopLoss()))
  277. {
  278. bool x = OrderModify(orderBuy,
  279. OrderOpenPrice(),
  280. Bid - pointsForLos * k,
  281. OrderTakeProfit(),
  282. NULL);
  283. }
  284. }
  285.  
  286. if(!orderSellClose)
  287. {
  288. if (!OrderSelect(orderSell, SELECT_BY_TICKET)) return;
  289. OrderSelect(orderSell, SELECT_BY_TICKET);
  290. if ((Ask + pointsForLos * k < OrderOpenPrice())&&(Ask + pointsForLos * k < OrderStopLoss()))
  291. {
  292.  
  293. bool x = OrderModify(orderSell,
  294. OrderOpenPrice(),
  295. Ask + pointsForLos * k,
  296. OrderTakeProfit(),
  297. NULL);
  298.  
  299. }
  300. }
  301. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement