Simple Delta + Accel

Author: Andrew Haas
Simple Delta + Accel
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Simple Delta + Accel
//+------------------------------------------------------------------+
//|                                           Simple Delta + Accel.mq4 |
//|                                                       Andrew Haas |
//|                                         http://www.predictiononline.com |
//+------------------------------------------------------------------+
#property copyright "Andrew Haas"
#property link      "http://www.predictiononline.com"

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 Green
#property indicator_color4 Red
#property indicator_color5 Blue
#property indicator_color6 Purple

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexStyle(5,DRAW_ARROW);
   
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexBuffer(5,ExtMapBuffer6);
   
   string short_name = "Simple Delta + Accel!";
   IndicatorShortName(short_name);
//----
   return(1);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
//---- check for possible errors
int delta = 1;
   if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if (counted_bars>0) counted_bars--;
   
   int    pos=  Bars-counted_bars;
   int    pos2 = Bars - counted_bars;
   
   double dClose,dLastClose,dResult,dDelta,dLastDelta,dAccel,dLastAccel,dCrossedZero;
   double dLastResult;
   Comment("Hi! I'm here on the main chart windows!");
   bool lastValue = false;
   bool lastDelta = false;
   bool isBuy = false;
   bool printingBuy = false;
   bool bBuy,bSell = false;
   
//---- main calculation loop
   while(pos>=0)
     {
         dClose = Close[pos];
         dResult = dClose;
         if (lastValue == false)
         {
            ExtMapBuffer1[pos]= 0.0 ;
            ExtMapBuffer2[pos] = 0.0;
            dResult = 0.0;
         }
         else
         {
            dDelta = dClose - dLastClose;
            ExtMapBuffer1[pos] = dDelta;
            if (lastDelta == false)
            {
            ExtMapBuffer1[pos] = dDelta;
            ExtMapBuffer2[pos] = 0.0;
            lastDelta = true;
            }
            else
            {
             dAccel = dDelta - dLastDelta;
             ExtMapBuffer2[pos] = dAccel;
             
             // Stop Signals
             if ((dDelta > 0) && (dLastDelta < 0))
             {
              dCrossedZero = dDelta;
              ExtMapBuffer3[pos] = -0.0001;
              bBuy = true;
              // ObjectCreate("P label", OBJ_TEXT, 0, Time[0], P);
              //  ObjectSetText("P label", "Pivot " +DoubleToStr(P,4), 8, "Arial", EMPTY);
             }
             else
             {
               dCrossedZero = 0.0;
               ExtMapBuffer3[pos] = EMPTY_VALUE;
               bBuy = false;
             }
             
             if ((dDelta < 0) && (dLastDelta > 0))
             {
              // ExtMapBuffer3[pos] = 0.0001;
              ExtMapBuffer4[pos] = 0.0001;
              bSell = true;  
             }
             else
             {
             // ExtMapBuffer3[pos] = EMPTY_VALUE;
               bSell = false;
             }
            
            
            // Buy/Sell Signals
             if ((dDelta > 0) && (dLastDelta < 0) 
                 && (dAccel > 0) && (dLastAccel < 0) )
             {
              ExtMapBuffer5[pos] = -0.0001;
              bBuy = true;
              // ObjectCreate("P label", OBJ_TEXT, 0, Time[0], P);
              //  ObjectSetText("P label", "Pivot " +DoubleToStr(P,4), 8, "Arial", EMPTY);
             }
             else
             {
               dCrossedZero = 0.0;
               // ExtMapBuffer5[pos] = EMPTY_VALUE;
               bBuy = false;
             }
             
             if ((dDelta < 0) && (dLastDelta > 0)
                 && (dAccel < 0) && (dLastAccel > 0))
             {
              // ExtMapBuffer5[pos] = 0.0001;
              ExtMapBuffer6[pos] = 0.0001;
              bSell = true;  
             }
             else
             {
             // ExtMapBuffer3[pos] = EMPTY_VALUE;
               bSell = false;
             }
            
             
           }
         }
         dLastClose = dClose;
         dLastResult = dResult;
         dLastDelta = dDelta;
         dLastAccel = dAccel;
         lastValue = true;
         pos--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---