no one know where is the problem?
what exactly is your problem?
i try to calculae simple ma from tick data but when i use the code above i not calculate the ma but the result of array matk is a number like 1256845 or -8524587 4587 458884 or similar
Not sure about what you meant by problem on your codes or what result you want from it... but consider the following below:
// >>>> Assuming with the following value to simulate running your code...
int maperiod=10; double Bid=1.00001; int contotick=0; int run=0; // >>>>> Tick run count, just to trace the values at a specific tick. double tk[], matk[]; /// buffer tick int dimtk = maperiod+5; //-------------- void tick() { run++; // >>>>> count of every tick. contotick++; //contotick =0 in the init function shifttick(); } //--------------- void shifttick() // shiftick { int setdim=dimtk+1; // add 1 memory ArraySetAsSeries(tk, false); // >>>>> ? ArraySetAsSeries(matk, false); // >>>>> ? ArrayResize(tk,setdim); ArrayResize(matk, setdim); ArraySetAsSeries(tk, true); ArraySetAsSeries(matk, true); tickcollect(); ArrayResize(tk,dimtk); // restore the memory -1 ArrayResize(matk, dimtk); return; } void tickcollect() { double sum; tk[0]=Bid; if (contotick==1) sum=0; sum+=tk[0]; Print("TickRun(",run,") "," contotick: ",contotick," maperiod =",maperiod," sum= ",sum," tk=",tk[0]," matk[0]= ",matk[0]); if (contotick>=maperiod) { matk[0]= sum/maperiod; sum-= tk[maperiod-1]; Print("TickRun(",run," ) Where contotick>=maperiod:"," contotick: ",contotick," maperiod =",maperiod," sum= ",sum," tk=",tk[0]," matk[0]= ",matk[0]); } return; }
Result I got:
Double check the values you're passing down to Bid and maperiod...
... and you may also try re-coding using "technical indicator function" where you can just collect directly the value of the simple moving average.
... just my two cents, hope it helps :)
thanks soo much my problem was : i want to calculate the movin avarage from tick , and i write this code to put an ea and calculate ma tick the first time i put on ea when i ask : comment ( matk[0] or matk[1]) on the chart it print value like -587412236 1548965 32154987 esample
andit did not calulate the ma tick .
so i ask for your help to understand where is the mistake .
but last day i was trying another part of the expert where there are the code above and i dont know way but know the code is ok
some day's ago the code not work also in a demo account
now the code go
thanks for your replay anyway
best regards
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
but when i ask for matk with comment () example ====> matk[0]= 111125448 or -2478556526 ,
seem there are some problem in calculation ma tick but where is the problem