int n=1; // Any other value >=1, indicating how many bars back the second price is. double MOMENTUM_now = Close (symbol[i], 0 ) / Close (symbol[i] , n) * 100 // it gets error: '-' - illegal operation double MOMENTUM_last = Close (symbol[i] , 1) / Close (symbol[i] , 1+n) * 100 if( MOMENTUM_last > MOMENTUM_now){ OpenFromMarket(symbol[i],ORDER_TYPE_SELL,GetLot(symbol[i]),Stop,Take); Sleep(3000); } double Close(string symb,int bar) { double cl[1]={0}; CopyClose(symb,Time_Frame,bar,1,cl); return(cl[0]); }
Thanks for the explanation. With the extra ';' it is working now.
Last edit:
This works best for me. It is with the sum from the momentum indicator:
int n_moment= 14; // Any other value >=1, indicating how many bars back the second price is, (this is the period value of from the momentum indicator) double MOMENTUM_last = Close(symbol[i], 1)*100 / Close (symbol[i], n_moment); double MOMENTUM_now = Close(symbol[i], 0 )*100 / Close(symbol[i], n_moment-1);

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
I want it to go short when 'last momentum > now momentum'. But how can i get the last momentum?
The momentum documentation:
Momentum is calculated as a ratio of today’s price to the price n periods ago:
MOMENTUM = CLOSE (i) / CLOSE (i - n) * 100
Where:
CLOSE (i) — close price of the current bar;
CLOSE (i - n) — close price n bars ago.
So i thought in my case:
Can someone help me in the right direction?