Ea opening Trades everytime

 

Hello, the ea is suppose to open a trade when  candle[3] is bearish and 2 candles bullish ( candle [2] & candle[1]) but it opens positions on the first signal  till it hit the SL then it looks for another signal. How do I stop this

Files:
yu.PNG  18 kb
00.PNG  129 kb
 
Sphelele Sphesihle Lubanyana: the ea is suppose to …

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the file.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

We can't see your broken code.

Fix your broken code.

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)

 
Sphelele Sphesihle Lubanyana:

Hello, the ea is suppose to open a trade when  candle[3] is bearish and 2 candles bullish ( candle [2] & candle[1]) but it opens positions on the first signal  till it hit the SL then it looks for another signal. How do I stop this

if(BuySignal==true&&LongPos<1){TradeLong();}
if(SellSignal==true&&ShortPos<1){TradeShort();}

Hope this help.

 
David Diez #:

Hope this help.

Is not… what is BuySignal?? What is LongPos?? Also others… we cannot see this conditions 
 
William Roeder #:

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the file.
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

We can't see your broken code.

Fix your broken code.

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)

This what I have. please help me. I am just a few steps away from completing the ea. Please check the trailling stop. If true, it deletes the tp , same as  the break even

 
Sphelele Sphesihle Lubanyana #:

This what I have. please help me. I am just a few steps away from completing the ea. Please check the trailling stop. If true, it deletes the tp , same as  the break even

you are missing the indicator

EDIT: handle goes into OnInit func, not OnTick
 
Revo Trades #:

you are missing the indicator

EDIT: handle goes into OnInit func, not OnTick

I tried doing that too

which indicator am I missing

 
Sphelele Sphesihle Lubanyana #:

I tried doing that too

which indicator am I missing

there is a indicator called g.ex5 added as a resource at top of the code.

 

Well thanks everyone, I finally figured where I went wrong. But I am still trying to get to the bottom of the trail and break even

 
Sphelele Sphesihle Lubanyana #:

Well thanks everyone, I finally figured where I went wrong. But I am still trying to get to the bottom of the trail and break even

describe what it is doing and how you want to work.

q... do i require the indicator for the ea to work? or can i comment out that resource line, and the ea will work?