AIUTOOOOO!!! (INDICATORE E DRAW_LINE)

 

Salve a tutti sto cercando di far disegnare una linea verticale al mio indicatore.
pubblico il codice e vi spiego cosa dovrebbe fare:

#property copyright "Created by RaysFX"
#property link      "n.a."
#property version   "1.00"
#property description "n.a."
#property tester_indicator "Stoch RSI"

#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_type1 DRAW_ARROW
#property indicator_width1 2
#property indicator_color1 0x0000FF
#property indicator_label1 "SELL"

#property indicator_type2 DRAW_ARROW
#property indicator_width2 2
#property indicator_color2 0xFFAA00
#property indicator_label2 "BUY"

#define PLOT_MAXIMUM_BARS_BACK 5000
#define OMIT_OLDEST_BARS 50

//--- indicator buffers
double Buffer1[];
double Buffer2[];

extern double stoch = 80;
extern double stoch_up = 20;
extern double arrow_pip = 5;
bool Audible_Alerts = true;
double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | 1 @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
   else if(type == "indicator")
     {
      Print(type+" | 1 @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
      if(Audible_Alerts) Alert(type+" | 1 @ "+Symbol()+","+IntegerToString(Period())+" | "+message);
     }
  }

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexDrawBegin(0, MathMax(Bars(Symbol(), PERIOD_CURRENT)-PLOT_MAXIMUM_BARS_BACK+1, OMIT_OLDEST_BARS+1));
   SetIndexArrow(0, 234);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, EMPTY_VALUE);
   SetIndexDrawBegin(1, MathMax(Bars(Symbol(), PERIOD_CURRENT)-PLOT_MAXIMUM_BARS_BACK+1, OMIT_OLDEST_BARS+1));
   SetIndexArrow(1, 233);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   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[])
  {
   int limit = rates_total - prev_calculated;
   //--- counting from 0 to rates_total
   ArraySetAsSeries(Buffer1, true);
   ArraySetAsSeries(Buffer2, true);
   //--- initial zero
   if(prev_calculated < 1)
     {
      ArrayInitialize(Buffer1, EMPTY_VALUE);
      ArrayInitialize(Buffer2, EMPTY_VALUE);
     }
   else
      limit++;
   
   //--- main loop
   for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(PLOT_MAXIMUM_BARS_BACK-1, rates_total-1-OMIT_OLDEST_BARS)) continue; //omit some old rates to prevent "Array out of range" or slow calculation   
      
      //Indicator Buffer 1
      if(iCustom(NULL, PERIOD_CURRENT, "Stoch RSI", 3, 3, 14, 14, PRICE_CLOSE, 1, i) < stoch
      && iCustom(NULL, PERIOD_CURRENT, "Stoch RSI", 3, 3, 14, 14, PRICE_CLOSE, 1, i+1) > stoch //Stoch RSI crosses below fixed value
      && Close[1+i] < iMA(NULL, PERIOD_CURRENT, 25, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close < Moving Average
      && Close[1+i] < iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close < Moving Average
      && Close[1+i] < iMA(NULL, PERIOD_CURRENT, 100, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close < Moving Average
      )
        {
         Buffer1[i] = High[i] + arrow_pip*Point; //Set indicator value at Candlestick High
        }
      else
        {
         Buffer1[i] = EMPTY_VALUE;
        }
      //Indicator Buffer 2
      if(iCustom(NULL, PERIOD_CURRENT, "Stoch RSI", 3, 3, 14, 14, PRICE_CLOSE, 1, i) > stoch_up
      && iCustom(NULL, PERIOD_CURRENT, "Stoch RSI", 3, 3, 14, 14, PRICE_CLOSE, 1, i+1) < stoch_up //Stoch RSI crosses above fixed value
      && Close[1+i] > iMA(NULL, PERIOD_CURRENT, 25, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close > Moving Average
      && Close[1+i] > iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close > Moving Average
      && Close[1+i] > iMA(NULL, PERIOD_CURRENT, 100, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close > Moving Average
      )
        {
         Buffer2[i] = Low[i] - arrow_pip*Point; //Set indicator value at Candlestick Low
        }
      else
        {
         Buffer2[i] = EMPTY_VALUE;
        }
     }
   return(rates_total);
  }

quello che voglio fare è inserire una linea verticale esattamente dove appare la freccia 

//Indicator Buffer 1
      if(iCustom(NULL, PERIOD_CURRENT, "Stoch RSI", 3, 3, 14, 14, PRICE_CLOSE, 1, i) < stoch
      && iCustom(NULL, PERIOD_CURRENT, "Stoch RSI", 3, 3, 14, 14, PRICE_CLOSE, 1, i+1) > stoch //Stoch RSI crosses below fixed value
      && Close[1+i] < iMA(NULL, PERIOD_CURRENT, 25, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close < Moving Average
      && Close[1+i] < iMA(NULL, PERIOD_CURRENT, 50, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close < Moving Average
      && Close[1+i] < iMA(NULL, PERIOD_CURRENT, 100, 0, MODE_EMA, PRICE_CLOSE, i) //Candlestick Close < Moving Average
      )
        {
         Buffer1[i] = High[i] + arrow_pip*Point; //Set indicator value at Candlestick High
        }

ma non so esattamente cosa scrivere...

mi sapreste aiutare? 

 
Davide Rappa:

Salve a tutti sto cercando di far disegnare una linea verticale al mio indicatore.
pubblico il codice e vi spiego cosa dovrebbe fare:

quello che voglio fare è inserire una linea verticale esattamente dove appare la freccia 

ma non so esattamente cosa scrivere...

mi sapreste aiutare? 

nessuno ?!?!?

 

Buona sera.

Anche se poco ortodosso, ha provato con ObjectCreate e OBJ_VLINE?

 
Gabriele Tedeschi #:

Buona sera.

Anche se poco ortodosso, ha provato con ObjectCreate e OBJ_VLINE?

provo, grazie :-)