target_lubang_MA
Download scriptThis tool is designed as a visual price target indicator for MetaTrader 4, specifically built to help traders identify key technical levels and market trends based on Moving Averages (MA). It serves as an automated guide that places a text label on your chart to signal where the price might head next or to alert you of significant trend shifts.
Core Functionality
The script works by constantly monitoring four different Simple Moving Average (SMA) lines: the 20, 50, 100, and 200 periods. By comparing the current market price (highs and lows) against these averages, the tool determines the "strength" of the current market movement and identifies specific targets.
How it Identifies Targets
The logic is divided into two primary categories: Upward Movements and Downward Movements.
1. For Bullish (Upward) Trends: The script checks if the price is currently above the moving averages. Depending on the specific arrangement of these lines, it provides different signals:
- Target Identification: If the price is above a specific MA, but the averages are not in a perfect "stacked" order, the script identifies the next significant MA as your target price.
- Trend Confirmation: If the moving averages are stacked in a specific sequence (e.g., 20 > 50 > 100), the tool detects a strong upward trend. In these cases, it alerts you that the current timeframe might be showing a "Strong Up Trend," suggesting you may need to adjust your analysis or switch timeframes.
2. For Bearish (Downward) Trends: Similarly, the script monitors the price dropping below the moving averages:
- Target Identification: It identifies the next lower moving average as a potential target for a sell or short position.
- Trend Confirmation: If the averages fall into a specific descending sequence, it triggers an alert for a "Strong Down Trend," signaling a significant shift in market momentum.
User Experience Features
- Visual Labels: Instead of just giving you numbers, the script places a physical text label on your chart. This label updates in real-time to show exactly what the target price is (e.g., "target MA50 1.xxxx").
- Language Localization: The tool includes a built-in toggle that allows users to switch the display language between English and Indonesian, making it accessible to a wider range of traders.
- Dynamic Updates: The script continuously recalculates as new price data comes in, ensuring the target label moves with the current market conditions.
Summary for Traders
Essentially, this script acts as a "navigation system." It looks at the relationship between various moving averages to tell you two things: where the price is likely heading next (the target) and how strong the current trend is (the alert). It removes the guesswork of identifying which moving average is the most relevant at any given moment.
//+------------------------------------------------------------------+
//| target lubang MA.mq4 |
//| reza rahmad |
//| reiz_gamer@yahoo.co.id |
//+------------------------------------------------------------------+
#property copyright "reza rahmad"
#property link "reiz_gamer@yahoo.co.id"
#property indicator_chart_window
extern string help = "use from tf 5m and change to find target";
extern bool indonesian = true;
//----
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
ObjectCreate("tar",OBJ_TEXT,0,0,0,0,0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("tar");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double ma100 = iMA(NULL,0,100,0,MODE_SMA,PRICE_CLOSE,0), ma50 =iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0),
ma20 = iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0), ma200 = iMA(NULL,0,200,0,MODE_SMA,PRICE_CLOSE,0);
if ( indonesian == false )
{
if (High[0] > ma20 && ma20 > ma50 && ma20 > ma100)
{
ObjectSet("tar",OBJPROP_PRICE1,ma50);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","Trend up change Timeframe",10,"Tahoma",Green);
}
if (High[0] > ma20 && ma50 > ma20)
{
ObjectSet("tar",OBJPROP_PRICE1,ma50);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA50 " + DoubleToStr(ma50,4),10,"Tahoma",Green);
}
if (High[0] > ma50 && ma100 > ma50)
{
ObjectSet("tar",OBJPROP_PRICE1,ma100);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA100 " + DoubleToStr(ma100,4),10,"Tahoma",Green);
}
if (High[0] > ma100 && ma200 > ma100 && ma200 > ma50)
{
ObjectSet("tar",OBJPROP_PRICE1,ma200);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA200 " + DoubleToStr(ma200,4),10,"Tahoma",Green);
}
if (High[0] > ma200 && ma200 > ma100 && ma200 > ma50 )
{
ObjectSet("tar",OBJPROP_PRICE1,ma200);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","TREND UP CHANGE TIMEFRAME ",10,"Tahoma",Green);
}
// turun
if (Low[0] < ma20 && ma20 < ma50 && ma20 < ma100)
{
ObjectSet("tar",OBJPROP_PRICE1,ma50);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","Trend DOWN CHANGE Timeframe",10,"Tahoma",Green);
}
if (Low[0] < ma20 && ma50 < ma20)
{
ObjectSet("tar",OBJPROP_PRICE1,ma50);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA50 " + DoubleToStr(ma50,4),10,"Tahoma",Green);
}
if (Low[0] < ma50 && ma100 < ma50)
{
ObjectSet("tar",OBJPROP_PRICE1,ma100);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA100 " + DoubleToStr(ma100,4),10,"Tahoma",Green);
}
if (Low[0] < ma50 && ma100 < ma50 && ma50 > ma20)
{
ObjectSet("tar",OBJPROP_PRICE1,ma100);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","TREND DOWN CHANGE TIMEFRAME ",10,"Tahoma",Green);
}
if (Low[0] < ma100 && ma200 < ma100 && ma200 < ma50)
{
ObjectSet("tar",OBJPROP_PRICE1,ma200);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA200 " + DoubleToStr(ma200,4),10,"Tahoma",Green);
}
if (Low[0] < ma200 && ma200 < ma100 && ma200 < ma50 )
{
ObjectSet("tar",OBJPROP_PRICE1,ma200);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","TREND DOWN CHANGE TIMEFRAME",10,"Tahoma",Green);
}
}
if ( indonesian == true )
{
if (High[0] > ma20 && ma20 > ma50 && ma20 > ma100)
{
ObjectSet("tar",OBJPROP_PRICE1,ma50);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","Trend up kuat ganti Timeframe",10,"Tahoma",Green);
}
if (High[0] > ma20 && ma50 > ma20)
{
ObjectSet("tar",OBJPROP_PRICE1,ma50);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA50 " + DoubleToStr(ma50,4),10,"Tahoma",Green);
}
if (High[0] > ma50 && ma100 > ma50)
{
ObjectSet("tar",OBJPROP_PRICE1,ma100);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA100 " + DoubleToStr(ma100,4),10,"Tahoma",Green);
}
if (High[0] > ma100 && ma200 > ma100 && ma200 > ma50)
{
ObjectSet("tar",OBJPROP_PRICE1,ma200);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA200 " + DoubleToStr(ma200,4),10,"Tahoma",Green);
}
if (High[0] > ma200 && ma200 > ma100 && ma200 > ma50 )
{
ObjectSet("tar",OBJPROP_PRICE1,ma200);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","TREND NAIK GANTI TIMEFRAME ",10,"Tahoma",Green);
}
// turun
if (Low[0] < ma20 && ma20 < ma50 && ma20 < ma100)
{
ObjectSet("tar",OBJPROP_PRICE1,ma50);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","Trend turun kuat ganti Timeframe",10,"Tahoma",Green);
}
if (Low[0] < ma20 && ma50 < ma20)
{
ObjectSet("tar",OBJPROP_PRICE1,ma50);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA50 " + DoubleToStr(ma50,4),10,"Tahoma",Green);
}
if (Low[0] < ma50 && ma100 < ma50)
{
ObjectSet("tar",OBJPROP_PRICE1,ma100);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA100 " + DoubleToStr(ma100,4),10,"Tahoma",Green);
}
if (Low[0] < ma50 && ma100 < ma50 && ma50 > ma20)
{
ObjectSet("tar",OBJPROP_PRICE1,ma100);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","trend turun kuat ganti timeframe ",10,"Tahoma",Green);
}
if (Low[0] < ma100 && ma200 < ma100 && ma200 < ma50)
{
ObjectSet("tar",OBJPROP_PRICE1,ma200);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","target MA200 " + DoubleToStr(ma200,4),10,"Tahoma",Green);
}
if (Low[0] < ma200 && ma200 < ma100 && ma200 < ma50 )
{
ObjectSet("tar",OBJPROP_PRICE1,ma200);
ObjectSet("tar",OBJPROP_TIME1,Time[0]);
ObjectSetText("tar","TREND TURUN GANTI TIMEFRAME ",10,"Tahoma",Green);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments