GOOD DAY TRADERS
After two months of struggling trying to make expert advisor I was able to achieve it a little finally i have abnormal expert advisor, actually the EA works good but it do place about 20 or more trade but my main idea was, the EA TO PLACE ONE ORDER PER SIGNAL EVEN IF THERE IS ALREADY AN OPEN OREDER BUYOR SELL THE SHOULD ACKNOWLEDGE AND PLACE ONLY ONE ORDER ACCORDING TO SIGNAL RECEIVED WITH OUT CLOSING ALREADY OPEN ORDER but here the EA do place more than 20 please some should please help me below is the code
//+------------------------------------------------------------------+ //| ProjectName | //| Copyright 2018, CompanyName | //| http://www.companyname.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2021,FXTIDYLUCKYSTAR." #property link "TIDYLUCKYSTAR@GMAIL.COM" #property version "1.00" input string sTheText = "This is traded from the EA"; input double Lots = 0.01; input int StopLoss = 100; input int TakeProfit = 100; input int Magic = 12345; input ENUM_TIMEFRAMES time_frame; input string separator00 = "*** OSMA Settings ***"; input int fastEMA = 5; input int slowEMA = 34; input int OSMA_signal = 5; input string separator01 = "*** Indicator Settings ***"; input double positiveSensitivity = 0.0001; input double negativeSensitivity = -0.0001; input double historyBarsCount = 0; input bool drawDivergenceLines = false; input bool displayAlert = false; input bool alertsON = false; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create timer EventSetTimer(60); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- destroy timer EventKillTimer(); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- if(IsNewBar()) { static int direction = 0; direction = CheckDirection(); PlaceTrade(direction); } // AdjustStops; } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- //int direction = CheckDirection(); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int CheckDirection() { // THIS IS BASED ON ICHIMOKU, MOVING AVERAGE AND RSI DIVERGENCE .CCI DIVERGENCE ,MACD DIVERGENCE ,OSMA DIVERGENCE , OBV DIVERGENCE // BUT IN ORDER TO MAKE IT MORE RELIABLE I ONLY USED ICHIMOKU AND OSMA DIVERGENCE_2.1 static int OSMA2check = 0; // 0= neutral, 1 = long, -1 = short static int Ichicheck = 0; // v2.1 if(iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,2,1) !=EMPTY_VALUE) OSMA2check = 1; if(iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,3,1) !=EMPTY_VALUE) OSMA2check = -1; if(iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,2,1) ==EMPTY_VALUE && iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,3,1) ==EMPTY_VALUE) OSMA2check = 0; double sanity = iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,2,1); double sanity2 = iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,3,1); Comment("OSMA2check is :, ", OSMA2check, " sanity check is: ", DoubleToStr(sanity,5), " sanity2 :, ",DoubleToStr(sanity2,5)); if(OSMA2check == 1) return(1); else return(0); if(OSMA2check == -1) return(2); else return(0); } // End Check Direction //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void PlaceTrade(int direction) { ///---FOR BUY CONDITIONS if(direction == 1) int ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask - StopLoss * Point(),Ask + TakeProfit * Point(),sTheText, Magic,0,Blue); ///---FOR SELL CONDITIONS if(direction == 2) int sell=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid + StopLoss * Point(),Bid - TakeProfit * Point(),sTheText, Magic,0,Red); else Print("direction is 0, so no trade"); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool IsNewBar() { static datetime lastbar; datetime curbar = (datetime)SeriesInfoInteger(_Symbol,_Period,SERIES_LASTBAR_DATE); if(lastbar != curbar) { lastbar = curbar; return true; } return false; } //+------------------------------------------------------------------+
i added a function called IsNewBAr which only look for signal if new candle is happend this means it will only open order once for each signal
- Iwegbuna Chidera Clinton: TO PLACE ONE ORDER PER SIGNAL
Don't SHOUT at us — that is RUDE.
-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon. -
if(iCustom(Symbol(),time_frame,"tidy/OSMA_FXTIDYLUCKYSTAR_V2.1",separator00,fastEMA,slowEMA,OSMA_signal,separator01,drawDivergenceLines,displayAlert,alertsON,2,1) !=EMPTY_VALUE) OSMA2check = 1;
Do you check if you have an open order? -
Do you check only once per bar?
-
You are looking at a signal. Act on a change of signal.
MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 2017.12.12
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
i added a function called IsNewBAr which only look for signal if new candle is happend this means it will only open order once for each signal
THANK YOU SIR
I was like i won't try this next with so many error frustrations
please can you help add email alert for i'm getting wrong parameters thanks
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
GOOD DAY TRADERS
After two months of struggling trying to make expert advisor I was able to achieve it a little finally i have abnormal expert advisor, actually the EA works good but it do place about 20 or more trade but my main idea was, the EA TO PLACE ONE ORDER PER SIGNAL EVEN IF THERE IS ALREADY AN OPEN OREDER BUYOR SELL THE SHOULD ACKNOWLEDGE AND PLACE ONLY ONE ORDER ACCORDING TO SIGNAL RECEIVED WITH OUT CLOSING ALREADY OPEN ORDER but here the EA do place more than 20 please some should please help me below is the code