What is wrong with my code?

 

Hi,

I need a little help here. I have this EA tied to a custom indicator. The indicator is a Fisher transform. In my code I have this logic:

if(fish0> -0.2 && fish1 <=-0.2)

New Buy Order/Close Sell Order

else if(fish0<0.2 && fish1>=0.2)

New Sell Order/Close Buy Order

Here are the files and a screen copy. I don't know why are there so many orders. I just want the one circled in the indicator to execute. How do I do that?. Thanks in advance.

FAC in Florida

Files:
 
1121048:

Hi,

I need a little help here. I have this EA tied to a custom indicator. The indicator is a Fisher transform. In my code I have this logic:

if(fish0> -0.2 && fish1 <=-0.2)

New Buy Order/Close Sell Order

else if(fish0<0.2 && fish1>=0.2)

New Sell Order/Close Buy Order

Here are the files and a screen copy. I don't know why are there so many orders. I just want the one circled in the indicator to execute. How do I do that?. Thanks in advance.

FAC in Florida


bump
 

I don't have the time at the moment to review your code but why don't you just check for

if (OrdersTotal()=0);

before opening a new order..?

 
n8937g:

I don't have the time at the moment to review your code but why don't you just check for

if (OrdersTotal()=0);

before opening a new order..?


Thank you for your idea, but is not helping with my problem. The problem is that the order is supossed to trigger at only one time. If you see in the screen copy, the red circle is where I want my order to be sent. The horizontal line is -0.2. I can't find in my code any condittion for the order to be send in the other bars. In this screen the order should be send at the big red bar at the bottom (signal goin up and crossing over the -0.2 level). However, it sends orders on bars that are way off my logic (for example, 5 bars before there are 4 buy orders that I can't find how they got there, the same happens two bars after when the value is oviously way bigger than -0.2. Only the crossin over -0.2 level is my trigger signal). I just need an explanation on why it ias happening so I can change/modify the code. Have been reading logs and re-testing for couple of days with no luck.

Thank You

FAC

 
1121048:


Thank you for your idea, but is not helping with my problem. The problem is that the order is supossed to trigger at only one time. If you see in the screen copy, the red circle is where I want my order to be sent. The horizontal line is -0.2. I can't find in my code any condittion for the order to be send in the other bars. In this screen the order should be send at the big red bar at the bottom (signal goin up and crossing over the -0.2 level). However, it sends orders on bars that are way off my logic (for example, 5 bars before there are 4 buy orders that I can't find how they got there, the same happens two bars after when the value is oviously way bigger than -0.2. Only the crossin over -0.2 level is my trigger signal). I just need an explanation on why it ias happening so I can change/modify the code. Have been reading logs and re-testing for couple of days with no luck.

Thank You

FAC


bump
 

I'm at work and can't take the time to review your work... but the way I'm reading your comment, you want to have either one buy or one sell open at any time. The fact that additional orders are opening tells me that you haven't put a condition to NOT open another order when the condition to open an order still exists and a new candle has opened.

 
n8937g:

I'm at work and can't take the time to review your work... but the way I'm reading your comment, you want to have either one buy or one sell open at any time. The fact that additional orders are opening tells me that you haven't put a condition to NOT open another order when the condition to open an order still exists and a new candle has opened.

Thank You n.....g,
I add a check for OrdersTotal() to just open one order at a time. It opens just one order and never close it. But still the order is executed outside my condition of crossing over the level. I'm enclosing another screen shot and the modified EA.

Files:
 

OK took a quick look at your code. After entering the if (OrdersTotal()==0) it does limit the multiple orders properly. A few other suggestions to consider...

Can't you use just one Indicator and have the logic

if(fish> 0.2 &&OrdersTotal()==0)

{

New Buy Order

}

if(fish<0.2&&ordersTotal()==0)

{

New SellOrder

}

And just use either Trailing Stops or Small T/P to close your orders?

 
n8937g:

OK took a quick look at your code. After entering the if (OrdersTotal()==0) it does limit the multiple orders properly. A few other suggestions to consider...

Can't you use just one Indicator and have the logic

if(fish> 0.2 &&OrdersTotal()==0)

{

New Buy Order

}

if(fish<0.2&&ordersTotal()==0)

{

New SellOrder

}

And just use either Trailing Stops or Small T/P to close your orders?


Wow, that was fast, you rock my friend. Let me try this way.

Thank You very much

 
1121048:


Wow, that was fast, you rock my friend. Let me try this way.

Thank You very much


Well, just finished testing it and it doesn't make any sense. Again the EA opened a BUY order in the middle of nowhere. That's OK because the new logic is to open when fish>0.2 and OrdersTotal()==0. What chock me is the fact that it never closed the BUY order where it shoul be. I got a print out of the log file and it is clear the signal changed from 0.2 to 0.9 at arround 8:58 in the time stamp. However the EA never issued the close BUY order. Here are the files again. Sorry to be a pain in the a.. but I'm stuck in this code for soooooo much time.

This is a copy/paste of the log file. Check the time at 8:58 to see how the signal changes from 0.2 to 0.19.

14:14:51 2009.09.03 08:57 Fisher_Public EURUSD,M5: fisho=0.2079
14:14:51 2009.09.03 08:57 Fisher_Public EURUSD,M5: fisho=0.2067
14:14:51 2009.09.03 08:57 Fisher_Public EURUSD,M5: fisho=0.2054
14:14:51 2009.09.03 08:57 Fisher_Public EURUSD,M5: fisho=0.2041
14:14:51 2009.09.03 08:57 Fisher_Public EURUSD,M5: fisho=0.2035
14:14:51 2009.09.03 08:57 Fisher_Public EURUSD,M5: fisho=0.2023
14:14:51 2009.09.03 08:57 Fisher_Public EURUSD,M5: fisho=0.2011
14:14:51 2009.09.03 08:57 Fisher_Public EURUSD,M5: fisho=0.1998
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987
14:14:51 2009.09.03 08:58 Fisher_Public EURUSD,M5: fisho=0.1987

Files:
 

Your Indicator is repainting... try this one. I think your opening offset now could be because of this...earlier tests showed an offset because you still had open order(s) and/or two indicators to prove up. Have you added Trailing stop or Take profit to your code yet? Letting it go back to the point at which the opposite orders were placed before closing left a lot of profit on the table instead of in the pocket too LOL...What pair and TF are you testing?

Files:
Reason: