116 lines
4.7 KiB
MQL5
116 lines
4.7 KiB
MQL5
|
//+------------------------------------------------------------------+
|
||
|
//| I-Trade-Start.mq5 |
|
||
|
//| Thorsten Fischer Copyright 2019-2020 |
|
||
|
//| https://mql5.tfsystem.de |
|
||
|
//+------------------------------------------------------------------+
|
||
|
#property copyright "Thorsten Fischer Copyright 2019-2020"
|
||
|
#property link "https://mql5.tfsystem.de"
|
||
|
#property version "1.00"
|
||
|
#property strict
|
||
|
#property indicator_separate_window
|
||
|
//#property indicator_minimum 1
|
||
|
//#property indicator_maximum 10
|
||
|
#property indicator_buffers 8
|
||
|
#property indicator_plots 2
|
||
|
#property indicator_label1 "TradeSignalUp"
|
||
|
#property indicator_type1 DRAW_ARROW
|
||
|
#property indicator_color1 clrSlateBlue
|
||
|
//#property indicator_style1 STYLE_SOLID
|
||
|
//#property indicator_width1 1
|
||
|
#property indicator_label2 "TradeSignalDown"
|
||
|
#property indicator_type2 DRAW_ARROW
|
||
|
#property indicator_color2 clrRed
|
||
|
//#property indicator_style2 STYLE_SOLID
|
||
|
//#property indicator_width2 1
|
||
|
//--- indicator buffers
|
||
|
double Buffer_Arrow_Up[];
|
||
|
double Buffer_Arrow_Down[];
|
||
|
double Buffer_MA_Oben[];
|
||
|
double Buffer_MA_Unten[];
|
||
|
double Buffer_HA_Open[];
|
||
|
double Buffer_HA_High[];
|
||
|
double Buffer_HA_Low[];
|
||
|
double Buffer_HA_Close[];
|
||
|
//double Buffer_Color[];
|
||
|
//double Buffer_Reserve[];
|
||
|
//+------------------------------------------------------------------+
|
||
|
//| Custom indicator initialization function |
|
||
|
//+------------------------------------------------------------------+
|
||
|
int OnInit()
|
||
|
{
|
||
|
//--- indicator buffers mapping
|
||
|
SetIndexBuffer(0,Buffer_Arrow_Up,INDICATOR_DATA);
|
||
|
SetIndexBuffer(1,Buffer_Arrow_Down,INDICATOR_DATA);
|
||
|
SetIndexBuffer(2,Buffer_MA_Oben,INDICATOR_CALCULATIONS);
|
||
|
SetIndexBuffer(3,Buffer_MA_Unten,INDICATOR_CALCULATIONS);
|
||
|
SetIndexBuffer(4,Buffer_HA_Open,INDICATOR_CALCULATIONS);
|
||
|
SetIndexBuffer(5,Buffer_HA_High,INDICATOR_CALCULATIONS);
|
||
|
SetIndexBuffer(6,Buffer_HA_Low,INDICATOR_CALCULATIONS);
|
||
|
SetIndexBuffer(7,Buffer_HA_Close,INDICATOR_CALCULATIONS);
|
||
|
//SetIndexBuffer(2,Buffer_Color,INDICATOR_COLOR_INDEX);
|
||
|
//SetIndexBuffer(3,Buffer_Reserve,INDICATOR_CALCULATIONS);
|
||
|
IndicatorSetInteger(INDICATOR_DIGITS,0);
|
||
|
IndicatorSetString(INDICATOR_SHORTNAME,"Trade Signal");
|
||
|
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,5);
|
||
|
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,5);
|
||
|
//PlotIndexSetString(0,PLOT_LABEL,"Trade Signal Up");
|
||
|
PlotIndexSetInteger(0,PLOT_ARROW,82);
|
||
|
PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,0);
|
||
|
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
|
||
|
//PlotIndexSetString(1,PLOT_LABEL,"Trade Signal Down");
|
||
|
PlotIndexSetInteger(1,PLOT_ARROW,82);
|
||
|
PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,0);
|
||
|
PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0);
|
||
|
//---
|
||
|
return(INIT_SUCCEEDED);
|
||
|
}
|
||
|
//+------------------------------------------------------------------+
|
||
|
//| deinitialization function |
|
||
|
//+------------------------------------------------------------------+
|
||
|
void OnDeinit(const int reason)
|
||
|
{
|
||
|
if (i_MA_Handle_Oben!=INVALID_HANDLE)
|
||
|
{
|
||
|
IndicatorRelease(i_MA_Handle_Oben);
|
||
|
}
|
||
|
if (i_MA_Handle_Unten!=INVALID_HANDLE)
|
||
|
{
|
||
|
IndicatorRelease(i_MA_Handle_Unten);
|
||
|
}
|
||
|
Comment("");
|
||
|
}
|
||
|
//+------------------------------------------------------------------+
|
||
|
//| 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 OnCalculate(const int rates_total,
|
||
|
// const int prev_calculated,
|
||
|
// const int begin,
|
||
|
// const double &price[])
|
||
|
{
|
||
|
//---
|
||
|
//bool z=true;
|
||
|
int i=prev_calculated-1;
|
||
|
if(i<0) i=0;
|
||
|
for(i; i<rates_total && !IsStopped(); i++)
|
||
|
{
|
||
|
(open[i]<close[i])?Buffer_Arrow_Up[i]=i:Buffer_Arrow_Down[i]=i;
|
||
|
//(z)?z=false:z=true;
|
||
|
//Print(__FUNCTION__+" rates_total = "+(string)rates_total+" prev_calculated = "+(string)prev_calculated+" begin = "+(string)begin+" price[i] = "+(string)price[i]);
|
||
|
//Buffer_Color[i]=1;
|
||
|
//Buffer_Reserve[i]=i+1;
|
||
|
}
|
||
|
//--- return value of prev_calculated for next call
|
||
|
return(rates_total);
|
||
|
}
|
||
|
//+------------------------------------------------------------------+
|