Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bd957ab1af | |||
| 0ba2c53a35 | |||
| dde1849bb0 | |||
| e4e0bb483a | |||
| b784e9556d | |||
| 695a66b812 | |||
| bd3a18958e |
@@ -96,7 +96,7 @@ void OnTick()
|
||||
double MA1[]; // array to be filled by values of the first moving average
|
||||
double MA2[]; // array to be filled by values of the second moving average
|
||||
|
||||
if(rangeBars.GetMA1(MA1,startAtBar,numberOfBars) && rangeBars.GetMA1(MA2,startAtBar,numberOfBars))
|
||||
if(rangeBars.GetMA1(MA1,startAtBar,numberOfBars) && rangeBars.GetMA2(MA2,startAtBar,numberOfBars))
|
||||
{
|
||||
//
|
||||
// Values are stored in the MA1 and MA2 arrays and are now ready for use
|
||||
|
||||
@@ -39,7 +39,7 @@ ulong currentTicket;
|
||||
// the RangeBars indicator attached.
|
||||
//
|
||||
|
||||
#define SHOW_INDICATOR_INPUTS
|
||||
//#define SHOW_INDICATOR_INPUTS
|
||||
|
||||
//
|
||||
// You need to include the RangeBars.mqh header file
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#property copyright "Copyright 2017, AZ-iNVEST"
|
||||
#property link "http://www.az-invest.eu"
|
||||
|
||||
//#define RANGEBAR_INDICATOR_NAME "RangeBars\\RangeBarsOverlay211"
|
||||
//#define RANGEBAR_INDICATOR_NAME "RangeBars\\RangeBarsOverlay213"
|
||||
#define RANGEBAR_INDICATOR_NAME "Market\\Range Bars Charting"
|
||||
|
||||
#define RANGEBAR_OPEN 00
|
||||
|
||||
@@ -485,7 +485,7 @@ bool CMarketOrder::Modify(ulong ticket, bool stopsInPips = true, int stoploss =
|
||||
//do checks
|
||||
if(!tradingChecks.OkToModifyPosition(symbol,ticket,priceSL,priceTP))
|
||||
{
|
||||
Alert("Unable to modify: "+tradingChecks.GetCheckErrorToString());
|
||||
Print("Unable to modify: "+tradingChecks.GetCheckErrorToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -532,7 +532,7 @@ bool CMarketOrder::Modify(ulong ticket, double priceSL=0,double priceTP=0)
|
||||
//do checks
|
||||
if(!tradingChecks.OkToModifyPosition(symbol,ticket,priceSL,priceTP))
|
||||
{
|
||||
Alert("Unable to modify: "+tradingChecks.GetCheckErrorToString());
|
||||
Print("Unable to modify: "+tradingChecks.GetCheckErrorToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -623,7 +623,7 @@ bool CMarketOrder::ModifyPending(ulong ticket, double entry, bool stopsInPips =
|
||||
//do checks
|
||||
if(!tradingChecks.OkToModifyOrder(symbol,ticket,entry,priceSL,priceTP))
|
||||
{
|
||||
Alert("Unable to modify: "+tradingChecks.GetCheckErrorToString());
|
||||
Print("Unable to modify: "+tradingChecks.GetCheckErrorToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ bool CMarketOrder::ModifyPending(ulong ticket, double entry, double priceSL=0, d
|
||||
//do checks
|
||||
if(!tradingChecks.OkToModifyOrder(symbol,ticket,entry,priceSL,priceTP))
|
||||
{
|
||||
Alert("Unable to modify: "+tradingChecks.GetCheckErrorToString());
|
||||
Print("Unable to modify: "+tradingChecks.GetCheckErrorToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,121 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| OBV.mq5 |
|
||||
//| Copyright 2009-2017, MetaQuotes Software Corp. |
|
||||
//| http://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "2009-2017, MetaQuotes Software Corp."
|
||||
#property link "http://www.mql5.com"
|
||||
#property description "On Balance Volume"
|
||||
//--- indicator settings
|
||||
#property indicator_separate_window
|
||||
#property indicator_buffers 1
|
||||
#property indicator_plots 1
|
||||
#property indicator_type1 DRAW_LINE
|
||||
#property indicator_color1 DodgerBlue
|
||||
#property indicator_label1 "OBV"
|
||||
//--- input parametrs
|
||||
input ENUM_APPLIED_VOLUME InpVolumeType=VOLUME_TICK; // Volumes
|
||||
//---- indicator buffer
|
||||
double ExtOBVBuffer[];
|
||||
|
||||
//
|
||||
// Initialize RangeBar indicator for data processing
|
||||
// according to settings of the RangeBar indicator already on chart
|
||||
//
|
||||
|
||||
#include <AZ-INVEST/SDK/RangeBarIndicator.mqh>
|
||||
RangeBarIndicator customIndicator;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| On Balance Volume initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
void OnInit()
|
||||
{
|
||||
//--- define indicator buffer
|
||||
SetIndexBuffer(0,ExtOBVBuffer);
|
||||
//--- set indicator digits
|
||||
IndicatorSetInteger(INDICATOR_DIGITS,0);
|
||||
//---- OnInit done
|
||||
|
||||
customIndicator.SetGetVolumesFlag();
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| On Balance Volume |
|
||||
//+------------------------------------------------------------------+
|
||||
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[])
|
||||
{
|
||||
//
|
||||
// Process data through RangeBar indicator
|
||||
//
|
||||
|
||||
if(!customIndicator.OnCalculate(rates_total,prev_calculated,time))
|
||||
return(0);
|
||||
|
||||
int _prev_calculated = customIndicator.GetPrevCalculated();
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//--- variables
|
||||
int pos;
|
||||
//--- check for bars count
|
||||
if(rates_total<2)
|
||||
return(0);
|
||||
//--- starting calculation
|
||||
pos=_prev_calculated-1;
|
||||
//--- correct position, when it's first iteration
|
||||
if(pos<1)
|
||||
{
|
||||
pos=1;
|
||||
if(InpVolumeType==VOLUME_TICK)
|
||||
ExtOBVBuffer[0]=(double)customIndicator.Tick_volume[0];
|
||||
else ExtOBVBuffer[0]=(double)customIndicator.Real_volume[0];
|
||||
}
|
||||
//--- main cycle
|
||||
if(InpVolumeType==VOLUME_TICK)
|
||||
CalculateOBV(pos,rates_total,customIndicator.Close,customIndicator.Tick_volume);
|
||||
else
|
||||
CalculateOBV(pos,rates_total,customIndicator.Close,customIndicator.Real_volume);
|
||||
//---- OnCalculate done. Return new prev_calculated.
|
||||
return(rates_total);
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
//| Calculate OBV by volume argument |
|
||||
//+------------------------------------------------------------------+
|
||||
void CalculateOBV(int StartPosition,
|
||||
int RatesCount,
|
||||
const double &ClBuffer[],
|
||||
const long &VolBuffer[])
|
||||
{
|
||||
for(int i=StartPosition;i<RatesCount && !IsStopped();i++)
|
||||
{
|
||||
//--- get some data
|
||||
double Volume=(double)VolBuffer[i];
|
||||
double PrevClose=ClBuffer[i-1];
|
||||
double CurrClose=ClBuffer[i];
|
||||
//--- fill ExtOBVBuffer
|
||||
if(CurrClose<PrevClose) ExtOBVBuffer[i]=ExtOBVBuffer[i-1]-Volume;
|
||||
else
|
||||
{
|
||||
if(CurrClose>PrevClose) ExtOBVBuffer[i]=ExtOBVBuffer[i-1]+Volume;
|
||||
else ExtOBVBuffer[i]=ExtOBVBuffer[i-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
Reference in New Issue
Block a user