You're reading...
EA development, MQL4, MQL5, Uncategorized

Getting Fibonacci prices from the percentage level

Getting a price at a Fibonnaci percentage level is a straightforward mathematical calculation.

We just need to define 3 things:
1. Price at 100%
2. Price at 0%
3. Percentage to return Price at

This is a script illustrating all the calculation needed:

#property strict
#property show_inputs

input double inp_price_100  = 0.0;  //Price at 100%
input double inp_price_0    = 0.0;  //Price at 0%
input double inp_percentage = 61.8; //Percentage to return Price at

void OnStart(){

   double priceDifference = MathAbs(inp_price_0 - inp_price_100) * inp_percentage/100; //get the price difference between the required percentage level and 0%
   
   Print((inp_price_100 > inp_price_0) ? NormalizeDouble(inp_price_0 + priceDifference, Digits) : NormalizeDouble(inp_price_0 - priceDifference, Digits));

}

You just need these 2 lines to to obtain your required price for further action within an EA.

Discussion

One thought on “Getting Fibonacci prices from the percentage level

  1. Amazing! Thank you so much 🙂

    Posted by Jacob Notte | 2021-05-29, 9:01 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Archives

Visitors

Flag Counter
%d bloggers like this: