Momentum+Moving average

 

Goodmorning everyone.. I have a little problem .. I created a separate window indicator that incorporates both momentum and a moving average. the problem that creates two completely disconnected lines as in the photo ... #property copyright "Your copyright" #property link "Link to your website" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_width1 2 #property indicator_color2 Blue #property indicator_width2 2 // exported variables // local variables double PipValue=1; string LF = "\n"; // use this in custom or utility blocks where you need line feeds int ObjCount = 0; // count of all objects created on the chart, allows creation of objects with unique names int current = 0; // variable points to current bar double Buffer2[]; double Buffer4[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { if (false) ObjectsDeleteAll(); // clear the chart IndicatorShortName("Indicator name"); IndicatorDigits(Digits+1); IndicatorBuffers(2); SetIndexBuffer(0, Buffer2); SetIndexStyle(0, DRAW_LINE, STYLE_SOLID); SetIndexBuffer(1, Buffer4); SetIndexStyle(1, DRAW_LINE, STYLE_SOLID); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { if (false) ObjectsDeleteAll(); return(0); } //+------------------------------------------------------------------+ //| Custom indicator start function | //+------------------------------------------------------------------+ int start() { OnEveryTick1(); return(0); } //+------------------------------------------------------------------+ void OnEveryTick1() { int i; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return; if(counted_bars > 0) counted_bars--; i = Bars - counted_bars; // main calculation loop while (i >= 0) { current = i; ChartLine2(); ChartLine4(); i--; } } void ChartLine2() { Buffer2[current]= iMomentum(NULL, PERIOD_CURRENT,30,PRICE_CLOSE,current); } void ChartLine4() { Buffer4[current]= iMA(NULL, PERIOD_CURRENT,13,0,MODE_EMA,PRICE_CLOSE,current); }

thank you so much!
Archivos adjuntos:
 
#property copyright "Your copyright"
#property link "Link to your website"
#property indicator_separate_window
#property indicator_buffers 2

#property indicator_color1 Red
#property indicator_width1 2

#property indicator_color2 Blue
#property indicator_width2 2



// exported variables


// local variables
double PipValue=1;
string LF = "\n";  // use this in custom or utility blocks where you need line feeds
int ObjCount = 0;  // count of all objects created on the chart, allows creation of objects with unique names
int current = 0; // variable points to current bar

double Buffer2[];
double Buffer4[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
    if (false) ObjectsDeleteAll();      // clear the chart
    IndicatorShortName("Indicator name");
    IndicatorDigits(Digits+1);
    IndicatorBuffers(2);
    
    SetIndexBuffer(0, Buffer2);
    SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
    
    SetIndexBuffer(1, Buffer4);
    SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
    
    
    return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
    if (false) ObjectsDeleteAll();
    
    
    return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator start function                                  |
//+------------------------------------------------------------------+
int start()
{
    OnEveryTick1();
    
    return(0);
}

//+------------------------------------------------------------------+

void OnEveryTick1()
{
    
    int i;
    int counted_bars = IndicatorCounted();
    if(counted_bars < 0) return;
    if(counted_bars > 0) counted_bars--;
    i = Bars - counted_bars;
    // main calculation loop
    while (i >= 0)
    {
        current = i;
        ChartLine2();
        ChartLine4();
        
        i--;
    }
}

void ChartLine2()
{
    Buffer2[current]= iMomentum(NULL, PERIOD_CURRENT,30,PRICE_CLOSE,current);
    
}

void ChartLine4()
{
    Buffer4[current]= iMA(NULL, PERIOD_CURRENT,13,0,MODE_EMA,PRICE_CLOSE,current);
    
}

 
Los valores se están representando de manera correcta

el "momentun" representan valores cercanos a 100, y la MEDIA MOVIL esta representando valores del precio, que estan por encima de 10000. lo que sucede es que los valores son tan distantes que solo asi pueden mostrarse en un espacio tan "pequeño"

Quizas quieras representar un valor sobre otro, asi que busca la Funcion "iMaOnArray"

Por cierto, este es el foro en español, asi que por favor, participa en español

Saludos!!!
 
muchas gracias
 
Sin embargo, no entendí cómo debería usarse y dónde debería colocarse ... ¿podría darme un ejemplo? ... Gracias
 
snakefist:
Sin embargo, no entendí cómo debería usarse y dónde debería colocarse ... ¿podría darme un ejemplo? ... Gracias
//+------------------------------------------------------------------+
void ChartLine4()
   {
   //Buffer4[current]= iMA(NULL, PERIOD_CURRENT,13,0,MODE_EMA,PRICE_CLOSE,current);
  Buffer4[current]=iMAOnArray(Buffer2,0,13,0,MODE_EMA,current);
   }
//+------------------------------------------------------------------+
 
Resolví el problema ... funciona ahora ... Muchas gracias
 

Buenos días. el indicador funciona bien, sin embargo, cuando cambio el TF, comienza a ralentizar el PC ... esto solo funciona cuando cargo el indicador en la plataforma ... Creo que es un problema de iMAOnArray ... ¿podrían darme algunas sugerencias para la corrección? Muchas gracias.

 
snakefist:

Buenos días. el indicador funciona bien, sin embargo, cuando cambio el TF, comienza a ralentizar el PC ... esto solo funciona cuando cargo el indicador en la plataforma ... Creo que es un problema de iMAOnArray ... ¿podrían darme algunas sugerencias para la corrección? Muchas gracias.

es porque tu bucle no tiene tiempo de espera.