Invalid use of "OR" operator, was: Syntax error through on "FLIP" and

_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("EMA Crossover");

EMA1=Param("EMA-1", 20, 100, 1, 0);
EMA2=Param("EMA-2", 50, 100, 1, 0);
PORP=ParamToggle("Percentage or Point", "Percentage | Point", 0);
TG = Param("Target", 1, 0.05, 100, 0.05);
SL = Param("StopLoss", 1, 0.05, 100, 0.05);
_SECTION_END();

_SECTION_BEGIN( "Market Setting" );
IM = ParamToggle( "Intraday Mode", "off|on", 1);
TradeStartTime = Param( "Trade Start From(HHMM)", 915, 600, 2400, 1);
NoEntryTime = Param("No Entry After(HHMM)", 1445, 900, 2400, 1);
ExitTime = Param( "Square Off Time(HHMM)", 1515, 900, 2400, 1);

FC = DateNum() != Ref( DateNum(), -1 );
LC = DateNum() != Ref( DateNum(), 1 );
EntryTime = TimeNum() >= TradeStartTime * 100 AND TimeNum() < NoEntryTime * 100;
MarketClose = Flip( TimeNum() >= ExitTime*100, LC);
_SECTION_END();

_SECTION_BEGIN("Trading Logics");

EMAA=EMA(C, EMA1);
EMAB=EMA(C, EMA2);

Plot(EMAA, "EMA-1", colorDefault, styleLine, colorRed);
Plot(EMAB, "EMA-2", colorDefault, styleDots, colorBlue);

PBuy = Cross(EMAA, EMAB) ;
PShort=Cross(EMAB, EMAA);
PBuy = ExRem(PBuy, Pshort OR (IM AND FC));
PShort = ExRem(PShort, PBuy OR (IM AND FC));

BZ = Flip(PBuy, PShort, OR (IM AND FC));
SZ = Flip(PShort, PBuy, OR (IM AND FC));

Buy = BZ AND EntryTime;
Short = SZ AND EntryTime;

Sell = PShort OR MarketClose;
Cover = Pbuy OR MarketCose;

Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

BuyPrice=ValueWhen(Buy,0,1);
ShortPrice=ValueWhen(Short,0,1);

OpenLong=Flip(Buy,Sell);
OpenShort=Flip(Short,Cover);


if(PORP)
{
	BTP1=BuyPrice+TG;
	STP1=ShortPrice-TG;
}
else
{
	BTP1=round(BuyPrice*(1+TG/100);
	STP1=round(ShortPrice*(1-TG/100);

}

BTPrice1 = IIf(OpenLong OR Sell, BTP1, Null);
STPrice1 = IIf(OpenShort OR Cover, STP1, Null);

if(PORP)
{
	BSLP=BuyPrice-SL;
	SSLP=ShortPrice+SL;
}
else
{
	BSLP=(round(BuyPrice*(1-SL/100));
	SSLP=(round(ShortPrice*(1+SL/100));
}

BSLPrice = IIf(OpenLong OR Sell, BSLP, Null);
SSLPrice1 = IIf(OpenShort OR Cover, SSLP, Null);

TSell1 = (H>=BTPrice1) AND !IsNull(BTPrice1);
SLSell = (L<=BSLPrice AND !Buy) AND !IsNull(BSLPrice);

TCover1 = (L<=STPrice1) AND !IsNull(STPrice1);
SLCover = (H>=SSLPrice AND !Short) AND !IsNull(SSLPrice);

Sell = (Sell OR TSell1) OR SLSell;
Cover = (Cover OR TCover1) OR SLCover;

Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

OpenLong=Flip(Buy,Sell);
OpenShort=Flip(Short,Cover);

BuyPrice = IIf(OpenLong OR Sell, BuyPrice, Null);
ShortPrice = IIf(OpenShort OR Cover, ShortPrice, Null);
BTPrice1 = IIf(OpenLong OR Sell, BTPrice1, Null);
STPrice1 = IIf(OpenShort OR Cover, STPrice1, Null);
BSLPrice = IIf(OpenLong OR Sell, BSLPrice, Null);
SSLPrice = IIf(OpenShort OR Cover, SSLPrice, Null);
SellPrice=IIf(Sell*SLSell,BSLPrice, IIf(Sell*TSell,BTPrice1,IIf(Sell,Close,Null )) );
CoverPrice=IIf(Cover*SLCover,SSLPrice, IIf(Cover*TCover1,STPrice1,IIf(Cover,Close,Null)));


PlotShapes(IIf(Buy, shapeSquare, shapeNone), colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone), colorLime, 0, L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone), colorWhite, 0, L, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone), colorRed, 0, H, Offset=-40);
PlotShapes(IIf(Short, shapeSquare, shapeNone), colorOrange, 0, H, Offset=-50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone), colorWhite, 0, H, Offset=-45);

PlotShapes(IIf(Cover, shapeUpTriangle, shapeNone), colorCustom7, 0, L, Offset=-20);
PlotShapes(IIf(Sell, shapeDownTriangle, shapeNone), colorCustom2, 0, H, Offset=-20);

Plot(BuyPrice, "Buy Price", colorBrightGreen, styleLine|styleNoTitle|styleNoLabel);
Plot(ShortPrice, "Short Price", colorRed, styleLine|styleNoTitle|styleNoLabel);

PlotShapes(TSell*shapeStar, colorBrightGreen, 0, H, 10, 0);
PlotShapes(TCover1*shapeStar, colorRed, 0, L, -10, 0);

PlotShapes(SLSell*shapeStar, colorBlue, 0, L, -20, 0);
PlotShapes(SLCover*shapeStar, colorYellow, 0, H, 20, 0);

Plot(BTPrice1, "BuyTargetPrice", colorGreen, styleLine|styleThick|styleDashed|styleNoTitle);
Plot(STPrice1, "ShortTargetPrice", colorRed, styleLine|styleThick|styleDashed|styleNoTitle);

Plot(BSLPrice, "BuySLPrice", colorLightOrange, styleLine|styleDashed|styleNoTitle);
Plot(SSLPrice, "ShortSLPrice", colorLightOrange, styleLine|styleDashed|styleNoTitle);

_SECTION_END

In your code, you have OR operator without first operand. OR operator needs BOTH operands:

somethingA OR somethingB

You can't have just OR somethingB

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.