Kittamet Sirinyamas: I want to use moving average’value of 10-50 period,Does I need to declare 40 buffers and 40 handles?
- There are forty-one (41) values between [10 … 50]. You need to remember 41 handles.
- Only if you need to access more than one MA at a time. Otherwise, just reuse one buffer.
William Roeder:
- There are forty-one (41) values between [10 … 50]. You need to remember 41 handles.
- Only if you need to access more than one MA at a time. Otherwise, just reuse one buffer.
I appreciate your help. As I remember, To get indicator's value,It doesnot need to declare the handle at onit() in MT4?
So why does mt5 has to?
hello, I am trying to create an expert advisor based on ichimoku. my code worked when i only used tenkansen and kijunsen, but since adding the chikouspan, SSA and SSB it doesn't work anymore, i really need help, thanks. here is my code:
//+------------------------------------------------------------------+ //| Knowledge.mq5 | //| Copyright 2021, Huau Martin | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021, Huau Martin" #property link "https://www.mql5.com" #property version "1.00" // on importe un module pour prendre des positions #include<Trade\Trade.mqh> CTrade trade; //+------------------------------------------------------------------+ //| Des que le robot est initialisé (utilisée une fois) | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Des que le robot n'est plus en service (utilisée une fois) | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Des que on a un nouveau tick | //+------------------------------------------------------------------+ void OnTick() { //--- attribition des caractéristiques bool Buy_opened=false; // variable to hold the result of Buy opened position bool Sell_opened=false; // variable to hold the result of Sell opened position if (PositionSelect(_Symbol) ==true) // we have an opened position { if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) { Buy_opened = true; //It is a Buy } else if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) { Sell_opened = true; // It is a Sell } } //+------------------------------------------------------------------+ //|Ouverture position achat | //+------------------------------------------------------------------+ if (PositionsTotal()<1 && testerSignalAchat() == true) { trade.Buy(0.5); } if (testerClotureAchat() == true && Buy_opened == true) { trade.PositionClose(Symbol()); } //+------------------------------------------------------------------+ //|Ouverture position vente | //+------------------------------------------------------------------+ if (PositionsTotal()<1 && testerSignalVente() == true) { trade.Sell(0.5); } if (testerClotureVente() == true && Sell_opened == true) { trade.PositionClose(Symbol()); } } //+------------------------------------------------------------------+ //| Fonction de test de signal d'achat | //+------------------------------------------------------------------+ bool testerSignalAchat() { MqlRates prix[25]; int nbreBougies = CopyRates(_Symbol,_Period,0,25,prix); if(nbreBougies!=25) { return false; } //+------------------------------------------------------------------+ //| On récupéeres les données de la kijunsen | //+------------------------------------------------------------------+ double KijunsenArray[]; int IchimokuDefinition1 =iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(KijunsenArray,true); CopyBuffer(IchimokuDefinition1,1,0,3,KijunsenArray); double KijunsenValue=KijunsenArray[1]; //+------------------------------------------------------------------+ //| On récupéeres les données de la tenkansen | //+------------------------------------------------------------------+ double TenkansenArray[]; int IchimokuDefinition0 =iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(TenkansenArray,true); CopyBuffer(IchimokuDefinition0,1,0,3,TenkansenArray); double TenkansenValue=TenkansenArray[0]; //+------------------------------------------------------------------+ //| On récupéeres les données de la Chikou | //+------------------------------------------------------------------+ double ChikouArray[]; int IchimokuDefinition2 =iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(ChikouArray,true); CopyBuffer(IchimokuDefinition2,1,0,3,ChikouArray); double ChikouValue=ChikouArray[4]; //+------------------------------------------------------------------+ //| On récupéeres les données de la SSA | //+------------------------------------------------------------------+ double SSAArray[]; int IchimokuDefinition3=iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(SSAArray,true); CopyBuffer(IchimokuDefinition3,1,0,3,SSAArray); double SSAValue=SSAArray[2]; //+------------------------------------------------------------------+ //| On récupéeres les données de la SSB | //+------------------------------------------------------------------+ double SSBArray[]; int IchimokuDefinition4=iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(SSBArray,true); CopyBuffer(IchimokuDefinition4,1,0,3,SSBArray); double SSBValue=SSBArray[3]; //+------------------------------------------------------------------+ //| verification des conditions | //+------------------------------------------------------------------+ //on ne travaille pas sur la bougie en cour mais la précédente if(prix[23].close>KijunsenValue && SSAValue>SSBValue && ChikouValue>prix[0].close) { return true; } return false; } //+------------------------------------------------------------------+ //| Fonction de test de signal de vente | //+------------------------------------------------------------------+ bool testerSignalVente() { MqlRates prix[25]; int nbreBougies = CopyRates(_Symbol,_Period,0,25,prix); if(nbreBougies!=25) { return false; } //+------------------------------------------------------------------+ //| On récupéeres les données de la kijunsen | //+------------------------------------------------------------------+ double KijunsenArray[]; int IchimokuDefinition1 =iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(KijunsenArray,true); CopyBuffer(IchimokuDefinition1,1,0,3,KijunsenArray); double KijunsenValue=KijunsenArray[1]; //+------------------------------------------------------------------+ //| On récupéeres les données de la tenkansen | //+------------------------------------------------------------------+ double TenkansenArray[]; int IchimokuDefinition0 =iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(TenkansenArray,true); CopyBuffer(IchimokuDefinition0,1,0,3,TenkansenArray); double TenkansenValue=TenkansenArray[0]; //+------------------------------------------------------------------+ //| On récupéeres les données de la Chikou | //+------------------------------------------------------------------+ double ChikouArray[]; int IchimokuDefinition2 =iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(ChikouArray,true); CopyBuffer(IchimokuDefinition2,1,0,3,ChikouArray); double ChikouValue=ChikouArray[4]; //+------------------------------------------------------------------+ //| On récupéeres les données de la SSA | //+------------------------------------------------------------------+ double SSAArray[]; int IchimokuDefinition3=iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(SSAArray,true); CopyBuffer(IchimokuDefinition3,1,0,3,SSAArray); double SSAValue=SSAArray[2]; //+------------------------------------------------------------------+ //| On récupéeres les données de la SSB | //+------------------------------------------------------------------+ double SSBArray[]; int IchimokuDefinition4=iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(SSBArray,true); CopyBuffer(IchimokuDefinition4,1,0,3,SSBArray); double SSBValue=SSBArray[3]; //on ne travaille pas sur la bougie en court mais la précédente if(prix[23].close<KijunsenValue && SSAValue<SSBValue && ChikouValue<prix[0].close) { return true; } return false; } //+------------------------------------------------------------------+ //| Fonction de test de signal cloture d'achat | //+------------------------------------------------------------------+ bool testerClotureAchat() { MqlRates prix[25]; int nbreBougies = CopyRates(_Symbol,_Period,0,25,prix); if(nbreBougies!=25) { return false; } //+------------------------------------------------------------------+ //| On récupéeres les données de la kijunsen | //+------------------------------------------------------------------+ double KijunsenArray[]; int IchimokuDefinition1 =iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(KijunsenArray,true); CopyBuffer(IchimokuDefinition1,1,0,3,KijunsenArray); double KijunsenValue=KijunsenArray[1]; //+------------------------------------------------------------------+ //| verification des conditions | //+------------------------------------------------------------------+ //on ne travaille pas sur la bougie en court mais la précédente if(prix[23].close<KijunsenValue) { return true; } return false; } //+------------------------------------------------------------------+ //| Fonction de test de signal cloture d'achat | //+------------------------------------------------------------------+ bool testerClotureVente() { MqlRates prix[25]; int nbreBougies = CopyRates(_Symbol,_Period,0,25,prix); if(nbreBougies!=25) { return false; } //+------------------------------------------------------------------+ //| On récupéeres les données de la kijunsen | //+------------------------------------------------------------------+ double KijunsenArray[]; int IchimokuDefinition1 =iIchimoku(_Symbol,_Period,9,26,52); ArraySetAsSeries(KijunsenArray,true); CopyBuffer(IchimokuDefinition1,1,0,3,KijunsenArray); double KijunsenValue=KijunsenArray[1]; //+------------------------------------------------------------------+ //| verification des conditions | //+------------------------------------------------------------------+ //on ne travaille pas sur la bougie en court mais la précédente if(prix[23].close>KijunsenValue) { return true; } return false; }
Files:
AE_ichimoku.mq5
25 kb
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,experts
I doubt if we can change parameters of indicator during the ea/script is running?
as we know,we need to declare (ma_Period,symbol) them in Onit() firstly before using.
Let say I want to use moving average’value of 10-50 period,Does I need to declare 40 buffers and 40 handles?
thank you very much