EA Trading multiple charts - imponderable! returns data at wrong time..

 

Ok this EA has been running for about 6 months. Just thought I would check a funny sell order, and this is what I found.

The Trace line printed 3 different time event series on the same line! 

1. My trace showed IMA moving averages of USDJPY  showing at yellow line on chart.(115.994 ma3)  (115.966 ma2) (116.113 ma1) ie MA shift 1,2,3

    So it found these oK when I looked on bar 0(I assume time 2017.01.06 16:00).

2. Trace printed on same line the "ask" price showing on chart at red line (117.441)  Now this is 17 1hr bars away (3 days) from the Moving averages!! which on 2017.01.06 16:00 should be 116.570

3. Trace printed on same line the time of 2017.01.09 16:29:09.945 showing as green line on chart.(3 days later)

Now how can 3 different time sequence events print on the same trace line? 

This is no fraud or thought up event. It is absolutely baffling.

 

[ next is the actual trace line from experts tag: It prints immediately after the MA's are discovered.(should be 01.06 16:00 not 01.09 16:29)

 2017.01.09 16:29:09.945 PriceAction3 EURUSD,H4: symbol=USDJPY agro up. risk=1.525 sl=115.916 tp=120.491 redhma3=115.944 bluehma2=115.966 redhma1=116.113 ask=117.441 currtradepair=buy

 2017.01.09 16:29:10.493 opened buy trade at ask price 117.441]

 

Because the ea runs on only EURUSD it use 3 pips before swapping to check next chart. Now next symbol has not actually been setup as a chart,

but I can still run IMA(USDJPY,Period-H1,,,1) on it to get results as above. 

I cant set Autoscroll on which is what I think might be causing the problem - because there is no chart displayed .

I have tried RefreshRates() but I think this only refreshes the chart the ea is running on (EURUSD) and cannot be pointed to another chartsymbol.

I repeat my problem;  How can 3 different time sequence events print on the same trace line? 

Any thoughts on this please? 

MetaTrader Trading Platform Screenshots

USDJPY, H1, 2017.01.11

Synergy Financial Markets Pty Ltd., MetaTrader 4, Real

USDJPY, H1, 2017.01.11, Synergy Financial Markets Pty Ltd., MetaTrader 4, Real


 
MQL5.royc:

Because the ea runs on only EURUSD it use 3 pips before swapping to check next chart. Now next symbol has not actually been setup as a chart,

but I can still run IMA(USDJPY,Period-H1,,,1) on it to get results as above. 

I cant set Autoscroll on which is what I think might be causing the problem - because there is no chart displayed .

I have tried RefreshRates() but I think this only refreshes the chart the ea is running on (EURUSD) and cannot be pointed to another chartsymbol.

I repeat my problem;  How can 3 different time sequence events print on the same trace line?

  1. There are no mind readers here. We can't see your broken code.
  2. Of course you can
  3. Autoscroll is irrelevant, EA's have no eyes.
  4. Perhaps you should read the manual. RefreshRates only updates predefine variables.
  5. There are no mind readers here. We can't see your broken code.
  6. This is why I recommend
    Do not trade multiple currencies in one EA
 
whroeder1:
  1. There are no mind readers here. We can't see your broken code.
  2. Of course you can
  3. Autoscroll is irrelevant, EA's have no eyes.
  4. Perhaps you should read the manual. RefreshRates only updates predefine variables.
  5. There are no mind readers here. We can't see your broken code.
  6. This is why I recommend

Thanks so much for applying your time to reply.

I think you may have given me the key to use ibarshift.

One point about Autoscroll is that its not relevant to the EA BUT may still keep the history platform showing from the last tick bar. 

Sorry for no code to check, so here it is.

[   // Has MA crossed with large slope
   REDHMA1=iMA(chartsymbol,PERIOD_H1,8,0,MODE_EMA,PRICE_CLOSE,1); // 0 MA shift, 1 bar shift
   REDHMA1=NormalizeDouble(REDHMA1,vdigits);
   REDHMA3=iMA(chartsymbol,PERIOD_H1,8,0,MODE_EMA,PRICE_CLOSE,3); // 0 MA shift, 3 bar shift
   REDHMA3=NormalizeDouble(REDHMA3,vdigits);
   BLUEHMA2=iMA(chartsymbol,PERIOD_H1,MA,0,MODE_EMA,PRICE_CLOSE,2); // 0 MA shift, 2 bar shift
   BLUEHMA2=NormalizeDouble(BLUEHMA2,vdigits);
   // determine if red crossing blueMA  
   if(REDHMA3<BLUEHMA2 && REDHMA1>BLUEHMA2 && Htrend=="up")     // red cross blue up and up trend  
     {
     vask=MarketInfo(chartsymbol,MODE_ASK);
     risk=vask-BLUEHMA2+(5*PipsInPoint*vpoint); // place risk below blue MA
     if(risk>maxslpips){return;}
     goagro=1;    
     slnorm=NormalizeDouble(vask-risk,digit1);
     tpnorm=vask+(2*risk);  // MSL should lock in BE
     if(traceinjournal==1) {Print("Timecurrent=",TimeToStr(TimeCurrent()),"symbol=",chartsymbol," agro up. MA=",MA," risk=",risk," sl=",slnorm," tp=",tpnorm," redhma3=",REDHMA3," bluehma2=",BLUEHMA2," redhma1=",REDHMA1," ask=",vask," currtradepair=",currenttradepair[ci] );}
     }

]

I have since added the time string to prove program time against log time.

I will try this following code before I change the periods of each IMA call, because I am flipping between H1 and H4 periods.

[ barno=ibarshift(chartsymbol,PERIOD_H1,TimeCurrent(),false);]

This should always return bar 0.  but may do something else!!

Then I can leave the IMA's as they are, because they were working anyway. (at time 1.06 16:00)

It still does not explain why vask (MarketInfo of ask) shows the price as 17 bars in front of Bar 0.

 

Forum on trading, automated trading systems and testing trading strategies

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


 
Alain Verleyen:

Thanks so much for fixing my code. Been at this for 20 years but still learning.

I also wanted to link to this post from my profile. Just pressed the user man above, does this do it? my link somehow disappeared!