sideway_or__trend_v_1_2_update

Download script
Author: reza rahmad
sideway_or__trend_v_1_2_update

This tool is designed to analyze market conditions and provide real-time visual feedback regarding whether the current price action is moving in a specific trend or behaving as "sideways" (range-bound) movement. By interpreting complex technical data, it translates these movements into clear, color-coded text labels on your trading chart.

How the Logic Works

The script utilizes a technical analysis metric called the Average Directional Index (ADX). It breaks down the market's strength and direction into three distinct components to determine which visual signal to display:

1. Trend Identification The script monitors the relationship between the main trend strength and its directional indicators.

  • Trend Buy: When the data suggests a strong upward momentum where the primary trend line is lower than the positive directional force, the tool displays a Green "TREND BUY" label.
  • Trend Sell: When the data indicates a dominant downward momentum where the primary trend line is lower than the negative directional force, the tool displays a Tomato "TREND SELL" label.

2. Sideways Market Identification The script looks for specific patterns where price movement lacks strong directional conviction or falls into specific low-volatility zones.

  • Sideway Buy: If the indicators show a balance of power favoring upward bias without a clear trend, or if the market is in a low-strength state (below a specific threshold), it displays a Magenta "SIDEWAY BUY" label.
  • Sideway Sell: Conversely, if the indicators favor a downward bias in a non-trending environment, or if the market shows very low strength, it displays a Magenta "SIDEWAY SELL" label.

Visual Feedback

Instead of requiring you to interpret raw numbers, the script automatically updates labels on your screen:

  • Textual Cues: Clearly states the detected market state (e.g., "TREND BUY", "SIDEWAY SELL").
  • Color Coding: Uses high-contrast colors (Green for bullish trends, Tomato for bearish trends, and Magenta for sideways movements) to allow for instant recognition at a glance.
  • Iconography: Includes symbols alongside the text to provide a secondary visual indicator of the current market sentiment.
Indicators Used
Movement directional index
5 Views
0 Downloads
0 Favorites
sideway_or__trend_v_1_2_update
//+------------------------------------------------------------------+
//|                                            sideway or  trend.mq4 |
//|                                                      reza rahmad |
//|                                           reiz_gamer@yahoo.co.id |
//+------------------------------------------------------------------+
#property copyright "reza rahmad"
#property link      "reiz_gamer@yahoo.co.id"

#property indicator_chart_window
extern int period_adx = 14;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators 
        ObjectCreate("side",OBJ_LABEL,0,0,0,0,0);
         ObjectSet("side",OBJPROP_XDISTANCE,40);         
         ObjectSet("side",OBJPROP_YDISTANCE,40);        
         
         
         ObjectCreate("side1",OBJ_LABEL,0,0,0,0,0);
         ObjectSet("side1",OBJPROP_XDISTANCE,80);
         ObjectSet("side1",OBJPROP_YDISTANCE,60);
         
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
ObjectDelete("side");
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
//----
   if(iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MAIN,0)>iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) && iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MAIN,0)>iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0)&& iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) >iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0)) 
   {
   ObjectSet("side",OBJPROP_CORNER,1);
    ObjectSet("side1",OBJPROP_CORNER,1);
   ObjectSetText("side","SIDEWAY BUY",15,"TAHOMA",Magenta);
   ObjectSetText("side1",CharToStr(75),30,"Wingdings",Magenta);
   
   }
   if(iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MAIN,0)>iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) && iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MAIN,0)>iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0)&& iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) < iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0)) 
   { ObjectSet("side",OBJPROP_CORNER,1);
   ObjectSet("side1",OBJPROP_CORNER,1);
   ObjectSetText("side","SIDEWAY SELL",15,"TAHOMA",Magenta);
    ObjectSetText("side1",CharToStr(75),30,"Wingdings",Magenta);
   }
   if(iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) > iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0 && iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MAIN,0) < 20) ) 
   {
   ObjectSet("side",OBJPROP_CORNER,1);
    ObjectSet("side1",OBJPROP_CORNER,1);
   ObjectSetText("side","SIDEWAY BUY",15,"TAHOMA",Magenta);
   ObjectSetText("side1",CharToStr(75),30,"Wingdings",Magenta);
   
   }
   if(iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) < iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0 && iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MAIN,0) < 20) ) 
   { ObjectSet("side",OBJPROP_CORNER,1);
   ObjectSet("side1",OBJPROP_CORNER,1);
   ObjectSetText("side","SIDEWAY SELL",15,"TAHOMA",Magenta);
    ObjectSetText("side1",CharToStr(75),30,"Wingdings",Magenta);
   }
   
   if(iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MAIN,0)<iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) && iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) >iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0))
   {
    ObjectSet("side",OBJPROP_CORNER,1);
    ObjectSet("side1",OBJPROP_CORNER,1);
   ObjectSetText("side","TREND BUY",15,"TAHOMA",Green);
   ObjectSetText("side1",CharToStr(221),30,"Wingdings",Green);
   }
   
   if(iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MAIN,0)<iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0) && iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_PLUSDI,0) < iADX(NULL,0,period_adx,PRICE_CLOSE,MODE_MINUSDI,0))
   {
    ObjectSet("side",OBJPROP_CORNER,1);
    ObjectSet("side1",OBJPROP_CORNER,1);
   ObjectSetText("side","TREND SELL",15,"TAHOMA",Tomato);
    ObjectSetText("side1",CharToStr(222),30,"Wingdings",Tomato);
   }
   
//---

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

Comments