The code you have shown does not take any trades . . . I see no OrderSend . . .
Yeah, I haven't included that code ... its there:)
There are two possibilities - one that the MA crosses first then the MACD crosses, or vice versa - the for loop here:
for(int q = SellCross; q < SellCross + 10; q++) { SellMain.B = iCustom(NULL,0,"MACD True",21,55,8,0,q); SellSignal.B = iCustom(NULL,0,"MACD True",21,55,8,1,q); if(SellMain.B > SellSignal.B) MACDvalid++; } if(MACDvalid >= 8) SellOne.B = true;
This is to test that the MACD lines before the crossover haven't touched.
Any thoughts?
Hello,
My guessing is, BuyCross variable has a wrong init value, or holds an old value.
The next for cycle is starting from here, but if it holds an old value or 0, the cycle will check interval starting from that. And if checking of this wrong interval is ok, it will buy.
Hi, BuyCross and SellCross are both initialized at the start() cycle with a value of 0, so every time the program runs, they are set back to zero. MACDvalid is also initialized as = 0.
Any thoughts?
Hi, BuyCross and SellCross are both initialized at the start() cycle with a value of 0, so every time the program runs, they are set back to zero. MACDvalid is also initialized as = 0.
Any thoughts?
If the BuyCross remains 0, becauose the
if(BuyMain.B > BuySignal.B && BuyMain1.B < BuySignal1.B){BuyCross = y+1; break;}
condition not true (there is no MACD crossing), the next for cycle starts checking from 0, without MACD being crossed.
Try to use an additional if for checking value of BuyCross, before run the MACDvalid checking:
if (BuyCross > 0) { for(int p = BuyCross; p < BuyCross + 10; p++) { BuyMain.B = iCustom(NULL,0,"MACD True",21,55,8,0,p); BuySignal.B = iCustom(NULL,0,"MACD True",21,55,8,1,p); if(BuyMain.B < BuySignal.B) MACDvalid++; } } if(MACDvalid >= 8) BuyOne.B = true;
If the BuyCross remains 0, becauose the
condition not true (there is no MACD crossing), the next for cycle starts checking from 0, without MACD being crossed.
Try to use an additional if for checking value of BuyCross, before run the MACDvalid checking:
Thanks, that fixed the problem! :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
The idea behind the EA is that the price should cross EA and MACD lines should cross in the same direction to place a trade. The code I am using is attached below. For some reason, strategy tester takes trades even when the MACD is not properly aligned(screenshot attached). Any clues? Thanks