Attachments forums

List of attachments posted on this forum.


All files on forums: 163291

Re: Something interesting please post here (Metatrader)

mladen, Sun Dec 22, 2019 4:34 am

uncle wong wrote: Fri Dec 20, 2019 2:38 am This is one of the most interesting indicator in mql4 language.
Description:
Linear Momentum:
Momentum is strength of an object that moves to different place — this is my own definition. Momentum can be calculated with following equation: momentum = mass x velocity. You should already know that velocity is speed with direction.
Shortest equation will be: p=mv where p is momentum, m is mass (in kg) and v is velocity (in m/s).
Linear Momentum Implementation in MetaTrader Custom Indicator:
The following will explain why it’s called Linear Momentum in Forex:
p = momentum; m = mass, converted into volume of trade or tick;
I would prefer to use tick volume because it’s more easy to find tick information than volume of all lots traded around the world; v = velocity, it’s a value taken from pips movement divided by timeframe (point/seconds, originally in m/s).

Replace the code of OnCalculate() with this :

Code: Select all

   int limit = rates_total-prev_calculated; if (limit>=rates_total-1) limit = rates_total-1;
      for(int i=limit; i>=0; i--) Temporary[i]=tick_volume[i]*(close[i]-open[i]);
      for(int i=limit; i>=0; i--) LinearMomentumBuffer[i]=iMAOnArray(Temporary,0,SmoothingPeriod,0,SmoothingMethod,i);
   return(rates_total);

The code used in that indicator is unnecessarily complicated

All files in topic