Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brenoperucchi/a5b6de37112e81d0cafe9ced8f520ffc to your computer and use it in GitHub Desktop.
Save brenoperucchi/a5b6de37112e81d0cafe9ced8f520ffc to your computer and use it in GitHub Desktop.
input
iGain(3.0);
iStop(550);
iPeriod(20);
iDesvio(2.00);
var
vUpBB : Float;
vDownBB : Float;
vUpBBLast : Float;
vDownBBLast : Float;
vClose : Float;
vlow : Float;
vMarket : Boolean;
vPrice : Float;
vPoints : Float;
vAux : Float;
function CandleAnalyze(vLow : float) : boolean;
var
i : integer;
minima_old : Float;
//result: boolean;
begin
result := false;
for i := 1 to 10 do
begin
minima_old := minima[i];
if (minima_old <= vLow) then
result := true;
end;
CandleAnalyze := result;
end;
function fPoints(price_open,price_close : float) : Float;
var
vPoints : integer;
vCount : integer;
begin
Result := price_open - price_close;
end;
begin
vUpBB := BollingerBands(2.50,30,1)|0|;
vDownBB := BollingerBands(2.50,30,1)|1|;
vUpBBLast := BollingerBands(2.50,30,1)[1]|0|;
vDownBBLast := BollingerBands(2.50,30,1)[1]|1|;
vClose := fechamento[0];
vLow := minima[1];
vPrice := Price[1];
Plot(vUpBB);
Plot2(vDownBB);
//vUpBB := BollingerBands(2.50,30,1)[1]|0|;
// if (high >= vUpBB) then
// else if (low <= vDownBB) then
if ( not IsSold and not IsBought) and (Time > 0905) and (Time < 1605) then
begin
if (high >= vUpBB) or (high[1] >= vUpBBLast) then
begin
PaintBar(clGreen);
SellShortLimit(vUpBB,1);
//BuyToCoverStop(Price + iStop);
end
else if (minima <= vDownBB) or (minima[1] <= vDownBBLast) then
begin
PaintBar(clRed);
BuyLimit(vDownBB,1);
//SellToCoverStop(Price + iStop);
end;
end
else begin
if (isSold) then
begin
//if (minima <= vDownBB) or (minima <= vDownBBLast) then
BuyToCoverStop(Price + iStop);
BuyToCoverLimit(vDownBB,1);
if(Price = VDownBB) then
vPoints := fPoints(vDownBB, Price);
end
else if (IsBought) then
begin
//if (high >= vUpBB) or (high[1] >= vUpBBLast) then
vPoints := fPoints(BuyPrice, vUpBB);
SellToCoverStop(Price - iStop);
SellToCoverLimit(vUpBB,1);
if(not IsBought) then
vPoints := fPoints(vDownBB, Price);
end;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment