Greetings
I am runing the following AFL to place orders with Upstox Python Api script using shellExec
command for the symbol NIFTY18SEPFUt in 5 min Inter day data in Realtime.
It is placing orders under Bar replay.While in realtime it is not placing buy sell OCO orders.
no errors thrown.
my code is below
_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 );
}
// on 5 min data refresh only
RequestTimedRefresh(300);
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);
// To avoid previous day signals
Buy=avn==1 AND Now(3)==LastValue(DateNum());
Short=avn==-1 AND Now(3)==LastValue(DateNum());
Buy=ExRem(Buy, Short OR endday);Short=ExRem(Short,Buy OR endday);
Sell=Short;
Cover=Buy;
Filter=Buy OR Short ;
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorLime, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorRed, 0,H, Offset=-45);
//if (LastValue(DateNum()) == 091000)
//{
// Nz(StaticVarGet("BuyorderPlaced"))==False;
// Nz(StaticVarGet("SellorderPlaced"))==False;
//}
if ( LastValue(Buy) == True AND Nz(StaticVarGet("BuyorderPlaced"))==False)
{
AlertIF( Buy, "EMAIL", "Realtf buy alert on "+FullName(), 1 );
AlertIF( Buy, "", "Simple text alert", 1);
ShellExecute("C:\Users\Administrator\AppData\Local\Programs\Python\Python37\pyamibridgeupstoxbuyOCO.py", "", "" );
StaticVarSet("BuyorderPlaced",True);
//tradeType = "BUY";
//placeBracketOrder(AT_EXCHANGE, AT_SYMBOL, tradeType, AT_QUANTITY, buyPrice, TARGET, STOPLOSS, TRAILING_STOPLOSS, 1);
}
if ( LastValue(Short) == True AND Nz(StaticVarGet("SellorderPlaced"))==False)
{
AlertIF( Short, "EMAIL", "Realtf short alert on "+FullName(), 3 );
AlertIF( Short, "", "Simple text alert", 3 );
ShellExecute("C:\Users\Administrator\AppData\Local\Programs\Python\Python37\pyamibridgeupstoxsellOCO.py", "", "" );
StaticVarSet("SellorderPlaced",True);
//tradeType = "SELL";
//placeBracketOrder(AT_EXCHANGE, AT_SYMBOL, tradeType, AT_QUANTITY, sellPrice, TARGET, STOPLOSS, TRAILING_STOPLOSS, 1);
}
_SECTION_END();
The aim is place only one Buy and or Sell orders every day without my intervension.
kindly modify and guide me to make it work on every day.
thanking you.
V.Periasamy