Moderator: admin
local MustB=false;
local MustS=false;
if (dip[period]<dim[period] and dip[period-1]>dim[period-1] and instance.parameters.TypeSignal=="direct") or (dip[period]>dim[period] and dip[period-1]<dim[period-1] and instance.parameters.TypeSignal=="reverse") then
MustS=true;
end
if (dip[period]>dim[period] and dip[period-1]<dim[period-1] and instance.parameters.TypeSignal=="direct") or (dip[period]<dim[period] and dip[period-1]>dim[period-1] and instance.parameters.TypeSignal=="reverse") then
MustB=true;
end
-- calculation of the crossing value
local iXStart, iXEnd;
iXStart = DMI.DIP:date(period - 1);
iXEnd = DMI.DIP:date(period);
local iXDelta;
iXDelta = iXEnd - iXStart;
local iYLine1Start, iYLine1End; -- rates for dip stream (DI+)
iYLine1Start = DMI.DIP:tick(period - 1);
iYLine1End = DMI.DIP:tick(period);
local iYLine2Start, iYLine2End; -- rates for dim stream (DI-)
iYLine2Start = DMI.DIM:tick(period - 1);
iYLine2End = DMI.DIM:tick(period);
local iXIntersection, CROSS;
local iYDelta1, iYDelta2;
iYDelta1 = iYLine1Start - iYLine1End;
iYDelta2 = iYLine2Start - iYLine2End;
local dA = iXStart * iYLine1End - iYLine1Start * iXEnd;
local dB = iXStart * iYLine2End - iYLine2Start * iXEnd;
local dC = iXDelta * iYDelta2 - iYDelta1 * iXDelta;
CROSS = (dB * iYDelta1 - dA * iYDelta2) / dC;
-- end of calculation
sunshine wrote:Hi PipGrabber,
I've added the Cross parameter with default value 25.
Unfortunately there is no function to easily define the crossing value, so I calculate it as follows:
- Code: Select all
-- calculation of the crossing value
local iXStart, iXEnd;
iXStart = DMI.DIP:date(period - 1);
iXEnd = DMI.DIP:date(period);
local iXDelta;
iXDelta = iXEnd - iXStart;
local iYLine1Start, iYLine1End; -- rates for dip stream (DI+)
iYLine1Start = DMI.DIP:tick(period - 1);
iYLine1End = DMI.DIP:tick(period);
local iYLine2Start, iYLine2End; -- rates for dim stream (DI-)
iYLine2Start = DMI.DIM:tick(period - 1);
iYLine2End = DMI.DIM:tick(period);
local iXIntersection, CROSS;
local iYDelta1, iYDelta2;
iYDelta1 = iYLine1Start - iYLine1End;
iYDelta2 = iYLine2Start - iYLine2End;
local dA = iXStart * iYLine1End - iYLine1Start * iXEnd;
local dB = iXStart * iYLine2End - iYLine2Start * iXEnd;
local dC = iXDelta * iYDelta2 - iYDelta1 * iXDelta;
CROSS = (dB * iYDelta1 - dA * iYDelta2) / dC;
-- end of calculation
And then I've added "AND CROSS > CrossValue" to the Buy/Sell conditions (where CrossValue is the value defined in the properties, CROSS is the value of DI+ and DI- crossing).
Avignon wrote:sunshine wrote:Hi PipGrabber,
I've added the Cross parameter with default value 25.
Unfortunately there is no function to easily define the crossing value, so I calculate it as follows:
- Code: Select all
-- calculation of the crossing value
local iXStart, iXEnd;
iXStart = DMI.DIP:date(period - 1);
iXEnd = DMI.DIP:date(period);
local iXDelta;
iXDelta = iXEnd - iXStart;
local iYLine1Start, iYLine1End; -- rates for dip stream (DI+)
iYLine1Start = DMI.DIP:tick(period - 1);
iYLine1End = DMI.DIP:tick(period);
local iYLine2Start, iYLine2End; -- rates for dim stream (DI-)
iYLine2Start = DMI.DIM:tick(period - 1);
iYLine2End = DMI.DIM:tick(period);
local iXIntersection, CROSS;
local iYDelta1, iYDelta2;
iYDelta1 = iYLine1Start - iYLine1End;
iYDelta2 = iYLine2Start - iYLine2End;
local dA = iXStart * iYLine1End - iYLine1Start * iXEnd;
local dB = iXStart * iYLine2End - iYLine2Start * iXEnd;
local dC = iXDelta * iYDelta2 - iYDelta1 * iXDelta;
CROSS = (dB * iYDelta1 - dA * iYDelta2) / dC;
-- end of calculation
And then I've added "AND CROSS > CrossValue" to the Buy/Sell conditions (where CrossValue is the value defined in the properties, CROSS is the value of DI+ and DI- crossing).
Hello,
After importing I have the message that is present yet it does not appear in the indicators.
Users browsing this forum: No registered users and 67 guests