Hello
I want help to optimize a Bool type expression 0 False 1True and i want also skip the expression too for example
if ( bool type 1 == True && bool type 2 == True && bool type 3 == False .................................. )
{
Bullish = false;
Bearish = true;
}
i made Int constants for True and False values to optimize them but it take only True (1) and False (0) but how to skip the bool type for example bool type 2 in optimization process not only give it a true or false values , i want in optimization the int value 1 true and 0 false and if i put another number for example 2 to skip that bool
Thank you in advance
Jaber
You should always use the "SRC" button when you post the code, it more professional. Try this:
bool type_1, type_2, type_3; bool Bearish = type_1 && type_2 && !type_3; bool Bullish = !Bearish;
You should always use the "SRC" button when you post the code, it more professional. Try this:
I want to know how to skip the bool expression in optimization of my EA not only True or False values
bool type_1, type_3; int type_2; bool bBearish, bBullish; bool bOptimization = MQLInfoInteger(MQL_OPTIMIZATION); bBearish = type_1 && (type_2 == 1 || (type_2 && bOptimization)) && !type_3; bBulish = !Bearish;
OK here is the full EA code
I want to Run Strategy Tester and optimize the values of Boolean type on my EA to find the optimum combination of variables , but these bool types can have True or False only but its very important to also skip them
in the Optimization process as well to let Strategy Tester find optimum values, and also i want to know how not to test other bool types if the bigger bool type is True to save the time
for example ( iind44 > iind4 > iind3 > iind2 > iind11 > iind1 ) if i ind44 no need to test lower bool values iind4 or iind3 or iind2 or iind1 and so on .
//+------------------------------------------------------------------+
//| JaberShortD.mq4 |
//| Copyright 2015, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//--- input parameters
input int Lots=1;
input int SLIPPAGE=2;
input int Magic=3115;
input int timeframe=0;
input int Dem_Period=7;
input int MFI_Period=7;
input int RSI_Period=7;
input int WPR_Period=7;
input int Force_Period=7;
input int stc_Kperiod=5;
input int stc_Dperiod=3;
input int stc_Slowing=3;
//++++++++++++++++++++++++ bolls +++++++++++++++++++++++
//_________________________ ( iind44 > iind4 > iind3 > iind2 > iind11 > iind1 )
input int iind1=0;
input int iind11=0;
input int iind2=0;
input int iind3=0;
input int iind4=1;
input int iind44=0;
//_________________________ ( ishfind44 > isind44 ) & (iind4 or iind44) > ( ishfind44 or isind44 )
input int isind44=0;
input int ishfind44=0;
//_________________________ ( idind4 > idind3 > idind2 > idind1 )
input int idind1=1;
input int idind2=0;
input int idind3=0;
input int idind4=0;
//_________________________ ( ist4 > ist3 > ist2 > ist1 )
input int ist1=0;
input int ist2=0;
input int ist3=0;
input int ist4=0;
//_________________________
input int if0=0;
//++++++++++++++++++++++++ bolls z +++++++++++++++++++++++
//_________________________ ( iind44z > iind4z > iind3z > iind2z > iind11z > iind1z )
input int iind1z=0;
input int iind11z=0;
input int iind2z=0;
input int iind3z=0;
input int iind4z=0;
input int iind44z=0;
//_________________________ ( ishfind44z > isind44z ) & (iind4z or iind44z) > ( ishfind44z or isind44z )
input int isind44z=0;
input int ishfind44z=0;
//_________________________ ( idind4z > idind3z > idind2z > idind1z )
input int idind1z=0;
input int idind2z=0;
input int idind3z=0;
input int idind4z=0;
//_________________________ ( ist4z > ist3z > ist2z > ist1z )
input int ist1z=0;
input int ist2z=0;
input int ist3z=0;
input int ist4z=0;
//_________________________
input int if0z=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
// Global variables
// Common
int LastBars = 0;
bool HaveLongPosition;
bool HaveShortPosition;
//+------------------------------------------------------------------+
//| Initialization |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Deinitialization |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Each tick |
//+------------------------------------------------------------------+
int start()
{
if ((!IsTradeAllowed()) || (IsTradeContextBusy()) || (!IsConnected()) || ((!MarketInfo(Symbol(), MODE_TRADEALLOWED))
&& (!IsTesting()))) return(0);
// Trade only if new bar has arrived
if (LastBars!= Bars) LastBars = Bars;
else return(0);
//Do we have enough bars to work with
if(Bars<60)
{
Print("bars less than 60");
return(0);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Signals
bool Bullish = false;
bool Bearish = false;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Indicators
//Get Handle for DEM Indicator
double Dm_1=iDeMarker(NULL,timeframe,Dem_Period,1);
double Dm_2=iDeMarker(NULL,timeframe,Dem_Period,2);
double Dm_3=iDeMarker(NULL,timeframe,Dem_Period,3);
double Dm_4=iDeMarker(NULL,timeframe,Dem_Period,4);
double Dm_5=iDeMarker(NULL,timeframe,Dem_Period,5);
double Dm_6=iDeMarker(NULL,timeframe,Dem_Period,6);
double Dm_7=iDeMarker(NULL,timeframe,Dem_Period,7);
//Get Handle for MFI indicator
double mfi_1=iMFI(NULL,timeframe,MFI_Period,1);
double mfi_2=iMFI(NULL,timeframe,MFI_Period,2);
double mfi_3=iMFI(NULL,timeframe,MFI_Period,3);
double mfi_4=iMFI(NULL,timeframe,MFI_Period,4);
double mfi_5=iMFI(NULL,timeframe,MFI_Period,5);
double mfi_6=iMFI(NULL,timeframe,MFI_Period,6);
double mfi_7=iMFI(NULL,timeframe,MFI_Period,7);
//Get Handle for RSI Indicator
double rsi_1=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,1);
double rsi_2=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,2);
double rsi_3=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,3);
double rsi_4=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,4);
double rsi_5=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,5);
double rsi_6=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,6);
double rsi_7=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,7);
//Get Handle for WPR indicator
double wpr_1=iWPR(NULL,timeframe,WPR_Period,1);
double wpr_2=iWPR(NULL,timeframe,WPR_Period,2);
double wpr_3=iWPR(NULL,timeframe,WPR_Period,3);
double wpr_4=iWPR(NULL,timeframe,WPR_Period,4);
double wpr_5=iWPR(NULL,timeframe,WPR_Period,5);
double wpr_6=iWPR(NULL,timeframe,WPR_Period,6);
double wpr_7=iWPR(NULL,timeframe,WPR_Period,7);
//Get Handle for Force indicator
double f_1=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,1);
double f_2=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,2);
double f_3=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,3);
double f_4=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,4);
double f_5=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,5);
double f_6=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,6);
double f_7=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,7);
//Get Handle for Stochastic Main indicator
double stm_1=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,1);
double stm_2=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,2);
double stm_3=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,3);
double stm_4=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,4);
double stm_5=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,5);
double stm_6=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,6);
double stm_7=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,7);
//Get Handle for Stochastic Signal indicator
double sts_1=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,1);
double sts_2=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,2);
double sts_3=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,3);
double sts_4=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,4);
double sts_5=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,5);
double sts_6=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,6);
double sts_7=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,7);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// REVERSED!!! ((bool difintions))
//********************************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//----------------------------------------------------------------------------iind1-----------------------------------------------------
bool indu1= ( (Dm_1>=0.7)||(mfi_1>=80)||(rsi_1>=70)||(wpr_1>=-20)||(Dm_2>=0.7)||(mfi_2>=80)||(rsi_2>=70)||(wpr_2>=-20) );
bool indd1= ( (Dm_1<=0.3)||(mfi_1<=20)||(rsi_1<=30)||(wpr_1<=-80)||(Dm_2<=0.3)||(mfi_2<=20)||(rsi_2<=30)||(wpr_2<=-80) );
//----------------------------------------------------------------------------iind11-----------------------------------------------------
bool indu11= ( (Dm_1>=0.7)||(mfi_1>=80)||(rsi_1>=70)||(wpr_1>=-20) );
bool indd11= ( (Dm_1<=0.3)||(mfi_1<=20)||(rsi_1<=30)||(wpr_1<=-80) );
//-----------------------------------------------------------------------------iind2----------------------------------------------------
bool indu2= ( ( ((mfi_1>= 80)||(mfi_2>= 80)) && ((rsi_1>= 70)||(rsi_2>= 70)) )
|| ( ((wpr_1>=-20)||(wpr_2>=-20)) && ((rsi_1>= 70)||(rsi_2>= 70)) )
|| ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((rsi_1>= 70)||(rsi_2>= 70)) )
|| ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((mfi_1>= 80)||(mfi_2>= 80)) )
|| ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((wpr_1>=-20)||(wpr_2>=-20)) )
|| ( ((mfi_1>= 80)||(mfi_2>= 80)) && ((wpr_1>=-20)||(wpr_2>=-20)) ) );
bool indd2= ( ( ((mfi_1<= 20)||(mfi_2<= 20)) && ((rsi_1<= 30)||(rsi_2<= 30)) )
|| ( ((wpr_1<=-80)||(wpr_2<=-80)) && ((rsi_1<= 30)||(rsi_2<= 30)) )
|| ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((rsi_1<= 30)||(rsi_2<= 30)) )
|| ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((mfi_1<= 20)||(mfi_2<= 20)) )
|| ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((wpr_1<=-80)||(wpr_2<=-80)) )
|| ( ((mfi_1<= 20)||(mfi_2<= 20)) && ((wpr_1<=-80)||(wpr_2<=-80)) ) );
//------------------------------------------------------------------------------iind3---------------------------------------------------
bool indu3= ( ( ((mfi_1>=80)||(mfi_2>=80)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) )
|| ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) )
|| ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((mfi_1>=80)||(mfi_2>=80)) && ((wpr_1>=-20)||(wpr_2>=-20)) )
|| ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((rsi_1>=70)||(rsi_2>=70)) && ((mfi_1>= 80)||(mfi_2>= 80)) ) );
bool indd3= ( ( ((mfi_1<=20)||(mfi_2<=20)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) )
|| ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) )
|| ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((mfi_1<=20)||(mfi_2<=20)) && ((wpr_1<=-80)||(wpr_2<=-80)) )
|| ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((rsi_1<=30)||(rsi_2<=30)) && ((mfi_1<= 20)||(mfi_2<= 20)) ) );
//------------------------------------------------------------------------------iind4---------------------------------------------------
bool indu4= ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((mfi_1>=80)||(mfi_2>=80)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) );
bool indd4= ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((mfi_1<=20)||(mfi_2<=20)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) );
//------------------------------------------------------------------------------iind44---------------------------------------------------
bool indu44= ( (Dm_1>=0.7)&&(mfi_1>=80)&&(rsi_1>=70)&&(wpr_1>=-20) );
bool indd44= ( (Dm_1<=0.3)&&(mfi_1<=20)&&(rsi_1<=30)&&(wpr_1<=-80) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//-------------------------------------------------------------------------------isind44--------------------------------------------------
bool slindu44= ( (Dm_1>=0.3)&&(mfi_1>=20)&&(rsi_1>=30)&&(wpr_1>=-80) );
bool slindd44= ( (Dm_1<=0.7)&&(mfi_1<=80)&&(rsi_1<=70)&&(wpr_1<=-20) );
//-------------------------------------------------------------------------------ishfind44-------------------------------------------------
bool shfindu44= ( (Dm_1>=0.5)&&(mfi_1>=50)&&(rsi_1>=50)&&(wpr_1>=-50) );
bool shfindd44= ( (Dm_1<=0.5)&&(mfi_1<=50)&&(rsi_1<=50)&&(wpr_1<=-50) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//--------------------------------------------------------------------------------i2ind44-------------------------------------------------
bool ind2u44= ( (Dm_2>=0.7)&&(mfi_2>=80)&&(rsi_2>=70)&&(wpr_2>=-20) );
bool ind2d44= ( (Dm_2<=0.3)&&(mfi_2<=20)&&(rsi_2<=30)&&(wpr_2<=-80) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//----------------------------------------------------------------------------------------idind1---------------------------------------------
bool dindu1= ( (wpr_1<=wpr_2) || (Dm_1<=Dm_2) || ( mfi_1<=mfi_2) || ( rsi_1<=rsi_2) || (f_1<=f_2) );
bool dindd1= ( (wpr_1>=wpr_2) || (Dm_1>=Dm_2) || ( mfi_1>=mfi_2) || ( rsi_1>=rsi_2) || (f_1>=f_2) );
//----------------------------------------------------------------------------------------idind2---------------------------------------------
bool dindu2= ( ((Dm_1 <= Dm_2) && (f_1 <= f_2)) || ((rsi_1<=rsi_2) && (wpr_1<=wpr_2))
|| ((Dm_1 <= Dm_2) && (rsi_1<=rsi_2)) || ((rsi_1<=rsi_2) && (mfi_1<=mfi_2))
|| ((Dm_1 <= Dm_2) && (mfi_1<=mfi_2)) || ((wpr_1<=wpr_2) && (mfi_1<=mfi_2))
|| ((Dm_1 <= Dm_2) && (wpr_1<=wpr_2)) || ((f_1 <= f_2) && (rsi_1<=rsi_2))
|| ((f_1 <= f_2) && (wpr_1<=wpr_2)) || ((f_1 <= f_2) && (mfi_1<=mfi_2)) );
bool dindd2= ( ((Dm_1 >= Dm_2) && (f_1 >= f_2)) || ((rsi_1>=rsi_2) && (wpr_1>=wpr_2))
|| ((Dm_1 >= Dm_2) && (rsi_1>=rsi_2)) || ((rsi_1>=rsi_2) && (mfi_1>=mfi_2))
|| ((Dm_1 >= Dm_2) && (mfi_1>=mfi_2)) || ((wpr_1>=wpr_2) && (mfi_1>=mfi_2))
|| ((Dm_1 >= Dm_2) && (wpr_1>=wpr_2)) || ((f_1 >= f_2) && (rsi_1>=rsi_2))
|| ((f_1 >= f_2) && (wpr_1>=wpr_2)) || ((f_1 >= f_2) && (mfi_1>=mfi_2)) );
//----------------------------------------------------------------------------------------idind3-----------------------------------------
bool dindu3= ( ((mfi_1<=mfi_2) && (rsi_1<=rsi_2) && (wpr_1<=wpr_2)) || ((Dm_1 <= Dm_2) && (rsi_1<=rsi_2) && (mfi_1<=mfi_2))
|| ((Dm_1 <= Dm_2) && (rsi_1<=rsi_2) && (wpr_1<=wpr_2)) || ((Dm_1 <= Dm_2) && (mfi_1<=mfi_2) && (wpr_1<=wpr_2))
|| ((f_1 <= f_2) && (rsi_1<=rsi_2) && (wpr_1<=wpr_2)) || ((f_1 <= f_2) && (Dm_1 <= Dm_2) && (wpr_1<=wpr_2))
|| ((f_1 <= f_2) && (rsi_1<=rsi_2) && (mfi_1<=mfi_2)) || ((f_1 <= f_2) && (Dm_1 <= Dm_2) && (mfi_1<=mfi_2))
|| ((f_1 <= f_2) && (rsi_1<=rsi_2) && (Dm_1 <= Dm_2)) || ((f_1 <= f_2) && (mfi_1<=mfi_2) && (wpr_1<=wpr_2)) );
bool dindd3= ( ((mfi_1>=mfi_2) && (rsi_1>=rsi_2) && (wpr_1>=wpr_2)) || ((Dm_1 >= Dm_2) && (rsi_1>=rsi_2) && (mfi_1>=mfi_2))
|| ((Dm_1 >= Dm_2) && (rsi_1>=rsi_2) && (wpr_1>=wpr_2)) || ((Dm_1 >= Dm_2) && (mfi_1>=mfi_2) && (wpr_1>=wpr_2))
|| ((f_1 >= f_2) && (rsi_1>=rsi_2) && (wpr_1>=wpr_2)) || ((f_1 >= f_2) && (Dm_1 >= Dm_2) && (wpr_1>=wpr_2))
|| ((f_1 >= f_2) && (rsi_1>=rsi_2) && (mfi_1>=mfi_2)) || ((f_1 >= f_2) && (Dm_1 >= Dm_2) && (mfi_1>=mfi_2))
|| ((f_1 >= f_2) && (rsi_1>=rsi_2) && (Dm_1 >= Dm_2)) || ((f_1 >= f_2) && (mfi_1>=mfi_2) && (wpr_1>=wpr_2)) );
//----------------------------------------------------------------------------------------idind4-----------------------------------------
bool dindu4= ( (wpr_1<=wpr_2) && (Dm_1<=Dm_2) && ( mfi_1<=mfi_2) && ( rsi_1<=rsi_2) && (f_1<=f_2) );
bool dindd4= ( (wpr_1>=wpr_2) && (Dm_1>=Dm_2) && ( mfi_1>=mfi_2) && ( rsi_1>=rsi_2) && (f_1>=f_2) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//------------------------------------------------------------------------------------------ist1---------------------------------------
bool stu1= (stm_1>sts_1);
bool std1= (stm_1<sts_1);
//------------------------------------------------------------------------------------------ist2---------------------------------------
bool stu2= ( (stm_1>sts_1) && (stm_2>sts_2));
bool std2= ( (stm_1<sts_1) && (stm_2<sts_2) );
//------------------------------------------------------------------------------------------ist3---------------------------------------
bool stu3= ( (stm_1>sts_1) && (stm_2>sts_2) && ((stm_1-sts_1)>(stm_2-sts_2)) );
bool std3= ( (stm_1<sts_1) && (stm_2<sts_2) && ((sts_1-stm_1)>(sts_2-stm_2)) );
//------------------------------------------------------------------------------------------ist4---------------------------------------
bool stu4= ( (stm_1>sts_1) && (stm_2>sts_2) && ((stm_1-sts_1)>(stm_2-sts_2)) && (sts_1<20) );
bool std4= ( (stm_1<sts_1) && (stm_2<sts_2) && ((sts_1-stm_1)>(sts_2-stm_2)) && (sts_1>80) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//-----------------------------------------------------------------------------------------if0----------------------------------------
bool fu= (f_1<0);
bool fd= (f_1>0);
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// REVERSED!!
{
//sell signal
if
// 6 =================== sell =======================================================================================
( indu1== iind1 && indd1== iind1z && indu11== iind11 && indd11== iind11z && indu2== iind2 && indd2== iind2z
&& indu3== iind3 && indd3== iind3z && indu4== iind4 && indd4== iind4z && indu44== iind44 && indd44== iind44z
&& slindu44== isind44 && slindd44== isind44z && shfindu44== ishfind44 && shfindd44== ishfind44z
&& dindu1== idind1 && dindd1== idind1z && dindu2== idind2 && dindd2== idind2z && dindu3== idind3 && dindd3== idind3z
&& dindu4== idind4 && dindd4== idind4z
&& stu1== ist1 && std1== ist1z && stu2== ist2 && std2== ist2z && stu3== ist3 && std3== ist3z && stu4== ist4 && std4== ist4z
&& fu== if0 && fd== if0z )
// ------------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
{
Bullish = false;
Bearish = true;
}
//******************************************************************************************************************************** //buy signal
else if
// 1 =====================buy================================================================================
( indu1== iind1z && indd1== iind1 && indu11== iind11z && indd11== iind11 && indu2== iind2z && indd2== iind2
&& indu3== iind3z && indd3== iind3 && indu4== iind4z && indd4== iind4 && indu44== iind44z && indd44== iind44
&& slindu44== isind44z && slindd44== isind44 && shfindu44== ishfind44z && shfindd44== ishfind44
&& dindu1== idind1z && dindd1== idind1 && dindu2== idind2z && dindd2== idind2 && dindu3== idind3z && dindd3== idind3
&& dindu4== idind4z && dindd4== idind4
&& stu1== ist1z && std1== ist1 && stu2== ist2z && std2== ist2 && stu3== ist3z && std3== ist3 && stu4== ist4z && std4== ist4
&& fu== if0z && fd== if0 )
{
Bullish = true;
Bearish = false;
}
else
{
Bullish = false;
Bearish = false;
}
}
//**********************************************************************************************************************
//**********************************************************************************************************************
GetPositionStates();
if ((HaveShortPosition) && (Bullish)) ClosePrevious();
if ((HaveLongPosition) && (Bearish)) ClosePrevious();
if (Bullish)
{
if (!HaveLongPosition) fBuy();
}
else if (Bearish)
{
if (!HaveShortPosition) fSell();
}
return(0);
}
//+------------------------------------------------------------------+
//| Check what position is currently open |
//+------------------------------------------------------------------+
void GetPositionStates()
{
int total = OrdersTotal();
for (int cnt = 0; cnt < total; cnt++)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) == false) continue;
if (OrderMagicNumber() != Magic) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderType() == OP_BUY)
{
HaveLongPosition = true;
HaveShortPosition = false;
// double BOP=OrderOpenPrice();
return;
}
else if (OrderType() == OP_SELL)
{
HaveLongPosition = false;
HaveShortPosition = true;
return;
}
}
HaveLongPosition = false;
HaveShortPosition = false;
}
//+------------------------------------------------------------------+
//| Buy |
//+------------------------------------------------------------------+
void fBuy()
{
RefreshRates();
int result = OrderSend(Symbol(),OP_BUY,Lots,Ask,SLIPPAGE,0,0,"Jaber5",Magic,0,Blue);
if (result == -1)
{
int e = GetLastError();
Print("OrderSend Error: ", e);
}
}
//+------------------------------------------------------------------+
//| Sell |
//+------------------------------------------------------------------+
void fSell()
{
RefreshRates();
int result = OrderSend(Symbol(),OP_SELL,Lots,Bid,SLIPPAGE,0,0,"Jaber5",Magic,0,Green);
if (result == -1)
{
int e = GetLastError();
Print("OrderSend Error: ", e);
}
}
//+------------------------------------------------------------------+
//| Close previous position |
//+------------------------------------------------------------------+
void ClosePrevious()
{
int total = OrdersTotal();
for (int i = 0; i < total; i++)
{
if (OrderSelect(i, SELECT_BY_POS) == false) continue;
if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == Magic))
{
if (OrderType() == OP_BUY)
{
RefreshRates();
OrderClose(OrderTicket(),OrderLots(),Bid,SLIPPAGE,Violet);
}
else if (OrderType() == OP_SELL)
{
RefreshRates();
OrderClose(OrderTicket(),OrderLots(),Ask,SLIPPAGE,Red);
}
}
}
}

- www.mql5.com
OK here is the full EA code
I want to Run Strategy Tester and optimize the values of Boolean type on my EA to find the optimum combination of variables , but these bool types can have True or False only but its very important to also skip them
in the Optimization process as well to let Strategy Tester find optimum values, and also i want to know how not to test other bool types if the bigger bool type is True to save the time
for example ( iind44 > iind4 > iind3 > iind2 > iind11 > iind1 ) if i ind44 no need to test lower bool values iind4 or iind3 or iind2 or iind1 and so on .
//+------------------------------------------------------------------+
//| JaberShortD.mq4 |
//| Copyright 2015, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//--- input parameters
input int Lots=1;
input int SLIPPAGE=2;
input int Magic=3115;
input int timeframe=0;
input int Dem_Period=7;
input int MFI_Period=7;
input int RSI_Period=7;
input int WPR_Period=7;
input int Force_Period=7;
input int stc_Kperiod=5;
input int stc_Dperiod=3;
input int stc_Slowing=3;
//++++++++++++++++++++++++ bolls +++++++++++++++++++++++
//_________________________ ( iind44 > iind4 > iind3 > iind2 > iind11 > iind1 )
input int iind1=0;
input int iind11=0;
input int iind2=0;
input int iind3=0;
input int iind4=1;
input int iind44=0;
//_________________________ ( ishfind44 > isind44 ) & (iind4 or iind44) > ( ishfind44 or isind44 )
input int isind44=0;
input int ishfind44=0;
//_________________________ ( idind4 > idind3 > idind2 > idind1 )
input int idind1=1;
input int idind2=0;
input int idind3=0;
input int idind4=0;
//_________________________ ( ist4 > ist3 > ist2 > ist1 )
input int ist1=0;
input int ist2=0;
input int ist3=0;
input int ist4=0;
//_________________________
input int if0=0;
//++++++++++++++++++++++++ bolls z +++++++++++++++++++++++
//_________________________ ( iind44z > iind4z > iind3z > iind2z > iind11z > iind1z )
input int iind1z=0;
input int iind11z=0;
input int iind2z=0;
input int iind3z=0;
input int iind4z=0;
input int iind44z=0;
//_________________________ ( ishfind44z > isind44z ) & (iind4z or iind44z) > ( ishfind44z or isind44z )
input int isind44z=0;
input int ishfind44z=0;
//_________________________ ( idind4z > idind3z > idind2z > idind1z )
input int idind1z=0;
input int idind2z=0;
input int idind3z=0;
input int idind4z=0;
//_________________________ ( ist4z > ist3z > ist2z > ist1z )
input int ist1z=0;
input int ist2z=0;
input int ist3z=0;
input int ist4z=0;
//_________________________
input int if0z=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
// Global variables
// Common
int LastBars = 0;
bool HaveLongPosition;
bool HaveShortPosition;
//+------------------------------------------------------------------+
//| Initialization |
//+------------------------------------------------------------------+
int init()
{
return(0);
}
//+------------------------------------------------------------------+
//| Deinitialization |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Each tick |
//+------------------------------------------------------------------+
int start()
{
if ((!IsTradeAllowed()) || (IsTradeContextBusy()) || (!IsConnected()) || ((!MarketInfo(Symbol(), MODE_TRADEALLOWED))
&& (!IsTesting()))) return(0);
// Trade only if new bar has arrived
if (LastBars!= Bars) LastBars = Bars;
else return(0);
//Do we have enough bars to work with
if(Bars<60)
{
Print("bars less than 60");
return(0);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Signals
bool Bullish = false;
bool Bearish = false;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Indicators
//Get Handle for DEM Indicator
double Dm_1=iDeMarker(NULL,timeframe,Dem_Period,1);
double Dm_2=iDeMarker(NULL,timeframe,Dem_Period,2);
double Dm_3=iDeMarker(NULL,timeframe,Dem_Period,3);
double Dm_4=iDeMarker(NULL,timeframe,Dem_Period,4);
double Dm_5=iDeMarker(NULL,timeframe,Dem_Period,5);
double Dm_6=iDeMarker(NULL,timeframe,Dem_Period,6);
double Dm_7=iDeMarker(NULL,timeframe,Dem_Period,7);
//Get Handle for MFI indicator
double mfi_1=iMFI(NULL,timeframe,MFI_Period,1);
double mfi_2=iMFI(NULL,timeframe,MFI_Period,2);
double mfi_3=iMFI(NULL,timeframe,MFI_Period,3);
double mfi_4=iMFI(NULL,timeframe,MFI_Period,4);
double mfi_5=iMFI(NULL,timeframe,MFI_Period,5);
double mfi_6=iMFI(NULL,timeframe,MFI_Period,6);
double mfi_7=iMFI(NULL,timeframe,MFI_Period,7);
//Get Handle for RSI Indicator
double rsi_1=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,1);
double rsi_2=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,2);
double rsi_3=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,3);
double rsi_4=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,4);
double rsi_5=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,5);
double rsi_6=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,6);
double rsi_7=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,7);
//Get Handle for WPR indicator
double wpr_1=iWPR(NULL,timeframe,WPR_Period,1);
double wpr_2=iWPR(NULL,timeframe,WPR_Period,2);
double wpr_3=iWPR(NULL,timeframe,WPR_Period,3);
double wpr_4=iWPR(NULL,timeframe,WPR_Period,4);
double wpr_5=iWPR(NULL,timeframe,WPR_Period,5);
double wpr_6=iWPR(NULL,timeframe,WPR_Period,6);
double wpr_7=iWPR(NULL,timeframe,WPR_Period,7);
//Get Handle for Force indicator
double f_1=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,1);
double f_2=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,2);
double f_3=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,3);
double f_4=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,4);
double f_5=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,5);
double f_6=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,6);
double f_7=iForce(NULL,timeframe,Force_Period,MODE_SMA,PRICE_CLOSE,7);
//Get Handle for Stochastic Main indicator
double stm_1=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,1);
double stm_2=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,2);
double stm_3=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,3);
double stm_4=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,4);
double stm_5=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,5);
double stm_6=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,6);
double stm_7=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,7);
//Get Handle for Stochastic Signal indicator
double sts_1=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,1);
double sts_2=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,2);
double sts_3=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,3);
double sts_4=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,4);
double sts_5=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,5);
double sts_6=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,6);
double sts_7=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,7);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// REVERSED!!! ((bool difintions))
//********************************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//----------------------------------------------------------------------------iind1-----------------------------------------------------
bool indu1= ( (Dm_1>=0.7)||(mfi_1>=80)||(rsi_1>=70)||(wpr_1>=-20)||(Dm_2>=0.7)||(mfi_2>=80)||(rsi_2>=70)||(wpr_2>=-20) );
bool indd1= ( (Dm_1<=0.3)||(mfi_1<=20)||(rsi_1<=30)||(wpr_1<=-80)||(Dm_2<=0.3)||(mfi_2<=20)||(rsi_2<=30)||(wpr_2<=-80) );
//----------------------------------------------------------------------------iind11-----------------------------------------------------
bool indu11= ( (Dm_1>=0.7)||(mfi_1>=80)||(rsi_1>=70)||(wpr_1>=-20) );
bool indd11= ( (Dm_1<=0.3)||(mfi_1<=20)||(rsi_1<=30)||(wpr_1<=-80) );
//-----------------------------------------------------------------------------iind2----------------------------------------------------
bool indu2= ( ( ((mfi_1>= 80)||(mfi_2>= 80)) && ((rsi_1>= 70)||(rsi_2>= 70)) )
|| ( ((wpr_1>=-20)||(wpr_2>=-20)) && ((rsi_1>= 70)||(rsi_2>= 70)) )
|| ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((rsi_1>= 70)||(rsi_2>= 70)) )
|| ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((mfi_1>= 80)||(mfi_2>= 80)) )
|| ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((wpr_1>=-20)||(wpr_2>=-20)) )
|| ( ((mfi_1>= 80)||(mfi_2>= 80)) && ((wpr_1>=-20)||(wpr_2>=-20)) ) );
bool indd2= ( ( ((mfi_1<= 20)||(mfi_2<= 20)) && ((rsi_1<= 30)||(rsi_2<= 30)) )
|| ( ((wpr_1<=-80)||(wpr_2<=-80)) && ((rsi_1<= 30)||(rsi_2<= 30)) )
|| ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((rsi_1<= 30)||(rsi_2<= 30)) )
|| ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((mfi_1<= 20)||(mfi_2<= 20)) )
|| ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((wpr_1<=-80)||(wpr_2<=-80)) )
|| ( ((mfi_1<= 20)||(mfi_2<= 20)) && ((wpr_1<=-80)||(wpr_2<=-80)) ) );
//------------------------------------------------------------------------------iind3---------------------------------------------------
bool indu3= ( ( ((mfi_1>=80)||(mfi_2>=80)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) )
|| ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) )
|| ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((mfi_1>=80)||(mfi_2>=80)) && ((wpr_1>=-20)||(wpr_2>=-20)) )
|| ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((rsi_1>=70)||(rsi_2>=70)) && ((mfi_1>= 80)||(mfi_2>= 80)) ) );
bool indd3= ( ( ((mfi_1<=20)||(mfi_2<=20)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) )
|| ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) )
|| ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((mfi_1<=20)||(mfi_2<=20)) && ((wpr_1<=-80)||(wpr_2<=-80)) )
|| ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((rsi_1<=30)||(rsi_2<=30)) && ((mfi_1<= 20)||(mfi_2<= 20)) ) );
//------------------------------------------------------------------------------iind4---------------------------------------------------
bool indu4= ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((mfi_1>=80)||(mfi_2>=80)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) );
bool indd4= ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((mfi_1<=20)||(mfi_2<=20)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) );
//------------------------------------------------------------------------------iind44---------------------------------------------------
bool indu44= ( (Dm_1>=0.7)&&(mfi_1>=80)&&(rsi_1>=70)&&(wpr_1>=-20) );
bool indd44= ( (Dm_1<=0.3)&&(mfi_1<=20)&&(rsi_1<=30)&&(wpr_1<=-80) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//-------------------------------------------------------------------------------isind44--------------------------------------------------
bool slindu44= ( (Dm_1>=0.3)&&(mfi_1>=20)&&(rsi_1>=30)&&(wpr_1>=-80) );
bool slindd44= ( (Dm_1<=0.7)&&(mfi_1<=80)&&(rsi_1<=70)&&(wpr_1<=-20) );
//-------------------------------------------------------------------------------ishfind44-------------------------------------------------
bool shfindu44= ( (Dm_1>=0.5)&&(mfi_1>=50)&&(rsi_1>=50)&&(wpr_1>=-50) );
bool shfindd44= ( (Dm_1<=0.5)&&(mfi_1<=50)&&(rsi_1<=50)&&(wpr_1<=-50) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//--------------------------------------------------------------------------------i2ind44-------------------------------------------------
bool ind2u44= ( (Dm_2>=0.7)&&(mfi_2>=80)&&(rsi_2>=70)&&(wpr_2>=-20) );
bool ind2d44= ( (Dm_2<=0.3)&&(mfi_2<=20)&&(rsi_2<=30)&&(wpr_2<=-80) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//----------------------------------------------------------------------------------------idind1---------------------------------------------
bool dindu1= ( (wpr_1<=wpr_2) || (Dm_1<=Dm_2) || ( mfi_1<=mfi_2) || ( rsi_1<=rsi_2) || (f_1<=f_2) );
bool dindd1= ( (wpr_1>=wpr_2) || (Dm_1>=Dm_2) || ( mfi_1>=mfi_2) || ( rsi_1>=rsi_2) || (f_1>=f_2) );
//----------------------------------------------------------------------------------------idind2---------------------------------------------
bool dindu2= ( ((Dm_1 <= Dm_2) && (f_1 <= f_2)) || ((rsi_1<=rsi_2) && (wpr_1<=wpr_2))
|| ((Dm_1 <= Dm_2) && (rsi_1<=rsi_2)) || ((rsi_1<=rsi_2) && (mfi_1<=mfi_2))
|| ((Dm_1 <= Dm_2) && (mfi_1<=mfi_2)) || ((wpr_1<=wpr_2) && (mfi_1<=mfi_2))
|| ((Dm_1 <= Dm_2) && (wpr_1<=wpr_2)) || ((f_1 <= f_2) && (rsi_1<=rsi_2))
|| ((f_1 <= f_2) && (wpr_1<=wpr_2)) || ((f_1 <= f_2) && (mfi_1<=mfi_2)) );
bool dindd2= ( ((Dm_1 >= Dm_2) && (f_1 >= f_2)) || ((rsi_1>=rsi_2) && (wpr_1>=wpr_2))
|| ((Dm_1 >= Dm_2) && (rsi_1>=rsi_2)) || ((rsi_1>=rsi_2) && (mfi_1>=mfi_2))
|| ((Dm_1 >= Dm_2) && (mfi_1>=mfi_2)) || ((wpr_1>=wpr_2) && (mfi_1>=mfi_2))
|| ((Dm_1 >= Dm_2) && (wpr_1>=wpr_2)) || ((f_1 >= f_2) && (rsi_1>=rsi_2))
|| ((f_1 >= f_2) && (wpr_1>=wpr_2)) || ((f_1 >= f_2) && (mfi_1>=mfi_2)) );
//----------------------------------------------------------------------------------------idind3-----------------------------------------
bool dindu3= ( ((mfi_1<=mfi_2) && (rsi_1<=rsi_2) && (wpr_1<=wpr_2)) || ((Dm_1 <= Dm_2) && (rsi_1<=rsi_2) && (mfi_1<=mfi_2))
|| ((Dm_1 <= Dm_2) && (rsi_1<=rsi_2) && (wpr_1<=wpr_2)) || ((Dm_1 <= Dm_2) && (mfi_1<=mfi_2) && (wpr_1<=wpr_2))
|| ((f_1 <= f_2) && (rsi_1<=rsi_2) && (wpr_1<=wpr_2)) || ((f_1 <= f_2) && (Dm_1 <= Dm_2) && (wpr_1<=wpr_2))
|| ((f_1 <= f_2) && (rsi_1<=rsi_2) && (mfi_1<=mfi_2)) || ((f_1 <= f_2) && (Dm_1 <= Dm_2) && (mfi_1<=mfi_2))
|| ((f_1 <= f_2) && (rsi_1<=rsi_2) && (Dm_1 <= Dm_2)) || ((f_1 <= f_2) && (mfi_1<=mfi_2) && (wpr_1<=wpr_2)) );
bool dindd3= ( ((mfi_1>=mfi_2) && (rsi_1>=rsi_2) && (wpr_1>=wpr_2)) || ((Dm_1 >= Dm_2) && (rsi_1>=rsi_2) && (mfi_1>=mfi_2))
|| ((Dm_1 >= Dm_2) && (rsi_1>=rsi_2) && (wpr_1>=wpr_2)) || ((Dm_1 >= Dm_2) && (mfi_1>=mfi_2) && (wpr_1>=wpr_2))
|| ((f_1 >= f_2) && (rsi_1>=rsi_2) && (wpr_1>=wpr_2)) || ((f_1 >= f_2) && (Dm_1 >= Dm_2) && (wpr_1>=wpr_2))
|| ((f_1 >= f_2) && (rsi_1>=rsi_2) && (mfi_1>=mfi_2)) || ((f_1 >= f_2) && (Dm_1 >= Dm_2) && (mfi_1>=mfi_2))
|| ((f_1 >= f_2) && (rsi_1>=rsi_2) && (Dm_1 >= Dm_2)) || ((f_1 >= f_2) && (mfi_1>=mfi_2) && (wpr_1>=wpr_2)) );
//----------------------------------------------------------------------------------------idind4-----------------------------------------
bool dindu4= ( (wpr_1<=wpr_2) && (Dm_1<=Dm_2) && ( mfi_1<=mfi_2) && ( rsi_1<=rsi_2) && (f_1<=f_2) );
bool dindd4= ( (wpr_1>=wpr_2) && (Dm_1>=Dm_2) && ( mfi_1>=mfi_2) && ( rsi_1>=rsi_2) && (f_1>=f_2) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//------------------------------------------------------------------------------------------ist1---------------------------------------
bool stu1= (stm_1>sts_1);
bool std1= (stm_1<sts_1);
//------------------------------------------------------------------------------------------ist2---------------------------------------
bool stu2= ( (stm_1>sts_1) && (stm_2>sts_2));
bool std2= ( (stm_1<sts_1) && (stm_2<sts_2) );
//------------------------------------------------------------------------------------------ist3---------------------------------------
bool stu3= ( (stm_1>sts_1) && (stm_2>sts_2) && ((stm_1-sts_1)>(stm_2-sts_2)) );
bool std3= ( (stm_1<sts_1) && (stm_2<sts_2) && ((sts_1-stm_1)>(sts_2-stm_2)) );
//------------------------------------------------------------------------------------------ist4---------------------------------------
bool stu4= ( (stm_1>sts_1) && (stm_2>sts_2) && ((stm_1-sts_1)>(stm_2-sts_2)) && (sts_1<20) );
bool std4= ( (stm_1<sts_1) && (stm_2<sts_2) && ((sts_1-stm_1)>(sts_2-stm_2)) && (sts_1>80) );
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//-----------------------------------------------------------------------------------------if0----------------------------------------
bool fu= (f_1<0);
bool fd= (f_1>0);
//---------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
//---------------------------------------------------------------------------------------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// REVERSED!!
{
//sell signal
if
// 6 =================== sell =======================================================================================
( indu1== iind1 && indd1== iind1z && indu11== iind11 && indd11== iind11z && indu2== iind2 && indd2== iind2z
&& indu3== iind3 && indd3== iind3z && indu4== iind4 && indd4== iind4z && indu44== iind44 && indd44== iind44z
&& slindu44== isind44 && slindd44== isind44z && shfindu44== ishfind44 && shfindd44== ishfind44z
&& dindu1== idind1 && dindd1== idind1z && dindu2== idind2 && dindd2== idind2z && dindu3== idind3 && dindd3== idind3z
&& dindu4== idind4 && dindd4== idind4z
&& stu1== ist1 && std1== ist1z && stu2== ist2 && std2== ist2z && stu3== ist3 && std3== ist3z && stu4== ist4 && std4== ist4z
&& fu== if0 && fd== if0z )
// ------------------------------------------------------------------------------------------------------------------------------------
//********************************************************************************************************************************
{
Bullish = false;
Bearish = true;
}
//******************************************************************************************************************************** //buy signal
else if
// 1 =====================buy================================================================================
( indu1== iind1z && indd1== iind1 && indu11== iind11z && indd11== iind11 && indu2== iind2z && indd2== iind2
&& indu3== iind3z && indd3== iind3 && indu4== iind4z && indd4== iind4 && indu44== iind44z && indd44== iind44
&& slindu44== isind44z && slindd44== isind44 && shfindu44== ishfind44z && shfindd44== ishfind44
&& dindu1== idind1z && dindd1== idind1 && dindu2== idind2z && dindd2== idind2 && dindu3== idind3z && dindd3== idind3
&& dindu4== idind4z && dindd4== idind4
&& stu1== ist1z && std1== ist1 && stu2== ist2z && std2== ist2 && stu3== ist3z && std3== ist3 && stu4== ist4z && std4== ist4
&& fu== if0z && fd== if0 )
{
Bullish = true;
Bearish = false;
}
else
{
Bullish = false;
Bearish = false;
}
}
//**********************************************************************************************************************
//**********************************************************************************************************************
GetPositionStates();
if ((HaveShortPosition) && (Bullish)) ClosePrevious();
if ((HaveLongPosition) && (Bearish)) ClosePrevious();
if (Bullish)
{
if (!HaveLongPosition) fBuy();
}
else if (Bearish)
{
if (!HaveShortPosition) fSell();
}
return(0);
}
//+------------------------------------------------------------------+
//| Check what position is currently open |
//+------------------------------------------------------------------+
void GetPositionStates()
{
int total = OrdersTotal();
for (int cnt = 0; cnt < total; cnt++)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) == false) continue;
if (OrderMagicNumber() != Magic) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderType() == OP_BUY)
{
HaveLongPosition = true;
HaveShortPosition = false;
// double BOP=OrderOpenPrice();
return;
}
else if (OrderType() == OP_SELL)
{
HaveLongPosition = false;
HaveShortPosition = true;
return;
}
}
HaveLongPosition = false;
HaveShortPosition = false;
}
//+------------------------------------------------------------------+
//| Buy |
//+------------------------------------------------------------------+
void fBuy()
{
RefreshRates();
int result = OrderSend(Symbol(),OP_BUY,Lots,Ask,SLIPPAGE,0,0,"Jaber5",Magic,0,Blue);
if (result == -1)
{
int e = GetLastError();
Print("OrderSend Error: ", e);
}
}
//+------------------------------------------------------------------+
//| Sell |
//+------------------------------------------------------------------+
void fSell()
{
RefreshRates();
int result = OrderSend(Symbol(),OP_SELL,Lots,Bid,SLIPPAGE,0,0,"Jaber5",Magic,0,Green);
if (result == -1)
{
int e = GetLastError();
Print("OrderSend Error: ", e);
}
}
//+------------------------------------------------------------------+
//| Close previous position |
//+------------------------------------------------------------------+
void ClosePrevious()
{
int total = OrdersTotal();
for (int i = 0; i < total; i++)
{
if (OrderSelect(i, SELECT_BY_POS) == false) continue;
if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == Magic))
{
if (OrderType() == OP_BUY)
{
RefreshRates();
OrderClose(OrderTicket(),OrderLots(),Bid,SLIPPAGE,Violet);
}
else if (OrderType() == OP_SELL)
{
RefreshRates();
OrderClose(OrderTicket(),OrderLots(),Ask,SLIPPAGE,Red);
}
}
}
}
you should always use the SRC button to post code. Its more professional. Add (input == 2) every time you check buy/sell condition with your inputs. For example, indu1== iind1z should say (indu1 == iind1z || iind1z == 2). Do not forgot to put brackets. This will convert the expression to true if inputs are 2. This will give you three parameters in the optimization process, and putting 2 will always give you true for that indicator check.
you should always use the SRC button to post code. Its more professional. Add (input == 2) every time you check buy/sell condition with your inputs. For example, indu1== iind1z should say (indu1 == iind1z || iind1z == 2). Do not forgot to put brackets. This will convert the expression to true if inputs are 2. This will give you three parameters in the optimization process, and putting 2 will always give you true for that indicator check.
Thank you so much Mr. Kaleem for your assistance , yes it worked as you said ,
But I want to change the code to save optimization time to make for example : 5 parameters in the optimization process 0,1,2,3 ,4 and 5 to convert the expression to true if input is 5
but it doesn't work it gives in optimization same values for all inputs !!! please help
please help
Thank you so much Mr. Kaleem for your assistance , yes it worked as you said ,
But I want to change the code to save optimization time to make for example : 5 parameters in the optimization process 0,1,2,3 ,4 and 5 to convert the expression to true if input is 5
but it doesn't work it gives in optimization same values for all inputs !!! please help
please help
//+------------------------------------------------------------------+ //| JaberShortD.mq4 | //| Copyright 2015, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //--- input parameters input int Lots=1; input int SLIPPAGE=2; input int Magic=3115; input int timeframe=0; input int Dem_Period=7; input int MFI_Period=7; input int RSI_Period=7; input int WPR_Period=7; input int Force_Period=7; input int stc_Kperiod=5; input int stc_Dperiod=3; input int stc_Slowing=3; //++++++++++++++++++++++++ bolls +++++++++++++++++++++++ //_________________________ input int iind=0; //_________________________ input int ist=0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ // Global variables // Common int LastBars = 0; bool HaveLongPosition; bool HaveShortPosition; //+------------------------------------------------------------------+ //| Initialization | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| Deinitialization | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Each tick | //+------------------------------------------------------------------+ int start() { if ((!IsTradeAllowed()) || (IsTradeContextBusy()) || (!IsConnected()) || ((!MarketInfo(Symbol(), MODE_TRADEALLOWED)) && (!IsTesting()))) return(0); // Trade only if new bar has arrived if (LastBars!= Bars) LastBars = Bars; else return(0); //Do we have enough bars to work with if(Bars<60) { Print("bars less than 60"); return(0); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Signals bool Bullish = false; bool Bearish = false; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Indicators //Get Handle for DEM Indicator double Dm_1=iDeMarker(NULL,timeframe,Dem_Period,1); double Dm_2=iDeMarker(NULL,timeframe,Dem_Period,2); double Dm_3=iDeMarker(NULL,timeframe,Dem_Period,3); double Dm_4=iDeMarker(NULL,timeframe,Dem_Period,4); double Dm_5=iDeMarker(NULL,timeframe,Dem_Period,5); double Dm_6=iDeMarker(NULL,timeframe,Dem_Period,6); double Dm_7=iDeMarker(NULL,timeframe,Dem_Period,7); //Get Handle for MFI indicator double mfi_1=iMFI(NULL,timeframe,MFI_Period,1); double mfi_2=iMFI(NULL,timeframe,MFI_Period,2); double mfi_3=iMFI(NULL,timeframe,MFI_Period,3); double mfi_4=iMFI(NULL,timeframe,MFI_Period,4); double mfi_5=iMFI(NULL,timeframe,MFI_Period,5); double mfi_6=iMFI(NULL,timeframe,MFI_Period,6); double mfi_7=iMFI(NULL,timeframe,MFI_Period,7); //Get Handle for RSI Indicator double rsi_1=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,1); double rsi_2=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,2); double rsi_3=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,3); double rsi_4=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,4); double rsi_5=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,5); double rsi_6=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,6); double rsi_7=iRSI(NULL,timeframe,RSI_Period,PRICE_CLOSE,7); //Get Handle for WPR indicator double wpr_1=iWPR(NULL,timeframe,WPR_Period,1); double wpr_2=iWPR(NULL,timeframe,WPR_Period,2); double wpr_3=iWPR(NULL,timeframe,WPR_Period,3); double wpr_4=iWPR(NULL,timeframe,WPR_Period,4); double wpr_5=iWPR(NULL,timeframe,WPR_Period,5); double wpr_6=iWPR(NULL,timeframe,WPR_Period,6); double wpr_7=iWPR(NULL,timeframe,WPR_Period,7); //Get Handle for Stochastic Main indicator double stm_1=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,1); double stm_2=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,2); double stm_3=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,3); double stm_4=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,4); double stm_5=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,5); double stm_6=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,6); double stm_7=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_MAIN,7); //Get Handle for Stochastic Signal indicator double sts_1=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,1); double sts_2=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,2); double sts_3=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,3); double sts_4=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,4); double sts_5=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,5); double sts_6=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,6); double sts_7=iStochastic(NULL,timeframe,stc_Kperiod,stc_Dperiod,stc_Slowing,MODE_SMA,0,MODE_SIGNAL,7); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // REVERSED!!! ((bool difintions)) //******************************************************************************************************************************** //--------------------------------------------------------------------------------------------------------------------------------- //******************************************************************************************************************************** //----------------------------------------------------------------------------iind1----------------------------------------------------- bool indu1= ( (Dm_1>=0.7)||(mfi_1>=80)||(rsi_1>=70)||(wpr_1>=-20)||(Dm_2>=0.7)||(mfi_2>=80)||(rsi_2>=70)||(wpr_2>=-20) ); bool indd1= ( (Dm_1<=0.3)||(mfi_1<=20)||(rsi_1<=30)||(wpr_1<=-80)||(Dm_2<=0.3)||(mfi_2<=20)||(rsi_2<=30)||(wpr_2<=-80) ); //-----------------------------------------------------------------------------iind2---------------------------------------------------- bool indu2= ( ( ((mfi_1>= 80)||(mfi_2>= 80)) && ((rsi_1>= 70)||(rsi_2>= 70)) ) || ( ((wpr_1>=-20)||(wpr_2>=-20)) && ((rsi_1>= 70)||(rsi_2>= 70)) ) || ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((rsi_1>= 70)||(rsi_2>= 70)) ) || ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((mfi_1>= 80)||(mfi_2>= 80)) ) || ( ((Dm_1 >=0.7)||(Dm_2 >=0.7)) && ((wpr_1>=-20)||(wpr_2>=-20)) ) || ( ((mfi_1>= 80)||(mfi_2>= 80)) && ((wpr_1>=-20)||(wpr_2>=-20)) ) ); bool indd2= ( ( ((mfi_1<= 20)||(mfi_2<= 20)) && ((rsi_1<= 30)||(rsi_2<= 30)) ) || ( ((wpr_1<=-80)||(wpr_2<=-80)) && ((rsi_1<= 30)||(rsi_2<= 30)) ) || ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((rsi_1<= 30)||(rsi_2<= 30)) ) || ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((mfi_1<= 20)||(mfi_2<= 20)) ) || ( ((Dm_1 <=0.3)||(Dm_2 <=0.3)) && ((wpr_1<=-80)||(wpr_2<=-80)) ) || ( ((mfi_1<= 20)||(mfi_2<= 20)) && ((wpr_1<=-80)||(wpr_2<=-80)) ) ); //------------------------------------------------------------------------------iind3--------------------------------------------------- bool indu3= ( ( ((mfi_1>=80)||(mfi_2>=80)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) ) || ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) ) || ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((mfi_1>=80)||(mfi_2>=80)) && ((wpr_1>=-20)||(wpr_2>=-20)) ) || ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((rsi_1>=70)||(rsi_2>=70)) && ((mfi_1>= 80)||(mfi_2>= 80)) ) ); bool indd3= ( ( ((mfi_1<=20)||(mfi_2<=20)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) ) || ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) ) || ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((mfi_1<=20)||(mfi_2<=20)) && ((wpr_1<=-80)||(wpr_2<=-80)) ) || ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((rsi_1<=30)||(rsi_2<=30)) && ((mfi_1<= 20)||(mfi_2<= 20)) ) ); //------------------------------------------------------------------------------iind4--------------------------------------------------- bool indu4= ( ((Dm_1>=0.7)||(Dm_2>=0.7)) && ((mfi_1>=80)||(mfi_2>=80)) && ((rsi_1>=70)||(rsi_2>=70)) && ((wpr_1>=-20)||(wpr_2>=-20)) ); bool indd4= ( ((Dm_1<=0.3)||(Dm_2<=0.3)) && ((mfi_1<=20)||(mfi_2<=20)) && ((rsi_1<=30)||(rsi_2<=30)) && ((wpr_1<=-80)||(wpr_2<=-80)) ); //--------------------------------------------------------------------------------------------------------------------------------- //******************************************************************************************************************************** //------------------------------------------------------------------------------------------ist1--------------------------------------- bool stu1= (stm_1>sts_1); bool std1= (stm_1<sts_1); //------------------------------------------------------------------------------------------ist2--------------------------------------- bool stu2= ( (stm_1>sts_1) && (stm_2>sts_2)); bool std2= ( (stm_1<sts_1) && (stm_2<sts_2) ); //------------------------------------------------------------------------------------------ist3--------------------------------------- bool stu3= ( (stm_1>sts_1) && (stm_2>sts_2) && ((stm_1-sts_1)>(stm_2-sts_2)) ); bool std3= ( (stm_1<sts_1) && (stm_2<sts_2) && ((sts_1-stm_1)>(sts_2-stm_2)) ); //------------------------------------------------------------------------------------------ist4--------------------------------------- bool stu4= ( (stm_1>sts_1) && (stm_2>sts_2) && ((stm_1-sts_1)>(stm_2-sts_2)) && (sts_1<20) ); bool std4= ( (stm_1<sts_1) && (stm_2<sts_2) && ((sts_1-stm_1)>(sts_2-stm_2)) && (sts_1>80) ); //--------------------------------------------------------------------------------------------------------------------------------- //******************************************************************************************************************************** //-----------------------------------------------------------------------------------------if0---------------------------------------- if (iind==1) indu1=1; else indu1=50; if (iind==2) indu2=1; else indu2=50; if (iind==3) indu3=1; else indu3=50; if (iind==4) indu4=1; else indu4=50; if (iind==1) indd1=1; else indd1=50; if (iind==2) indd2=1; else indd2=50; if (iind==3) indd3=1; else indd3=50; if (iind==4) indd4=1; else indd4=50; if (ist==1) stu1=1; else stu1=50; if (ist==2) stu2=1; else stu2=50; if (ist==3) stu3=1; else stu3=50; if (ist==4) stu4=1; else stu4=50; if (ist==1) std1=1; else std1=50; if (ist==2) std2=1; else std2=50; if (ist==3) std3=1; else std3=50; if (ist==4) std4=1; else std4=50; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // REVERSED!!! { //sell signal if ( ( indu1 || iind==2 || iind==3 || iind==4 || iind==5 ) && ( indu2 || iind==1 || iind==3 || iind==4 || iind==5 ) && ( indu3 || iind==1 || iind==2 || iind==4 || iind==5 ) && ( indu4 || iind==1 || iind==2 || iind==3 || iind==5 ) && ( stu1 || ist==2 || ist==3 || ist==4 || ist==5 ) && ( stu2 || ist==1 || ist==3 || ist==4 || ist==5 ) && ( stu3 || ist==1 || ist==2 || ist==4 || ist==5 ) && ( stu4 || ist==1 || ist==2 || ist==3 || ist==5 ) ) //******************************************************************************************************************************** { Bullish = false; Bearish = true; } //******************************************************************************************************************************** //buy signal else if ( ( indd1 || iind==2 || iind==3 || iind==4 || iind==5 ) && ( indd2 || iind==1 || iind==3 || iind==4 || iind==5 ) && ( indd3 || iind==1 || iind==2 || iind==4 || iind==5 ) && ( indd4 || iind==1 || iind==2 || iind==3 || iind==5 ) && ( std1 || ist==2 || ist==3 || ist==4 || ist==5 ) && ( std2 || ist==1 || ist==3 || ist==4 || ist==5 ) && ( std3 || ist==1 || ist==2 || ist==4 || ist==5 ) && ( std4 || ist==1 || ist==2 || ist==3 || ist==5 ) ) //******************************************************************************************************************************** { Bullish = true; Bearish = false; } else { Bullish = false; Bearish = false; } } //********************************************************************************************************************** //********************************************************************************************************************** GetPositionStates(); if ((HaveShortPosition) && (Bullish)) ClosePrevious(); if ((HaveLongPosition) && (Bearish)) ClosePrevious(); if (Bullish) { if (!HaveLongPosition) fBuy(); } else if (Bearish) { if (!HaveShortPosition) fSell(); } return(0); } //+------------------------------------------------------------------+ //| Check what position is currently open | //+------------------------------------------------------------------+ void GetPositionStates() { int total = OrdersTotal(); for (int cnt = 0; cnt < total; cnt++) { if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) == false) continue; if (OrderMagicNumber() != Magic) continue; if (OrderSymbol() != Symbol()) continue; if (OrderType() == OP_BUY) { HaveLongPosition = true; HaveShortPosition = false; return; } else if (OrderType() == OP_SELL) { HaveLongPosition = false; HaveShortPosition = true; return; } } HaveLongPosition = false; HaveShortPosition = false; } //+------------------------------------------------------------------+ //| Buy | //+------------------------------------------------------------------+ void fBuy() { RefreshRates(); int result = OrderSend(Symbol(),OP_BUY,Lots,Ask,SLIPPAGE,0,0,"Jaber5",Magic,0,Blue); if (result == -1) { int e = GetLastError(); Print("OrderSend Error: ", e); } } //+------------------------------------------------------------------+ //| Sell | //+------------------------------------------------------------------+ void fSell() { RefreshRates(); int result = OrderSend(Symbol(),OP_SELL,Lots,Bid,SLIPPAGE,0,0,"Jaber5",Magic,0,Green); if (result == -1) { int e = GetLastError(); Print("OrderSend Error: ", e); } } //+------------------------------------------------------------------+ //| Close previous position | //+------------------------------------------------------------------+ void ClosePrevious() { int total = OrdersTotal(); for (int i = 0; i < total; i++) { if (OrderSelect(i, SELECT_BY_POS) == false) continue; if ((OrderSymbol() == Symbol()) && (OrderMagicNumber() == Magic)) { if (OrderType() == OP_BUY) { RefreshRates(); OrderClose(OrderTicket(),OrderLots(),Bid,SLIPPAGE,Violet); } else if (OrderType() == OP_SELL) { RefreshRates(); OrderClose(OrderTicket(),OrderLots(),Ask,SLIPPAGE,Red); } } } }
Thank you so much Mr. Kaleem for your assistance , yes it worked as you said ,
But I want to change the code to save optimization time to make for example : 5 parameters in the optimization process 0,1,2,3 ,4 and 5 to convert the expression to true if input is 5
but it doesn't work it gives in optimization same values for all inputs !!! please help
please help

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
I want help to optimize a Bool type expression 0 False 1True and i want also skip the expression too for example
if ( bool type 1 == True && bool type 2 == True && bool type 3 == False .................................. )
{
Bullish = false;
Bearish = true;
}
i made Int constants for True and False values to optimize them but it take only True (1) and False (0) but how to skip the bool type for example bool type 2 in optimization process not only give it a true or false values , i want in optimization the int value 1 true and 0 false and if i put another number for example 2 to skip that bool
Thank you in advance
Jaber