Mo1k wrote >>
Hello,
i am programming my own ea but the ea isnt trading but if i look at the charts, there are bars with my conditions !!!
the ordersend code is correct and working.
conditions for long trade:
the difference between the open and close price must be at least 3 pips
the differenze between the last 2 bars must be under 1 pip
the last bar close price must be higher than the open price
William's percent range must be under 40
Stochastic must be under 25
rsi must be under 51
conditions for short trade:
the difference between the open and close price must be at least 3 pips
the differenze between the last 2 bars must be under 1 pip
the last bar open price must be higher than the close price
William's percent range must be over 60
Stochastic must be over 75
rsi must be over 49
Mo1k
Hello,
i am programming my own ea but the ea isnt trading but if i look at the charts, there are bars with my conditions !!!
the ordersend code is correct and working.
conditions for long trade:
the difference between the open and close price must be at least 3 pips
the differenze between the last 2 bars must be under 1 pip
the last bar close price must be higher than the open price
William's percent range must be under 40
Stochastic must be under 25
rsi must be under 51
conditions for short trade:
the difference between the open and close price must be at least 3 pips
the differenze between the last 2 bars must be under 1 pip
the last bar open price must be higher than the close price
William's percent range must be over 60
Stochastic must be over 75
rsi must be over 49
Mo1k
If you put Wiliams Percent Range (WPR) on your chart you will see the negative values..0 to -100
So ... WPR>60 never will become true and WPR<40 always true :-)
The d2 variable is declared as a double data type, but has not be assigned a value. So conditional expressions like this will always have false return.
(d2>minimalecodifferenz)
Sometimes it is easier to break the thing up into functions.....looking at som many interleaved if's and's or's can be painful.
#define NO_RESULT -10 extern double mnumber = 100; extern double TakeProfit = 25; extern double StopLoss = 10; extern double Lots = 0.1; extern double bardifferenz = 1.1; extern double minimalecodifferenz = 3; int D_Factor = 1; double Slippage = 3; //+------------------------------------------------------------------+ //| Expert Initialisation | //+------------------------------------------------------------------+ int init() { double Pip = Point; if (Digits == 3|| Digits == 5){D_Factor = 10; Pip = Point * 10;} TakeProfit *= Pip; StopLoss *= Pip; bardifferenz *= Pip; minimalecodifferenz *= Pip; Slippage *= Pip; } //+------------------------------------------------------------------+ //| Expert Start | //+------------------------------------------------------------------+ int start() { if(!Can_Trade())return(0); //there is an open trade so do nothing if(!Open_Close_Diff())return(0);// difference between Open and Close is less than 3 pips>>Do nothing if(!Bar_Pip_Difference())return(0); //difference between bars is more than 1 pip int Buy_or_Sell = WPR_Check() + Stoch_Check() + RSI_Check(); //if all return buy(0) sum = 0......if all return sell(1) sum = 3....if any return fail sum = less than 0(-10 per fail) if(Buy_or_Sell == 0){ //buy signal double Temp_SL = NormalizeDouble(Ask - StopLoss,Digits); //claculate stops and normalise double Temp_TP = NormalizeDouble(Ask + TakeProfit,Digits); int ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"firstea",mnumber,0,Green);//enter order without stop to be ECN compatible if (ticket > 0)bool mod = OrderModify(ticket,OrderOpenPrice(),Temp_SL,Temp_TP,0,CLR_NONE);//if order is successfull enter the stops if(!mod)Alert("Error entering SL or TP"); //the ordermodify had a problem >> alter the user } if(Buy_or_Sell == 3){ //sell signal Temp_SL = NormalizeDouble(Bid + StopLoss,Digits); //claculate stops and normalise Temp_TP = NormalizeDouble(Bid - TakeProfit,Digits); ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"firstea",mnumber,0,Green);//enter order without stop to be ECN compatible if (ticket > 0)mod = OrderModify(ticket,OrderOpenPrice(),Temp_SL,Temp_TP,0,CLR_NONE);//if order is successfull enter the stops if(!mod)Alert("Error entering SL or TP"); //the ordermodify had a problem >> alter the user } return(0); } //----------------------------------------------------------------- bool Can_Trade() //returns false if we have an open trade { for(int cnt=0;cnt<OrdersTotal();cnt++){ OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber()==mnumber)return(false); } return(true); //no open trade so return true } //----------------------------------------------------------------- bool Open_Close_Diff() { if (MathAbs(Open[1] - Close[1]) > minimalecodifferenz)return(false); if (MathAbs(Open[2] - Close[2]) > minimalecodifferenz)return(false); return(true); } //---------------------------------------------------------------- bool Bar_Pip_Difference() { double Bar_1 = MathAbs(Open[1] - Close[1]), //size of bar 1 Bar_2 = MathAbs(Open[2] - Close[2]); //size of bar 2 if (MathAbs(Bar_1 - Bar_2) < bardifferenz) return(true); //difference between 2 bars is less than 1 pip return(false); } //---------------------------------------------------------------- int WPR_Check() { double wpr1 = iWPR(NULL,0,25,2), wpr2 = iWPR(NULL,0,25,1); if (wpr1 < 40 || wpr2 < 40)return(OP_BUY); if (wpr1 > 60 || wpr2 > 60)return(OP_SELL); return(NO_RESULT); } //----------------------------------------------------------------- int Stoch_Check() { double stoch1 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,2), stoch2 = iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1); if (stoch1 < 25 || stoch1 < 25)return(OP_BUY); if (stoch1 > 75 || stoch2 > 75)return(OP_SELL); return(NO_RESULT); } //----------------------------------------------------------------- int RSI_Check() { double rsi1 = iRSI(NULL,0,14,PRICE_CLOSE,2), rsi2 = iRSI(NULL,0,14,PRICE_CLOSE,1); if (rsi1 <= 50 || rsi2 <= 50)return(OP_BUY); if (rsi1 >= 50 || rsi2 >= 50)return(OP_SELL); return(NO_RESULT); } //-----------------------------------------------------------------
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
i am programming my own ea but the ea isnt trading but if i look at the charts, there are bars with my conditions !!!
the ordersend code is correct and working.
conditions for long trade:
the difference between the open and close price must be at least 3 pips
the differenze between the last 2 bars must be under 1 pip
the last bar close price must be higher than the open price
William's percent range must be under 40
Stochastic must be under 25
rsi must be under 51
conditions for short trade:
the difference between the open and close price must be at least 3 pips
the differenze between the last 2 bars must be under 1 pip
the last bar open price must be higher than the close price
William's percent range must be over 60
Stochastic must be over 75
rsi must be over 49
Mo1k