Expert Advisor - Open Trade Issue

 

Hi,

I have programmed an expert advisor and is working well! It does everything I need it to do, except that there is one bug or flaw in my advisor.

I use an oscillator to get the trend, and then either open a long or short. If the trend goes the other way, it closes the current trade and opens another. This works fine, except that when back trading. One tick makes the trent up, so I open a trade. The very next tick makes the trend down, so I close the long and open a short. So on and so on, so that I actually make about 15 until the trend definately goes one way or another.

Is there any way I can somehow skip an hour's worth of ticks once I open a trade? So that I no longer trend the wrong way, etc?

Any help would be greatly appreciated!

 

i think you should use previous bar instead current bar. Use bar index 1, not 0 for your oscillator.

Good luck

 
demam_emas:
i think you should use previous bar instead current bar. Use bar index 1, not 0 for your oscillator. Good luck

Or use previous bar And current bar.

if (current_bar > previous_bar)

{Ordersend() Long}

if (current_bar < previous_bar)

{Ordersend() Short}

Use something like that, This will stop the multiple open and close of orders in a small time frame. Plus it is using two bars to confirm the trend, instead of just one.

Just my thoughts, good luck!