how can i make the expert doesnt open any order until the existing order closes?

 
hello all

my experience in mql4 is not much but i am trying

i have an expert for moving average but the problem when i add it to work on any time frame like 5 minutes it opens an order  every 5 minutes when there is already an existing order!!

this is a part of the expert

ma1=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0);

 if(Close[1]>ma1&&time!=Time[0]&&orderstotal()<max)

i dont know what is the problem

i just need it doesnt open any order until the existing order closes .. thank you
Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average...
 
  1. most123: i dont know what is the problem

    Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)


  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  3.  if(Close[1]>ma1&&time!=Time[0]&&orderstotal()<max)

    How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

    Always post all relevant code. We have no idea what time is or if it is ever updated. We have no idea what orderstotal() does. We have no idea what max is.

 
if your orderstotal() is OrdersTotal() and if your max is an input set to 2… should work… don’t know about the “time”… maybe it is a part from NewBar()
 
most123:
hello all

my experience in mql4 is not much but i am trying

i have an expert for moving average but the problem when i add it to work on any time frame like 5 minutes it opens an order  every 5 minutes when there is already an existing order!!

this is a part of the expert

ma1=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0);

 if(Close[1]>ma1&&time!=Time[0]&&orderstotal()<max)

i dont know what is the problem

i just need it doesnt open any order until the existing order closes .. thank you

What is the value of max?