Hi
to get first signal of the day (either buy or short) ignore rest of all signals of that day
This is I want to achive ,finally after one week of searching the final code is here.
I used this Statements
isEndOfDay = Nz(TimeFrameExpand(1, inDaily, expandPoint));
Buy = ExRem(Buy, isEndOfDay);
Short = ExRem(Short, isEndOfDay);
Thank you all
//_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("Name");
function ParamOptimize( pname, defaultval, minv, maxv, step )
{
return Optimize( pname,
Param( pname, defaultval, minv, maxv, step ),
minv, maxv, step );
}
EntryBufferPct = ParamOptimize("Entry Buffer %", 0, 0, 2, 0.1);
NewDay = (Day()!= Ref(Day(), -1)) OR BarIndex() == 0;
EndDay=Ref(NewDay,-1);
HighestOfDay = HighestSince(NewDay,H,1);
LowestOfDay = LowestSince(NewDay,L,1);
realbh = ValueWhen(NewDay,HighestOfDay ,1) * (1 + (EntryBufferPct/100));
realbl = ValueWhen(NewDay,LowestOfDay ,1) * (1 - (EntryBufferPct/100));
res=realbh;
sup=realbl;
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
supres=IIf(avn==1,sup,res);
supres_col=IIf(avn==1,colorGreen,colorRed);
Plot(supres,"",supres_col,styleStaircase|styleThick);
SetBarFillColor(supres_col);
Plot(C,"",supres_col,styleCandle);
Buy=avn==1 ;
Short=avn==-1 ;
isEndOfDay = Nz(TimeFrameExpand(1, inDaily, expandPoint));
Buy = ExRem(Buy, isEndOfDay);
Short = ExRem(Short, isEndOfDay);
Sell=Short;
Cover=Buy;
Filter=Buy OR Short ;
if (LastValue(Buy) )
{
AlertIf( Buy, "My alert"+FullName(), "BUY @ " + C, 1 );
ShellExecute("C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\pyamibridgeupstoxbuyOCO.py", "", "" );
}
if (LastValue(Short) )
{
AlertIf( Short, "My alert"+FullName(), "SHORT @ " + C, 1 );
ShellExecute("C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\pyamibridgeupstoxsellOCO.py", "", "" );
}
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorLime, 0,L, Offset=-20);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0,H, Offset=-20);
PlotShapes( Buy*shapeUpTriangle, colorBlue, 0, Low, -40 );
PlotShapes( Short*shapeDownTriangle, colorYellow, 0, Low, -40 );
_SECTION_END()