Price intersection

 

Hi, I'm trying to make a clean price intersection expert advisor with no success till now, I think the code is right but the backtester doesn't think the same.

These are the critical points:

- Opening candle price below the moving average and close price upwards for BUY:

   double BUYsignal=UPtrend&&Open[0]<FastMA&&Close[0]>FastMA;

- Opening candle price above the moving average and close price downwards for SELL:

   double SELLsignal=DOWNtrend&&Open[0]>FastMA&&Close[0]<FastMA;

If someone can help me to fix this issue would be great.

 
  1. To help you we would need more information, either more code or detailed, what you EA 'thinks' ion the tester!
  2. Faster for you would be if you let your EA show that it 'thinks' in the tester using Comment() and the Visual mode!
  3. There are really a lot of EAs that are trading that way - search for them and look how they do it. (I am repeating myself: Why trying to event the wheel while it is already available for free!)
    Look e.g. for an EA that uses the Alligator.
 
Carl Schreiber:
  1. To help you we would need more information, either more code or detailed, what you EA 'thinks' ion the tester!
  2. Faster for you would be if you let your EA show that it 'thinks' in the tester using Comment() and the Visual mode!
  3. There are really a lot of EAs that are trading that way - search for them and look how they do it. (I am repeating myself: Why trying to event the wheel while it is already available for free!)
  4. Look e.g. for an EA that uses the Alligator.

Check it out, it worths a million.

//----------------------------------------- internal variables ---!
   double UPtrend=Ask>iMA(NULL,0,SlowMAPeriod,0,MODE_LWMA,PRICE_CLOSE,0);
   double DOWNtrend=Bid<iMA(NULL,0,SlowMAPeriod,0,MODE_LWMA,PRICE_CLOSE,0);
   double FastMA=iMA(NULL,0,FastMAPeriod,0,MODE_SMMA,PRICE_CLOSE,0);
   int    BUYsignal=UPtrend&&Open[0]<FastMA&&Close[0]>FastMA;
   int    SELLsignal=DOWNtrend&&Open[0]>FastMA&&Close[0]<FastMA;
   int    TheTakeProfit=TakeProfit+MarketInfo(Symbol(),MODE_SPREAD);
   int    TheBreakPoint=BreakPoint+MarketInfo(Symbol(),MODE_SPREAD);
   int    cnt,ticket,slippage=3;

 
  1. As Ask > Bid it could happen that slowMa lays between Ask and Bid so you have at the same time an up and a down trend - is that you intention?
  2. For me your approach would be too unsafe if e.g. the fastMA == Open[0] and the Close[0] swings around the fastMA you'll get more signals than you want to have I guess
  3. I don't want to imagine what happens to your millions if 1. and 2. become true at the same time!
 
Carl Schreiber:
  1. As Ask > Bid it could happen that slowMa lays between Ask and Bid so you have at the same time an up and a down trend - is that you intention?
  2. For me your approach would be too unsafe if e.g. the fastMA == Open[0] and the Close[0] swings around the fastMA you'll get more signals than you want to have I guess
  3. I don't want to imagine what happens to your millions if 1. and 2. become true at the same time!
1. I had not noticed that possibility, however the signal would respond to the direction taken by the candle.

2.
It is evident that this need some layers of makeup, but it's just an example. So we can consider the following:

· int BUYsignal = UPtrend && Open [0] <= FastMA && Close [0]> FastMA;
· int SELLsignal = DOWNtrend && Open [0]>= FastMA && Close [0] <FastMA;


3. But we need this to work! I send you the file by private message and you take a look, do you agree?
Reason: