signal appearing suddenly

burai123

Active Member
#1
sometimes buy/sell signal appearing suddenly. suppose candle(1) formed at 12 pm and at that time there was no buy/sell signal. but at 12.20 pm when candle(4) formed then suddenly buy/sell signal generated at candle(1).
members please help me and correct the code if needed or give me some suggestions.
the code is -

_SECTION_BEGIN("MACD Exploration");
r1 = Param( "Fast avg", 10, 2, 200, 1 );
r2 = Param( "Slow avg", 25, 2, 200, 1 );
r3 = Param( "Signal avg", 4, 2, 200, 1 );
Z=Param("zig",0.8,0,10,0.1);


Cond1 = Cross(MACD(r1,r2),Signal(r1,r2,r3));
Cond3 = Zig(C,z)>Ref(Zig(C,z),-4);
Buy = Cond1 AND Cond3;

Cond4 = Cross(Signal(r1,r2,r3),MACD(r1,r2));
Cond6 = Zig(C,z)<Ref(Zig(C,z),-4);
Sell = Cond4 AND Cond6;

Trigger = WriteIf(Buy, "Buy", "") + WriteIf(Sell, "Sell", "");

_N(Title = StrFormat("{{NAME}} {{DATE}} {{INTERVAL}}: O=%1.2f, H=%1.2f, L=%1.2f, C=%1.2f, V=%1.0f\n{{VALUES}}", O, H, L, C, V));

BG = IIf(Buy, colorPaleGreen, IIf(Sell, colorRose, colorDefault));
FG = IIf(Buy, colorDarkGreen, IIf(Sell, colorDarkRed, colorDefault));

if(Status("action") == actionIndicator)
{
Plot(C, "", colorGrey50, styleBar);
PlotShapes(IIf(Buy, shapeCircle, shapeNone),colorBlue, 0,L, Offset=-60);
PlotShapes(IIf(Sell, shapeCircle, shapeNone),colorWhite, 0,H, Offset=-30);
PlotShapes(shapeDownArrow*Sell,colorYellow,0,SellPrice,0);
PlotShapes(shapeUpArrow*Buy,colorYellow,0,BuyPrice,0);
}

//------------------------------------------------------------------------------------------------
if(Status("action") == actionExplore)

Filter = Buy OR Sell;
SetOption("NoDefaultColumns", True);

AddTextColumn(Name(), "Symbol", 77, FG, BG, 120);
AddColumn(DateTime(), "Date", formatDateTime, FG, BG, 100);
AddColumn(TimeNum() ,"Time",1);
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn(V, "Volume");
AddColumn(Ref(V,-1),"P-Vol");
AddColumn(V/Ref(V,-1)*100,"Increase in Vol");
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );

shape = Buy * shapeHollowUpTriangle + Sell * shapeHollowDownTriangle;

PlotShapes( shape, IIf( Buy, colorBlue, colorWhite ), 0, IIf( Buy, Low, High ) );

GraphXSpace = 7;

GraphXSpace = 7;
_SECTION_END();
 

burai123

Active Member
#3
Cond3 = Zig(C,z)>Ref(Zig(C,z),-4);


the above statement look into the future to generate the signal, my friend.
cheers
Ztop
thank you for your suggestion. but when the parameters are (12,26,9,1) respectively then signals not appearing suddenly.
 

Similar threads