A little help? - page 3

 
deVries:

Place a SMA with same settings to the chart of your EA and see what you have done ...

doing so and I'm at the point:

SMA6(with shift)>SMA21 => Buy order, code is printing SMA6(with shift)=0 therefore SMA6(ws)<SMA21 and thus selling?

 
j.w.msb:

doing so and I'm at the point:

SMA6(with shift)>SMA21 => Buy order, code is printing SMA6(with shift)=0 therefore SMA6(ws)<SMA21 and thus selling?



SMA6(with shift -3 )>SMA21 is this ever gonna be happening at bar 0

take a picture of your chart and show me if this ever happens ??

what also will help is Data Window (Ctrl + D) move your mousepointer over the chart and check the values

 

https://www.mql5.com/en/charts/926555/eurusd-m1-easy-forex

Like here? the shift has already been applied and SMA6<SMA21 (though I have a feeling Im being incredibly dense ...) Forgive me for being slow, but at any given moment Im comparing the immediate SMA21 with the SMA6 from 3 Bars ago isnt it? I see no reason why they cant cross :s

 
j.w.msb:

https://www.mql5.com/en/charts/926555/eurusd-m1-easy-forex

Like here? the shift has already been applied and SMA6<SMA21 (though I have a feeling Im being incredibly dense ...) Forgive me for being slow, but at any given moment Im comparing the immediate SMA21 with the SMA6 from 3 Bars ago isnt it? I see no reason why they cant cross :s


no that is a picture where you have the bartime 13:00 and there are more then 3 bars come with later time

so take a picture as example where we see the last formed bar no bar coming after it

with the moving averages on the chart like you coded in your EA and hold your mouse pointing last bar

 

... my shift was in the wrong position wasnt it ... so iMA(Symbol(),0,6,0,MODE_SMA,PRICE_CLOSE,-3) is what I was aiming for? and no, I was being silly, they cant cross at bar 0 simply because SMA6 is 3 bars behind so how do I use it?

 
j.w.msb:

... my shift was in the wrong position wasnt it ... so iMA(Symbol(),0,6,0,MODE_SMA,PRICE_CLOSE,-3) is what I was aiming for? and no, I was being silly, they cant cross at bar 0 simply because SMA6 is 3 bars behind so how do I use it?


double SMA6=iMA(Symbol(),0,6,-3,MODE_SMA,PRICE_CLOSE,0);       //ma_shift

means ma is shifted 3 bars left (to the past) no value at bar 0 and it will never be

 iMA(Symbol(),0,6,0,MODE_SMA,PRICE_CLOSE,-3)     //shift

also you will see no bar with negative number we can't know what in future happens

so don't calculate negative ma_shift and don't use negative barnumbers

 

make SMA6 = iMA(Symbol(),0,6,0,MODE_SMA,PRICE_CLOSE,0) for now

do a test with strategytester and place it also on a demoaccount with a low period to have it trade often M5 is good enough for testing

look terminal experts and journal to see if errors appear (they will)

i don't tell now which i see already coming you learn the most this way

see your next posting....

 

Running on a 5 minute time frame with:

//-----Indicators on the current timeframe----------------------------+
double SMA6=iMA(Symbol(),0,6,0,MODE_SMA,PRICE_CLOSE,0);
Print("SMA6 is ",SMA6);
double SMA21=iMA(Symbol(),0,21,0,MODE_SMA,PRICE_CLOSE,0);
Print("SMA21 is ",SMA21);                                    
//----Indicators on a higher timeframe--------------------------------+
double RSI=iRSI(Symbol(),1440,14,PRICE_CLOSE,0);
Print("RSI is ",RSI);                                                                   
//----Indicators on a lower timeframe---------------------------------+

Runs perfectly fine, and trades as expected with no worries

2013.10.24 14:52:33 2013.09.10 20:10 SMATrader1-1-0 GBPJPY,M5: close #5 sell 0.07 GBPJPY at 157.797 sl: 159.797 at price 157.909
2013.10.24 14:52:33 2013.09.10 20:15 SMATrader1-1-0 GBPJPY,M5: SMA6 is 157.809
2013.10.24 14:52:33 2013.09.10 20:15 SMATrader1-1-0 GBPJPY,M5: SMA21 is 157.8063
2013.10.24 14:52:33 2013.09.10 20:15 SMATrader1-1-0 GBPJPY,M5: RSI is 69.3519
2013.10.24 14:52:33 2013.09.10 20:15 SMATrader1-1-0 GBPJPY,M5: open #6 buy 0.07 GBPJPY at 157.893 sl: 155.893 ok

etc

I cant see any errors?

 
j.w.msb:

Running on a 5 minute time frame with:

Runs perfectly fine, and trades as expected with no worries

2013.10.24 14:52:33 2013.09.10 20:10 SMATrader1-1-0 GBPJPY,M5: close #5 sell 0.07 GBPJPY at 157.797 sl: 159.797 at price 157.909
2013.10.24 14:52:33 2013.09.10 20:15 SMATrader1-1-0 GBPJPY,M5: SMA6 is 157.809
2013.10.24 14:52:33 2013.09.10 20:15 SMATrader1-1-0 GBPJPY,M5: SMA21 is 157.8063
2013.10.24 14:52:33 2013.09.10 20:15 SMATrader1-1-0 GBPJPY,M5: RSI is 69.3519
2013.10.24 14:52:33 2013.09.10 20:15 SMATrader1-1-0 GBPJPY,M5: open #6 buy 0.07 GBPJPY at 157.893 sl: 155.893 ok

etc

I cant see any errors?

You log is going to get very big if you take a lot of trades . . . especially in the Strategy Tester, don't remove the debugging Prints, turn them on and off using a scheme such as the one I use.
 
//-----Indicators on the current timeframe----------------------------+
double SMA6=iMA(Symbol(),0,6,0,MODE_SMA,PRICE_CLOSE,0);
//Print("SMA6 is ",SMA6);
double SMA21=iMA(Symbol(),0,21,0,MODE_SMA,PRICE_CLOSE,0);
//Print("SMA21 is ",SMA21);                                    
//----Indicators on a higher timeframe--------------------------------+
double RSI=iRSI(Symbol(),1440,14,PRICE_CLOSE,0);
//Print("RSI is ",RSI);                                                                   
//----Indicators on a lower timeframe---------------------------------+

you have seen here are no errors you don't need the printstatements here

in strategytester your program might work well,

but how is it doing running on your demoaccount ??

Reason: