Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //+------------------------------------------------------------------+
- //| Giga.mq4 |
- //| mine |
- //| https://www.mql5.com |
- //+------------------------------------------------------------------+
- #property copyright "mine"
- #property link "https://www.mql5.com"
- #property version "1.00"
- #property strict
- // Indicator parameters
- string IndiVersion="lel";
- string TimeFrameSettings="——————————————————————————————";
- int TimeFramePeriod=0; // Timeframe: 0,1,5,15,30,60,240,1440 etc. Current Timeframe=0.
- int TimeFrameAuto=0; // Automatically select higher TF. M15 and M30 -> H1. Off=0, 1st HTF=1, 2nd HTF=2
- string TVISettings="——————————————————————————————";
- int TVIr=12;
- int TVIs=12;
- int TVIu=5;
- string TVILabel="TVI";
- string CCISettings="——————————————————————————————";
- int CCIPeriod=20;
- double CCIThreshold=60;
- string CCILabel="CCI";
- string T3_8Settings="——————————————————————————————";
- int T3_8Period=8;
- int T3_8BarCount=1500;
- string T3_8Label="T3..";
- string GannHiLoSettings="——————————————————————————————";
- int GannHiLoPeriod=10;
- string GannHiLoLabel="GHL";
- string AlertSettings="——————————————————————————————";
- bool AlertOnBarClose=True; // Alert only when an open bar closes
- bool AlertPopup=False; // Enable popup window & sound on alert
- bool AlertEmail=False; // Enable send email on alert
- string AlertSubject=""; // Email Subject. Null string ("") will result in a preconfigured subject.
- string DisplaySettings="——————————————————————————————";
- color DisplayLabelColor=White; // Color of Histogram Id labels
- double gadTVIUp[];
- double gadTVIDn[];
- double gadCCIUp[];
- double gadCCIDn[];
- double gadT3Up[];
- double gadT3Dn[];
- double gadGHLUp[];
- double gadGHLDn[];
- // Labels
- double gadGap[4];
- // Globals
- int giRepaintBars;
- string gsIndicatorName;
- bool gbInit;
- bool isLastLineBlue = false;
- extern int pointsForProfit = 500;
- extern int pointsForLos = 100;
- extern double LotValue = 0.01;
- int LosCounter;
- extern int linearPersent = 50;
- bool isPossibleToBuy;
- bool isPossibleToSell;
- int orderBuy = 123;
- int orderSell = 123;
- bool orderBuyClose = true;
- bool orderSellClose = true;
- //от 0 до 0.5;
- extern double coefficientOfStopLossShift = 0.1;
- extern double summToBuy;
- extern double summToSell;
- extern double coeff0;
- extern double coeff1;
- extern double coeff2;
- extern double coeff3;
- extern double coeff4;
- extern double coeff5;
- extern double coeff6;
- extern double coeff7;
- extern double coeff8;
- double coeff9;
- //Анализатор 2000 pro v1.0
- double indicators[10];
- double coefficients[10];
- int currentTimeFrame;
- int nextTimeFrame;
- void TuneTimeFrame()
- {
- currentTimeFrame = 0;
- nextTimeFrame = 0;
- int timeFrames[10]; //(1,5,15,30,60,240,1440,10080,43200);
- timeFrames[0] = 1;
- timeFrames[1] = 5;
- timeFrames[2] = 15;
- timeFrames[3] = 30;
- timeFrames[4] = 60;
- timeFrames[5] = 240;
- timeFrames[6] = 1440;
- timeFrames[7] = 10080;
- timeFrames[8] = 43200;
- timeFrames[9] = 43200;
- for(int i = 0; i<9;i++)
- {
- if (Period() == timeFrames[i])
- {
- currentTimeFrame = timeFrames[i];
- nextTimeFrame = timeFrames[i+1];
- break;
- }
- }
- }
- //+------------------------------------------------------------------+
- //| Expert initialization function |
- //+------------------------------------------------------------------+
- int OnInit()
- {
- //---
- //Настройка входных данных
- coefficients[0] = coeff0;
- coefficients[1] = coeff1;
- coefficients[2] = coeff2;
- coefficients[3] = coeff3;
- coefficients[4] = coeff4;
- coefficients[5] = coeff5;
- coefficients[6] = coeff6;
- coefficients[7] = coeff7;
- coefficients[8] = coeff8;
- coefficients[9] = coeff9;
- //---
- return(INIT_SUCCEEDED);
- }
- //+------------------------------------------------------------------+
- //| Expert deinitialization function |
- //+------------------------------------------------------------------+
- void OnDeinit(const int reason)
- {
- //---
- }
- //+------------------------------------------------------------------+
- //| Expert tick function |
- //+------------------------------------------------------------------+
- void OnTick()
- {
- TuneTimeFrame();
- 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;
- 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;
- 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;
- 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;
- indicators[4] = iStochastic(NULL,currentTimeFrame,11,3,3,MODE_SMA,0,1,1) / 100;
- indicators[5] = iStochastic(NULL,currentTimeFrame,11,3,3,MODE_SMA,0,0,1) / 100;
- indicators[6] = iStochastic(NULL, nextTimeFrame,11,3,3,MODE_SMA,0,1,1) / 100;
- indicators[7] = iStochastic(NULL, nextTimeFrame,11,3,3,MODE_SMA,0,0,1) / 100;
- double high = High[1];
- double low = Low[1];
- indicators[8] = high - low;
- double summ = 0;
- for(int i = 0; i < 9; i++)
- summ += indicators[i] * coefficients[i];
- isPossibleToBuy = false;
- isPossibleToSell = false;
- if (summ < summToBuy)
- isPossibleToBuy = true;
- else if (summ > summToSell)
- isPossibleToSell = true;
- SetStopLossLinear();
- //--------------------------------------------------------
- //Проверка начала изменения тренда по индикаторам.
- //--------------------------------------------------------
- if(isPossibleToBuy)
- {
- int x = OrderClose(orderSell,LotValue,Ask,4,Blue);
- orderSellClose = true;
- }
- if(isPossibleToSell)
- {
- orderBuyClose = true;
- int x = OrderClose(orderBuy,LotValue,Bid,4,Red);
- }
- //--------------------------------------------------------------
- //Покупка и продажа, если возможно.
- //--------------------------------------------------------------
- if (isPossibleToBuy && (!OrderSelect(orderBuy, SELECT_BY_TICKET)||OrderCloseTime() != 0))
- {
- double pointsForLocalMin = (Ask - getMin(LosCounter)) * (1 + coefficientOfStopLossShift);
- double pointsForForGlobalMin = pointsForLos * Point;
- if (pointsForLocalMin < pointsForForGlobalMin)
- pointsForLocalMin = pointsForForGlobalMin;
- orderBuy = OrderSend(Symbol(),OP_BUY,LotValue,Ask,5,Ask - pointsForLocalMin,Bid + pointsForProfit*Point,NULL,228,0,Blue);
- orderBuyClose = false;
- isPossibleToBuy = false;
- return;
- }
- if (isPossibleToSell && (!OrderSelect(orderSell, SELECT_BY_TICKET)||OrderCloseTime() != 0))
- {
- double pointsForLocalMax = (getMax(LosCounter) - Bid) * (1 + coefficientOfStopLossShift);
- double pointsForForGlobalMax = pointsForLos * Point;
- if (pointsForLocalMax > pointsForForGlobalMax)
- pointsForLocalMax = pointsForForGlobalMax;
- orderSell = OrderSend(Symbol(),OP_SELL,LotValue,Bid,5,Bid + pointsForLocalMax,Ask - pointsForProfit*Point,NULL,228,0,Red);
- orderSellClose = false;
- isPossibleToSell = false;
- return;
- }
- }
- //+------------------------------------------------------------------+
- double getMin(int count)
- {
- double min = Low[1];
- for (int i = 1 ; i < count; i++)
- {
- if (Low[i]<min) min = Low[i];
- }
- return min;
- }
- double getMax(int count)
- {
- double max = High[1];
- for (int i = 1 ; i< count; i++)
- {
- if (High[i]>max) max = High[i];
- }
- return max;
- }
- void SetStopLossLinear()
- {
- double k = Point * linearPersent / 100.0;
- if(!orderBuyClose)
- {
- if (!OrderSelect(orderBuy, SELECT_BY_TICKET)) return;
- OrderSelect(orderBuy, SELECT_BY_TICKET);
- if ((Bid - pointsForLos * k > OrderOpenPrice())&&(Bid - pointsForLos * k > OrderStopLoss()))
- {
- bool x = OrderModify(orderBuy,
- OrderOpenPrice(),
- Bid - pointsForLos * k,
- OrderTakeProfit(),
- NULL);
- }
- }
- if(!orderSellClose)
- {
- if (!OrderSelect(orderSell, SELECT_BY_TICKET)) return;
- OrderSelect(orderSell, SELECT_BY_TICKET);
- if ((Ask + pointsForLos * k < OrderOpenPrice())&&(Ask + pointsForLos * k < OrderStopLoss()))
- {
- bool x = OrderModify(orderSell,
- OrderOpenPrice(),
- Ask + pointsForLos * k,
- OrderTakeProfit(),
- NULL);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement