Camarilla-MT04-Ind_MBB

Camarilla-MT04-Ind_MBB

This script is designed for the MetaTrader 4 trading platform to automatically identify and visualize specific price boundaries on a chart. It utilizes a mathematical approach known as "Camarilla Pivot Points," which helps traders determine potential support and resistance levels based on the previous day's market activity.

Core Logic Overview

The tool functions by analyzing historical data from the preceding trading day to calculate four key price points: two Resistance levels (R3, R4) and two Support levels (S3, S4). Here is a breakdown of how the logic flows:

Data Collection The script begins by retrieving the essential price data from the previous day's daily candles. Specifically, it looks for three key pieces of information:

  • The highest price reached during the day.
  • The lowest price reached during the day.
  • The closing price of the day.

Mathematical Calculation Once these values are gathered, the script determines the "Range"—the total distance between the high and the low of yesterday. It then applies a specific multiplier (1.1) to this range to project the following levels:

  • Resistance Levels (R3 & R4): These are calculated by adding a fraction of the adjusted range to yesterday’s closing price. They represent areas where the price may face pressure to pull back or stall during the current session.
  • Support Levels (S3 & S4): These are calculated by subtracting a fraction of the adjusted range from yesterday’s closing price. They represent floor levels where the price might find buying interest or stability.

Visual Representation After performing these calculations, the script performs three main actions on your trading screen:

  1. On-Screen Text: It displays the exact numerical values for R4, R3, S3, and S4 in a text comment box on the chart for quick reference.
  2. Dynamic Drawing: It automatically draws horizontal lines across the chart to represent these levels.
  3. Automatic Updating: The script is programmed to clear old lines and redraw the new ones every time the data refreshes, ensuring that your support and resistance levels are always current and accurate based on the most recent daily close.

Visual Styling

To make the data easy to read at a glance, the script applies specific formatting to the lines:

  • Resistance Lines (R3, R4): Rendered in an Orange-Red color with a dashed-dot style.
  • Support Lines (S3, S4): Rendered in a Green-Yellow color with a dashed-dot style.
11 Views
0 Downloads
0 Favorites
Camarilla-MT04-Ind_MBB
//+------------------------------------------------------------------+
//|                                                          PV4.mq4 |
//|                                                        Jim Arner |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
  {
//---- indicators

//---- indicators

   

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   double yesterday_high;
   double yesterday_low;
   double yesterday_close;
   double array_price[][6];
   double P,R4,R3,S3,S4;

//---- TODO: add your code here

ArrayInitialize(array_price,0);
ArrayCopyRates(array_price,(Symbol()), PERIOD_D1);

yesterday_high = array_price[1][3];
yesterday_low = array_price[1][2];
yesterday_close = array_price[1][4];

P = yesterday_high - yesterday_low;

R4 = (1.1*P/2)+yesterday_close;
R3 = (1.1*P/4)+yesterday_close;

S3 = yesterday_close - (P*1.1/4);
S4 = yesterday_close - (P*1.1/2);

Comment("Camarilla Levels by Bin-Yagoub","\nR4=",R4,"\nR3=",R3,"\nS3=",S3,"\nS4=",S4);

ObjectDelete("S4_Line");
ObjectDelete("R4_Line");

ObjectDelete("S3_Line");
ObjectDelete("R3_Line");

ObjectCreate("S4_Line", OBJ_HLINE,0, CurTime(),S4);
ObjectSet("S4_Line",OBJPROP_COLOR,GreenYellow);
ObjectSet("S4_Line",OBJPROP_STYLE,STYLE_DASHDOTDOT);

ObjectCreate("R4_Line", OBJ_HLINE,0, CurTime(),R4);
ObjectSet("R4_Line",OBJPROP_COLOR,OrangeRed);
ObjectSet("R4_Line",OBJPROP_STYLE,STYLE_DASHDOTDOT);

ObjectCreate("S3_Line", OBJ_HLINE,0, CurTime(),S3);
ObjectSet("S3_Line",OBJPROP_COLOR,GreenYellow);
ObjectSet("S3_Line",OBJPROP_STYLE,STYLE_DASHDOTDOT);

ObjectCreate("R3_Line", OBJ_HLINE,0, CurTime(),R3);
ObjectSet("R3_Line",OBJPROP_COLOR,OrangeRed);
ObjectSet("R3_Line",OBJPROP_STYLE,STYLE_DASHDOTDOT);

ObjectsRedraw();

   return(0);
 }
//+------------------------------------------------------------------+

Comments