First Indicator and Trading System for Meta Trader Platform


After checking lot of Indicators from Forum at www.http://forexfactory.com. I wanted to create one nice Indicator as a pre-cursor for my own EA.  It will also help me to do scalping on 1 Min chart, until such time.

Indicator helps me to pay less attention is price action and helps me to just look at the chart only when required. This reduces lot of strain.

//+——————————————————————+
//|                                                     Infinite.mq4 |
//|                                       Copyright © 2011, pannet1  |
//|                                                pannet1@yahoo.com |
//+——————————————————————+
#property  copyright “Copyright © 2011, pannet1”
#property  link      “https://pannet1.wordpress.com”

//—-
#property indicator_separate_window
#property indicator_buffers  8
#property indicator_minimum  0
#property indicator_maximum  2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 PaleGreen
#property indicator_color4 LightSalmon
//—-
extern int MA = 20;
extern int MA_Type = 1;
extern int StDev = 2;
extern int Shift = 0;

//—- indicator buffers
double CrossUp[];
double CrossDown[];
double MAUp[];
double MADown[];
double TrendUp[];
double TrendDown[];
double Up[];
double Down[];
//+——————————————————————+
//| Custom indicator initialization function                         |
//+——————————————————————+
int init()
{
//—- indicator line

SetIndexStyle (0, DRAW_ARROW, 0,1, indicator_color2);
SetIndexArrow (0, 163);
SetIndexBuffer(0, CrossUp);
SetIndexStyle (1, DRAW_ARROW, 0,1, indicator_color1);
SetIndexArrow (1, 163);
SetIndexBuffer(1, CrossDown);

SetIndexStyle (2, DRAW_ARROW,0,1, indicator_color1);
SetIndexArrow (2, 241);
SetIndexBuffer(2, MAUp);
SetIndexStyle (3, DRAW_ARROW,0,1, indicator_color2);
SetIndexArrow (3, 242);
SetIndexBuffer(3, MADown);

SetIndexStyle (4, DRAW_ARROW, 0,1, indicator_color3);
SetIndexArrow (4, 110);
SetIndexBuffer(4, TrendUp);
SetIndexStyle (5, DRAW_ARROW, 0,1, indicator_color4);
SetIndexArrow (5, 110);
SetIndexBuffer(5, TrendDown);

SetIndexStyle (6, DRAW_ARROW, 0,1, indicator_color1);
SetIndexArrow (6, 236);
SetIndexBuffer(6, Up);
SetIndexStyle (7, DRAW_ARROW, 0,1, indicator_color2);
SetIndexArrow (7, 238);
SetIndexBuffer(7, Down);

//—- name for DataWindow and indicator subwindow label
IndicatorShortName(“Infinite”);
return(0);
}
//+——————————————————————+
//|                                                                  |
//+——————————————————————+
int deinit()
{
//—-
return(0);
}
//+——————————————————————+
//|  Infinite V1                                               |
//+——————————————————————+
int start()
{
int counted_bars = IndicatorCounted();
// int i;
int limit;
//—- check for possible errors
if(counted_bars < 0)
return(-1);
//—- last counted bar will be recounted
if(counted_bars > 0)
counted_bars–;
limit = Bars – counted_bars;
//—-
if(limit <= MA)
limit=1;
//—–

// Begin Main Loop Function
for(int i=0; i<limit; i++)
{
double  MAnow = iMA(NULL, 0, MA, 0, MA_Type,
PRICE_CLOSE, i);
double  MAprevious = iMA(NULL, 0, MA, 0, MA_Type,
PRICE_CLOSE, i + 1);
double  MAafter = iMA(NULL, 0, MA, 0, MA_Type,
PRICE_CLOSE, i – 1);
double  MAswap = 0;

//—-
double  BB_Upper = iBands(NULL, 0, MA, StDev, Shift,
PRICE_CLOSE, MODE_UPPER,  i);

double  BB_Lower = iBands(NULL, 0, MA, StDev, Shift,
PRICE_CLOSE, MODE_LOWER,  i);

//- Correct error in MAafter if bar (0) is latest

if (i==0) { // if we are in present bar
MAswap = MAnow;
if (MAswap > 0)
{
MAafter    = MAnow;
MAnow      = MAprevious;
MAprevious = MAswap;
}
}

//—-   Determine Bar type
double LOB =  Low[i];
double HOB =  High[i];
double OOB =  Open[i];
double COB =  Close[i];

bool BULLISH = false;
bool BEARISH = false;
bool DOJI    = false;

if ( OOB<COB )
BULLISH = true;

if ( OOB>COB )
BEARISH = true;

if ( (OOB-COB) == 0 )
DOJI = true;
//— end determine Bar type

//—– Determine dynamic Take Profit or Stop Loss
if(
(OOB < MAnow && COB > MAnow)
)
CrossDown[i] = 0.25;

if(
(OOB > MAnow && COB < MAnow)
)
CrossUp[i] = 1.25;
//——–

//– Signal Trend Change
if(
(MAnow < MAprevious)
&&(MAnow < MAafter)
)
MAUp[i] = 0.75;
{
Print(“inside function MAUp, at Bar “, i);
Print(“Previous: “,  MAprevious, ” now: “, MAnow, ” after:”, MAafter);
}

if(
(MAnow > MAprevious)
&& (MAnow > MAafter)
)
MADown[i] = 0.75;
//– end Trend Change

//– Determine present trend
if(
(MAnow > MAprevious)
&&(MAnow < MAafter)
)
TrendUp[i] = 0.75;

if(
(MAnow < MAprevious)
&&(MAnow > MAafter)
)
TrendDown[i] = 0.75;
//– end Trend Change

//— Signal Overbought or Oversold with Bollinger Band
if ( (HOB > BB_Lower && LOB < BB_Lower && HOB < MAnow) &&
(BULLISH==true)
)
Up[i] = 0.25;

if ( (HOB > BB_Upper && LOB < BB_Upper && LOB > MAnow) &&
(BEARISH==true)
)
Down[i] = 1.25;
//———-

}
return(0);
}
//+——————————————————————+

How to Trade
Get Ready when the Slanting Arrows are up or down.

Buy (Enter from Bottom Row arrow pointing upwards)
When a Sell Stop is encountered or
When the trend is changed (Moving average is UP)
Exit when a Buy Stop is encountered.
Clue: After entering focus attention in the top row.

Sell (Enter from Top Row arrow pointing downwards)
When a Buy Stop is encountered or
When the trend is changed (Moving average is Down)
Exit when a Sell Stop is encountered
Clue: After entering focus attention in the Bottom row.

 

Edit:  I just shifted the MaAfter value and every other MAs to the left by ONE (1) and everything works fine.

Also made few changes to have Stops and “Take Profit to one Row (Top row for Buy and Bottom row for Sell).

Advertisements

Setting up an Extended Desktop for Watching Charts and Indicators


My friend wanted to use more than one monitor for trading purpose (watching charts and indicators) from within Meta Trader. Actually the solution already exists if you have a laptop with Intel Chipset and an out for external Monitor.

Intel Media Graphics Accelator for MObile
Virutal Desktop

 

There could be similar solution for other Chipset manufacturers too (Nvidea etc).

intel extended desktop
extended desktop

Select “extended desktop” from operating mode. That’s it. Now you can move the windows spanning from your laptop to the LCD Monitor.

I have a Samsung N150 Plus netbook and a Samsung LCD TV in which I personally use this setup.