Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!
Thank you.
Thank you
// --- Sell #property indicator_label1 "Sell" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrAqua #property indicator_width1 1 input bool SELL_ARROW = true; // --- Buy #property indicator_label2 "Buy" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrAqua #property indicator_width2 1 input bool BUY_ARROW = true; //--- Buffa double SELL[]; double BUY[]; // --- Global int MA_HANDLE; int MACD_HANDLE; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping // --- Sell SetIndexBuffer(0, SELL, INDICATOR_DATA); PlotIndexSetInteger(0, PLOT_ARROW, 226); PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 0); PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0); ArraySetAsSeries(SELL, true); // --- Buy SetIndexBuffer(1, BUY, INDICATOR_DATA); PlotIndexSetInteger(1, PLOT_ARROW, 225); PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, 0); PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, 0); ArraySetAsSeries(BUY, true); // --- Handle MA_HANDLE = iMA(NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE); MACD_HANDLE = iMACD(NULL, PERIOD_M5, 5, 25, 5, PRICE_CLOSE); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- // --- bar int limit, to_copy; if(prev_calculated>rates_total || prev_calculated<=0) limit = rates_total; else limit = rates_total - prev_calculated; if(prev_calculated>rates_total || prev_calculated<=0) to_copy = rates_total; else { to_copy = rates_total - prev_calculated; to_copy ++; } // --- MA&MACD double ma[], ma_past[], macd[]; CopyBuffer(MA_HANDLE, 0, 0, to_copy, ma); CopyBuffer(MACD_HANDLE, 0, 1, to_copy, ma_past); CopyBuffer(MACD_HANDLE, 0, 0, to_copy, macd); ArraySetAsSeries(ma, true); ArraySetAsSeries(ma_past, true); ArraySetAsSeries(macd, true); ArraySetAsSeries(open,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); // --- Arrow for(int i = 0; i < 1000; i++) { if(ma[i] > close[i]) { SELL[i] = high[i]; //Print(ma[i]); } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Kosei S :
Your error is here:
// --- Handle MA_HANDLE = iMA(NULL, PERIOD_M5, 20, 0, MODE_SMA, PRICE_CLOSE); MACD_HANDLE = iMACD(NULL, PERIOD_M5, 5, 25, 5, PRICE_CLOSE);
Vladimir Karputov:
Thank you for reply.Your error is here:
I changed it, but the arrow was still not displayed.
MA_HANDLE = iMA(NULL, PERIOD_CURRENT, 20, 0, MODE_SMA, PRICE_CLOSE); MACD_HANDLE = iMACD(NULL, PERIOD_CURRENT, 5, 25, 5, PRICE_CLOSE);
Kosei S :
Thank you for reply.
I changed it, but the arrow was still not displayed.
Thank you for reply.
I changed it, but the arrow was still not displayed.
Please attach your file using the button
Kosei S :
Thank you
Thank you
Error: You did not specify the number of indicator buffers and did not specify the number of graphical plots.
#property indicator_chart_window // --- Sell #property indicator_label1 "Sell"
I recommend creating a template using the MQL Wizard
Vladimir Karputov:
Error: You did not specify the number of indicator buffers and did not specify the number of graphical plots.
I recommend creating a template using the MQL Wizard
Thank you so much

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Code
***