거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
Experts

A Code block to detect A "New Candle/Bar" using bars history (very effective way) - MetaTrader 5용 expert

조회수:
1087
평가:
(3)
게시됨:
2024.04.11 12:05
업데이트됨:
2024.04.11 12:12
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

In previous code I used the time to detect a new bar. This time let's use the bars count to detect a new bar. it's way lighter and faster than using the time method.

  • Declare the variables in integer data type to store the bar counts. 
  • Assign the bars count for the "BarsTotal_OnInt" at the initialization. 
  • Use iBars(); function to assign the bars count for the "BarsTotal_OnTick" variable at live chart. This variable is updated on every tick. 
  • Use comments and alerts to check the code accuracy.

int BarsTotal_OnInt; 
int BarsTotal_OnTick;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {  
   BarsTotal_OnInt = iBars(NULL,PERIOD_CURRENT); // Asign the total bars at initialization
   return(INIT_SUCCEEDED);
  }
  
void OnTick() // OnTick Function
  {   
   BarsTotal_OnTick = iBars(NULL,PERIOD_CURRENT); // Stores the latest amount
   
   if(BarsTotal_OnTick > BarsTotal_OnInt) // New bar has arrived
   {
    BarsTotal_OnInt = BarsTotal_OnTick; // Updates the history.
    Alert("New Bar has arrived");
    Comment("Bars Count in history -: ", BarsTotal_OnInt, "\n", "Bars Count in Live -: ", BarsTotal_OnTick);

     // Your Code goes here. --------------------------
    
    // You can update a "flag" / variable to use it on later too. 

   }
  }
    Candle Analysis Report Candle Analysis Report

    This script helps traders understand the distribution and range of candles in a specific period, which can be useful for making trading decisions such as determining which historical values to use for Take Profit or Stop Loss.

    Counter Attack Candlestick Counter Attack Candlestick

    Counter attack candlestick pattern

    Basic GridManager Library Basic GridManager Library

    This is a basic library to create and manage grids.

    Code blocks for "Counters" like Count "X" time and pass Code blocks for "Counters" like Count "X" time and pass

    Here are some examples of codes for set counters based on "Count"