You never set last_signal. And there's no need to use a double for this. Also you never check for signal=="sell". When looping through open orders always go from back to front: for(int i=OrdersTotal()-1;i>=0;i--)
Thanks for your comment.
About the second part yes, it was just a mistake :)
About the first part, I want to count the candles backward and when I find the first arrow up or arrow down, or in other words, signal="buy" or signal="sell", make a position according to conditions (which I said above in the first post). So about the Third part I think it was a mistake of mine to look for a OP_BUY or OP_SELL.
And what I forgot to say is that I want to make the position a candle after the signal candle, and also do this for closing the position a candle after the signal candle, to make sure that it was a correct signal, obviously because my strategy repaints.
So That's all I'm looking for and I don't know what to do about it.
And what I forgot to say is that I want to make the position a candle after the signal candle, and also do this for closing the position a candle after the signal candle, to make sure that it was a correct signal, obviously because my strategy repaints.
In this case it's better to add a new bar check and when a new candle opens look back at the previous one if it got a signal (or even the 2nd last one.)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi friends. I hope that you are fine. I built an strategy and I want to make an EA of it. I wrote the basics code which I'll be sharing with you but it doesn't do what I want from it. I'll attach a picture to this post. In this picture you will see four vertical lines. I'll tell you what those lines mean. The the blue line is on the candle that shows an arrow up after its last arrow which is down with a red vertical line on the candle. The candle after the candle which has a blue vertical line is my long entry. My exist will be the candle which has an arrow down and a brown vertical line on it. Also notice that the last arrow is an up one which is on the candle with a green vertical line. At this exit, I want to open a short position too. and exit when a arrow up appears (the candle after it at open price) and not to mention that there's an arrow down before it. and here again is a long position entry and this cycle goes on and on with an stoploss of 100 pips. I hope you can help me with the code.
here's my basic code (I've already defined the sell conditions and buy conditions but for obvious reasons I can't share them here):