Gann HiLo EA
You have some infinite loops in the code and I don't understand why you have the loop on the trade decision so I chpped it about a bit and now at least it runs in back tester. It still doesn't trade but now you can add comments and see why no trades occur. Perhaps you should look at the structure some more because it is all in line code. Try using function calls to modularise it.
Thank you so much Ruptor for your help! I already checked and realized that the reason that the EA doesn't place trades was because it couldn't find the right conditions for the ones I wrote (below)
if ((Open[i]>ssl[i+1]) && (Close[i+1]<=ssl[i+1])) Buy_signal=1; if ((Open[i]>ssl[i+1]) && (Close[i+1]>ssl[i+1])&& (Open[i+1]<=ssl[i+1])) Buy_signal=1; if ((Open[i]<ssl[i+1]) && (Close[i+1]>=ssl[i+1])) Sell_signal=1; if ((Open[i]<ssl[i+1]) && (Close[i+1]<ssl[i+1])&& (Open[i+1]>=ssl[i+1])) Sell_signal=1;
The entire condition for placing trade is this (still, when I eliminate other orders and only keep the conditions and the order placing loops, it still does not place others. Is there any problem with the way the GAnn is calculated?
int i=0; if(Close[i]>iMA(Symbol(),0,Lookback,0,MODE_SMA,PRICE_HIGH,i+1)) Hld=1; else { if(Close[i]<iMA(Symbol(),0,Lookback,0,MODE_SMA,PRICE_LOW,i+1)) Hld=-1; else Hld=0; } if(Hld!=0) Hlv=Hld; if(Hlv==-1) ssl[i]=iMA(Symbol(),0,Lookback,0,MODE_SMA,PRICE_HIGH,i+1); else ssl[i]=iMA(Symbol(),0,Lookback,0,MODE_SMA,PRICE_LOW,i+1); if ((Open[i]>ssl[i+1]) && (Close[i+1]<=ssl[i+1])) Buy_signal=1; if ((Open[i]>ssl[i+1]) && (Close[i+1]>ssl[i+1])&& (Open[i+1]<=ssl[i+1])) Buy_signal=1; if ((Open[i]<ssl[i+1]) && (Close[i+1]>=ssl[i+1])) Sell_signal=1; if ((Open[i]<ssl[i+1]) && (Close[i+1]<ssl[i+1])&& (Open[i+1]>=ssl[i+1])) Sell_signal=1;
if ((Open[i]>ssl[i+1]) && (Close[i+1]<=ssl[i+1])) Buy_signal=1; if ((Open[i]>ssl[i+1]) && (Close[i+1]>ssl[i+1])&& (Open[i+1]<=ssl[i+1])) Buy_signal=1; if ((Open[i]<ssl[i+1]) && (Close[i+1]>=ssl[i+1])) Sell_signal=1; if ((Open[i]<ssl[i+1]) && (Close[i+1]<ssl[i+1])&& (Open[i+1]>=ssl[i+1])) Sell_signal=1;Please help me, everyone, I don't know whom to ask and where to ask ........ : (I still don't know the reason why the condition to open trades above isn't sufficient !??!!! When I separate the conditions, the trades were opened; however, when I group them together using "&&" no trade was opened!!! :( please help me once
I hope all the experts here will help me figure out why my EA does not work. This EA drove men nut. I have rechecked it so many time but still could not figure out the error!!!
The rule is very simple based on Gann Hi-Lo
Price crosses above Gann -> buy
Price crosses below Gann -> sell
Standard: Open price of the current bar
Buy Condition 1:
If (current_open_price>gann) And { if (last_close_price<=gann)
=> buy at current_open_price
Buy Condition 2:
If (current_open_price>gann) And { if (last_close_price>gann) And If (last_open_price<=gan)
=> buy at current_open_price
Sell Condition 1:
If (current_open_price<gann) And { if (last_close_price>=gann)
=> sell at current_open_price
Sell Condition 2:
If (current_open_price<gann) And { if (last_close_price<gann) And If (last_open_price>=gan)
=> sell at current_open_price