How to set a "-5" in MA shift? - page 2

 
6578466543:

Hello,


What SRC button? I use the german version of Meta Editor, i also turned it to english but what SRC button?

This one: How to use the SRC button.
 
6578466543:


A friend had the same problem that the moving average shift to -5 didn´t work. He got a update from the broker to his account so it work now. So i don´t know if i have the same problem here.

How can i use the shift to -5 so that it will work and the EA makes trades?

Did you try this ? or are you just trying to waste people's time ?

I suggest you do this and then you will understand what is going on:

Add 2 MAs to any chart, just the standard Moving Average indicator, add one with a MA shift of 0 and one with a MA shift of -5, the use the Data Window (Ctrl + D) and look at bars to the left of bar 10 by placing your mouse pointer on the bar and looking at the Data Window, you will see two values, one for each of the 2 MAs, now look at bars 0 to 4 . . . you will see only one value, the other MA does not have a value.

 
6578466543:

Hello,


thanks for you answers.



What SRC button? I use the german version of Meta Editor, i also turned it to english but what SRC button?


A friend had the same problem that the moving average shift to -5 didn´t work. He got a update from the broker to his account so it work now. So i don´t know if i have the same problem here.


How can i use the shift to -5 so that it will work and the EA makes trades?


Thanks.

Why not leave the MA at shift zero and set the other MA at shift 5?
 
6578466543: What SRC button? I use the german version of Meta Editor, i also turned it to english but what SRC button?
It's not the EDITOR. It's in THIS FORUM

Play video
Please edit your post.
For large amounts of code, attach it.
 
6578466543:

Hello Raptor,



thanks for your answer. English isn´t my motherlanguage so it´s a bit heavy for me.


I use 2 moving averages on different periodes to see a trend. What i like to do is, shift the faster ma -5 backwards. The problem on the 2 moving averages is, that they are very slow. So if they reach a "cross" the price i have to pay is higher or lower. So i like to get a better price by shifting it back. It looks great with the -5 in a chart. I can set the MA1_Shift=-5, but if i try it in the strategy tester it doesen´t make even 1 trade. So i don´t know where the problem is.




You've been answered a few times, but you seem to be unable to comprehend.

Yes, shifting the MA backwards will look great on the chart, sometimes it will seem to be uncannily accurate at predicting moves.

But of course it is not predicting because the MA is calculating on future data compared to its position on the chart.

Look at the 2 charts and you will see where I have marked the shifted MA cross with an arrow

present

The 2nd chart shows what MA data was available at the time of the cross.

As you can see, because of the shift backwards, at that time, there was no cross, because the MA cannot work with data from candles that, at that time, would be in the future.

That is why your EA will not work with the shift backwards

past

 
//============================================================================================
//
//
//
//
//
//============================================================================================
extern int    MA1_Period=3;                              // Ïåðèîä 1-é ÌÀ
extern int    MA2_Period=13;                             // Ïåðèîä 2-é ÌÀ
extern int    MA1_Method=0;                              // Ìåòîä âû÷èñëåíèÿ ÌÀ1 (SMA=0,EMA=1,SMMA=2,LWMA=3)
extern int    MA2_Method=3;                              // Ìåòîä âû÷èñëåíèÿ ÌÀ2 (SMA=0,EMA=1,SMMA=2,LWMA=3)
extern int    MA1_Price=0;                               // Ìåòîä âû÷èñëåíèÿ öåíû ÌÀ1 
extern int    MA2_Price=4;                               // Ìåòîä âû÷èñëåíèÿ öåíû ÌÀ2
extern int    MA1_Shift=0;                               // Âðåìåííîé ñäâèã ÌÀ1
extern int    MA2_Shift=0;                               // Âðåìåííîé ñäâèã ÌÀ2
extern double Lot = 0.1;                                 // Ôèêñèðîâàííûé ëîò
extern int    slippage = 0;                              // Îòêëîíåíèå öåíû äëÿ ðûíî÷íûõ îðäåðîâ 
int New_Bar;                                             // 0/1 Ôàêò îáðàçîâàíèÿ íîâîãî áàðà
int Time_0;                                              // Âðåìÿ íà÷àëà íîâîãî áàðà
int PosOpen;                                             // Íàïðàâëåíèå ïåðåñå÷åíèÿ
int PosClose;                                            // Íàïðàâëåíèå ïåðåñå÷åíèÿ
int total;                                               // Êîëè÷åñòâî îòêðûòûõ îðäåðîâ
double MA1_0;                                            // Òåêóùåå çíà÷åíèå 1-é ÌÀ (ðîçîâ)
double MA1_1;                                            // Ïðåäûäóùåå çíà÷åíèå 1-é ÌÀ (ðîçîâ)
double MA2_0;                                            // Òåêóùåå çíà÷åíèå 2-é ÌÀ (ãîëóáàÿ)
double MA2_1;                                            // Ïðåäûäóùåå çíà÷åíèå 2-é ÌÀ (ãîëóáàÿ)
int orderBuy;                                            // 1 = ôàêò íàëèèÿ îðäåðà Buy
int orderSell;                                           // 1 = ôàêò íàëèèÿ îðäåðà Sell 
//============================================================================================
int init()  
   {

   }  
//============================================================================================
int start()  
   {
   orderBuy=0;
   orderSell=0; 
   double price;  
   int openOrders=0;
   int total=OrdersTotal();                                  // Îáùåå êîëè÷åñòâî îðäåðîâ
   for(int i=total-1;i>=0;i--)
      {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)     // Âûáèðàåì îðäåð
         {
         if(OrderType()==OP_BUY)                             // Åñëè ñòîèò îðäåð íà ïîêóïêó
            {
            orderBuy=1;
            if(CrossPositionClose()==1)                      // Çàêðûâåì îðäåð, åñëè óäîâëåòâîðÿåò
               {                                             // óñëîâèþ CrossPositionClose()=1
               price=MarketInfo(Symbol(),MODE_BID);
               OrderClose(OrderTicket(),OrderLots(),price,slippage,CLR_NONE);
               }
            }
         if(OrderType()==OP_SELL)                            // Åñëè ñòîèò îðäåð íà ïîêóïêó
            {
            orderSell=1;
            if(CrossPositionClose()==2)                      // Çàêðûâåì îðäåð, åñëè óäîâëåòâîðÿåò
               {                                             // óñëîâèþ CrossPositionClose()=2
               price=MarketInfo(Symbol(),MODE_ASK);
               OrderClose(OrderTicket(),OrderLots(),price,slippage,CLR_NONE);
               }
            }
         }
      }
   
   New_Bar=0;                                                // Äëÿ íà÷àëà îáíóëèìñÿ
   if (Time_0 != Time[0])                                    // Åñëè óæå äðóãîå âðåìÿ íà÷àëà áàðà
      {
      New_Bar= 1;                                            // À âîò è íîâûé áàð
      Time_0 = Time[0];                                      // Çàïîìíèì âðåìÿ íà÷àëà íîâîãî áàðà
      } 
   
   MA1_0=iMA(NULL,0, MA1_Period, MA1_Shift,MAMethod(MA1_Method), MAPrice(MA1_Price), 0);    // Òåêóùåå    çíà÷åíèå 1-é ÌÀ
   MA1_1=iMA(NULL,0, MA1_Period, MA1_Shift,MAMethod(MA1_Method), MAPrice(MA1_Price), 1);    // Ïðåäûäóùåå çíà÷åíèå 1-é ÌÀ
   MA2_0=iMA(NULL,0, MA2_Period, MA2_Shift,MAMethod(MA2_Method), MAPrice(MA2_Price), 0);    // Òåêóùåå    çíà÷åíèå 2-é ÌÀ
   MA2_1=iMA(NULL,0, MA2_Period, MA2_Shift,MAMethod(MA2_Method), MAPrice(MA2_Price), 1);    // Ïðåäûäóùåå çíà÷åíèå 2-é ÌÀ
   
   if (CrossPositionOpen()==1 && New_Bar==1)                 // Äâèæåíèå ñíèçó ââåðõ = îòêð. Buy
      {
      OpenBuy();
      }      
   if (CrossPositionOpen()==2 && New_Bar==1)                 // Äâèæåíèå ñâåðõó âíèç = îòêð. Sell
      {
      OpenSell();
      }    
   return;
   }  
//============================================================================================
int CrossPositionOpen()
   {
   PosOpen=0;                                                 // Âîò ãäå ñîáàêà çàðûòà!!:)
   if ((MA1_1<=MA2_0 && MA1_0>MA2_0) || (MA1_1<MA2_0 && MA1_0>=MA2_0))   // Ïåðåñå÷åíèå ñíèçó ââåðõ  
      {
      PosOpen=1;
      }                  
   if ((MA1_1>=MA2_0 && MA1_0<MA2_0) || (MA1_1>MA2_0 && MA1_0<=MA2_0))   // Ïåðåñå÷åíèå ñâåðõó âíèç
      {
      PosOpen=2;
      }             
   return(PosOpen);                                          // Âîçâðàùàåì íàïðàâëåíèå ïåðåñå÷åí.
   }
//============================================================================================
int CrossPositionClose()
   {
   PosClose=0;                                                // Âîò ãäå ñîáàêà çàðûòà!!:)
   if ((MA1_1>=MA2_0 && MA1_0<MA2_0) || (MA1_1>MA2_0 && MA1_0<=MA2_0))   // Ïåðåñå÷åíèå ñâåðõó âíèç        {
      {
      PosClose=1;
      }                  
   if ((MA1_1<=MA2_0 && MA1_0>MA2_0) || (MA1_1<MA2_0 && MA1_0>=MA2_0))   // Ïåðåñå÷åíèå ñíèçó ââåðõ
      {
      PosClose=2;
      }             
   return(PosClose);                                          // Âîçâðàùàåì íàïðàâëåíèå ïåðåñå÷åí.
   }
//============================================================================================
int OpenBuy() 
   {
   if (total==1)
      {
      OrderSelect(0, SELECT_BY_POS,MODE_TRADES);              // Âûäåëèì îðäåð
      if (OrderType()==OP_BUY) return;                        // Åñëè îí buy, òî íå îòêðûâàåìñÿ
      }
   OrderSend(Symbol(),OP_BUY, Lot, Ask, slippage, 0, 0, "Buy: MA_cross_Method_PriceMode", 1, 0, CLR_NONE);// Îòêðûâàåìñÿ
   return;
   }
//============================================================================================
int OpenSell() 
   {
   if (total==1)
      {
      OrderSelect(0, SELECT_BY_POS,MODE_TRADES);              // Âûäåëèì îðäåð
      if (OrderType()==OP_SELL) return;                       // Åñëè îí sell, òî íå îòêðûâàåìñÿ
      }
   OrderSend(Symbol(),OP_SELL, Lot, Bid, slippage, 0, 0, "Sell: MA_cross_Method_PriceMode", 2, 0, CLR_NONE);
   return;
   }
//============================================================================================
int MAMethod(int MA_Method)
   {
      switch(MA_Method)
        {
         case 0: return(0);                                   // Âîçâðàùàåò MODE_SMA=0
         case 1: return(1);                                   // Âîçâðàùàåò MODE_EMA=1
         case 2: return(2);                                   // Âîçâðàùàåò MODE_SMMA=2
         case 3: return(3);                                   // Âîçâðàùàåò MODE_LWMA=3
        }
   }
//============================================================================================
int MAPrice(int MA_Price)
   {
      switch(MA_Price)
        {
         case 0: return(PRICE_CLOSE);                         // Âîçâðàùàåò PRICE_CLOSE=0        
         case 1: return(PRICE_OPEN);                          // Âîçâðàùàåò PRICE_OPEN=1
         case 2: return(PRICE_HIGH);                          // Âîçâðàùàåò PRICE_HIGH=2
         case 3: return(PRICE_LOW);                           // Âîçâðàùàåò PRICE_LOW=3
         case 4: return(PRICE_MEDIAN);                        // Âîçâðàùàåò PRICE_MEDIAN=4
         case 5: return(PRICE_TYPICAL);                       // Âîçâðàùàåò PRICE_TYPICAL=5
         case 6: return(PRICE_WEIGHTED);                      // Âîçâðàùàåò PRICE_WEIGHTED=6
        }
   }
//============================================================================================

Thank you,



ah ok, now with the SRC button.


Shift the other MA to +5 does not make the same results, because it is much slower.

Ok that update from my friend was just a normal account update, so the problem must be somewhere in the code. Can anyone please help me?



or are you just trying to waste people's time ?


Yes i know what the shift does, the whole time i´m trading with 2 MA´s and the "faster" one is shift to -5 but i like, that a EA is doing this for me.

My friends EA work with the shift to -5 from the "faster" MA.


Thanks for you help!!!

 
6578466543: or are you just trying to waste people's time ?
You are the one wasting our time. I already told you "It won't change the lag at all."
 

I think that your friend's EA is not exactly the same code as yours.

Add some print commands to print the value of the shifted MA and you will see what the problem is.

 
GumRai:

I think that your friend's EA is not exactly the same code as yours.


Hello,




yes this is right. He payed for his EA a lot of money. A professional programmer made it for him. I thought it should be possible to make the -5 shift running on the EA without paying for it. Otherwise i will pay for it to only get the code for the shift for my EA.

 
6578466543:

Hello,




yes this is right. He payed for his EA a lot of money. A professional programmer made it for him. I thought it should be possible to make the -5 shift running on the EA without paying for it. Otherwise i will pay for it to only get the code for the shift for my EA.

Then the shift on your friend's EA applies to something else.

The way you want it requires that calculations are made with data from the future and this is impossible.

Look at this indicator. It is uncannily 100% accurate and tells you the exact closing price of the 5th following bar.

Wow, I will be a millionaire in no time with this :)

Simply buy when the indicator is way above the price and sell when it is well below. Target is the value of the indicator. You will see that the target is hit every single time and zero losses.

So how much would you be willing to pay me for this 100% accurate indicator?

$100?

$1,000?

$100,000?

The big institutions would be willing to pay me millions for this,

but special offer, just for today,

You can get it for,,,,,,,

wait for it......

You won't believe this......


into the future

Today only.....with a 60 day moneyback guarantee......

..........$0

Just put a 1 period SMA with Close and a -5 shift.


Sorry, I couldn't resist the joke :)

If you don't understand now, then you never will.