Einzelnen Beitrag anzeigen
  #6 (permalink)  
Alt 22.01.18
RetepM RetepM ist offline
Mitglied
 
Registriert seit: Feb 2016
Beiträge: 240
RetepM befindet sich auf einem aufstrebenden Ast
Standard

Hi, so könnte so was aussehen. Ich hoffe, es hilft Dir! Das ist für MT4.

################################################## ##

#property indicator_separate_window
#property indicator_buffers 4

#property indicator_color1 Red
#property indicator_color2 Green

#property indicator_color3 Orange
#property indicator_color4 DodgerBlue


// exported variables
extern double mylevel = 1;

// local variables
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 Buffer13[];
double Buffer23[];
double Buffer12[];
double Buffer22[];

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

int init()
{
if (false) ObjectsDeleteAll(); // clear the chart
IndicatorShortName("MACD Change Color");
IndicatorDigits(0);
IndicatorBuffers(4);

SetIndexBuffer(0, Buffer13);
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2, indicator_color1);
SetIndexBuffer(1, Buffer23);
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2, indicator_color2);

SetIndexBuffer(2, Buffer12);
SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 2, indicator_color3);
SetIndexBuffer(3, Buffer22);
SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 2, indicator_color4);


return(0);
}

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

int deinit()
{
if (false) ObjectsDeleteAll();

return(0);
}

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

int start()
{
OnEveryTick();

return(0);
}

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

void OnEveryTick()
{

int i;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
i = Bars - counted_bars;
// main calculation loop
while (i >= 0)
{
current = i;

if (Ask >= mylevel)
{
if (iMA(NULL, NULL,14,0,MODE_SMA,PRICE_CLOSE,current) > iMA(NULL, NULL,24,0,MODE_SMA,PRICE_CLOSE,current))
{
Buffer13[current]= (iMA(NULL, NULL,14,0,MODE_SMA,PRICE_CLOSE,current)-iMA(NULL, NULL,24,0,MODE_SMA,PRICE_CLOSE,current))*100;
Buffer23[current] = EMPTY_VALUE;
}
else
{
Buffer23[current]= (iMA(NULL, NULL,14,0,MODE_SMA,PRICE_CLOSE,current)-iMA(NULL, NULL,24,0,MODE_SMA,PRICE_CLOSE,current))*100;
Buffer13[current] = EMPTY_VALUE;
}
}

if (Bid <= mylevel)
{
if (iMA(NULL, NULL,14,0,MODE_SMA,PRICE_CLOSE,current) > iMA(NULL, NULL,24,0,MODE_SMA,PRICE_CLOSE,current))
{
Buffer12[current]= (iMA(NULL, NULL,14,0,MODE_SMA,PRICE_CLOSE,current)-iMA(NULL, NULL,24,0,MODE_SMA,PRICE_CLOSE,current))*100;
Buffer22[current] = EMPTY_VALUE;
}
else
{
Buffer22[current]= (iMA(NULL, NULL,14,0,MODE_SMA,PRICE_CLOSE,current)-iMA(NULL, NULL,24,0,MODE_SMA,PRICE_CLOSE,current))*100;
Buffer12[current] = EMPTY_VALUE;
}
}

i--;
}
}

################################################## ##