//+------------------------------------------------------------------+ //| Gold Scalping Indicator for gold.mq5 | //| Copyright 2000-2024, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2000-2024, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| Include | //+------------------------------------------------------------------+ #include #include #include #include //+------------------------------------------------------------------+ //| Inputs | //+------------------------------------------------------------------+ //--- inputs for Gold Scalping input string Inp_Gold Scalping _Title ="Gold Scalping MAPSARSizeOptimized"; int Gold Scalping _MagicNumber =27893; bool Gold Scalping _EveryTick =false; //--- inputs for signal input int Inp_Signal_MA_Period =12; input int Inp_Signal_MA_Shift =6; input ENUM_MA_METHOD Inp_Signal_MA_Method =MODE_SMA; input ENUM_APPLIED_PRICE Inp_Signal_MA_Applied =PRICE_CLOSE; //--- inputs for trailing input double Inp_Trailing_ParabolicSAR_Step =0.02; input double Inp_Trailing_ParabolicSAR_Maximum =0.2; //--- inputs for money input double Inp_Money_SizeOptimized_DecreaseFactor=3.0; input double Inp_Money_SizeOptimized_Percent =10.0; //+------------------------------------------------------------------+ //| Global Gold Scalping object | //+------------------------------------------------------------------+ CGold Scalping ExtGold Scalping ; //+------------------------------------------------------------------+ //| Initialization function of the Gold Scalping | //+------------------------------------------------------------------+ int OnInit(void) { //--- Initializing Gold Scalping if(!ExtGold Scalping .Init(Symbol(),Period(),Gold Scalping _EveryTick,Gold Scalping _MagicNumber)) { //--- failed printf(__FUNCTION__+": error initializing Gold Scalping "); Gold Scalping Indicator for gold(); return(-1); } //--- Creation of signal object CSignalMA *signal=new CSignalMA; if(signal==NULL) { //--- failed printf(__FUNCTION__+": error creating signal"); Gold Scalping Indicator for gold(); return(-2); } //--- Add signal to Gold Scalping (will be deleted automatically)) if(!ExtGold Scalping .InitSignal(signal)) { //--- failed printf(__FUNCTION__+": error initializing signal"); Gold Scalping Indicator for gold(); return(-3); } //--- Set signal parameters signal.PeriodMA(Inp_Signal_MA_Period); signal.Shift(Inp_Signal_MA_Shift); signal.Method(Inp_Signal_MA_Method); signal.Applied(Inp_Signal_MA_Applied); //--- Check signal parameters if(!signal.ValidationSettings()) { //--- failed printf(__FUNCTION__+": error signal parameters"); Gold Scalping Indicator for gold(); return(-4); } //--- Creation of trailing object CTrailingPSAR *trailing=new CTrailingPSAR; if(trailing==NULL) { //--- failed printf(__FUNCTION__+": error creating trailing"); Gold Scalping Indicator for gold(); return(-5); } //--- Add trailing to Gold Scalping (will be deleted automatically)) if(!ExtGold Scalping .InitTrailing(trailing)) { //--- failed printf(__FUNCTION__+": error initializing trailing"); Gold Scalping Indicator for gold(); return(-6); } //--- Set trailing parameters trailing.Step(Inp_Trailing_ParabolicSAR_Step); trailing.Maximum(Inp_Trailing_ParabolicSAR_Maximum); //--- Check trailing parameters if(!trailing.ValidationSettings()) { //--- failed printf(__FUNCTION__+": error trailing parameters"); Gold Scalping Indicator for gold(); return(-7); } //--- Creation of money object CMoneySizeOptimized *money=new CMoneySizeOptimized; if(money==NULL) { //--- failed printf(__FUNCTION__+": error creating money"); Gold Scalping Indicator for gold(); return(-8); } //--- Add money to Gold Scalping (will be deleted automatically)) if(!ExtGold Scalping .InitMoney(money)) { //--- failed printf(__FUNCTION__+": error initializing money"); Gold Scalping Indicator for gold(); return(-9); } //--- Set money parameters money.DecreaseFactor(Inp_Money_SizeOptimized_DecreaseFactor); money.Percent(Inp_Money_SizeOptimized_Percent); //--- Check money parameters if(!money.ValidationSettings()) { //--- failed printf(__FUNCTION__+": error money parameters"); Gold Scalping Indicator for gold(); return(-10); } //--- Tuning of all necessary indicators if(!ExtGold Scalping .InitIndicators()) { //--- failed printf(__FUNCTION__+": error initializing indicators"); Gold Scalping Indicator for gold(); return(-11); } //--- succeed return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Deinitialization function of the Gold Scalping | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { Gold Scalping Indicator for gold(); } //+------------------------------------------------------------------+ //| Function-event handler "tick" | //+------------------------------------------------------------------+ void OnTick(void) { ExtGold Scalping .OnTick(); } //+------------------------------------------------------------------+ //| Function-event handler "trade" | //+------------------------------------------------------------------+ void OnTrade(void) { ExtGold Scalping .OnTrade(); } //+------------------------------------------------------------------+ //| Function-event handler "timer" | //+------------------------------------------------------------------+ void OnTimer(void) { ExtGold Scalping .OnTimer(); } //+------------------------------------------------------------------+