Thanks Tomasz for the quick response - I only posted the section of code that is not recognized - Here is the full AFL
_N(SectionName = "ABS");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +
WriteVal( V, 1.0 ) +
" {{VALUES}}",
O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ),
ParamStyle("Style",styleNoTitle|styleBar,maskAll) );
RequestTimedRefresh( 1 );
ibc = GetTradingInterface("IB");
EnableAutoTrade = ParamList("Enable Autotrade", "No|Yes", 0);
NQty = Param("Qty to Buy/Sell?",500,100,5000,100);
Transmit = ParamToggle("Transmit","OFF|ON",0);
Reset = ParamTrigger("Reset All","RESET");
LastTrade = StaticVarGetText("LastTrade");
BuyOrderID = StaticVarGetText("BuyOrderID");
SellOrderID = StaticVarGetText("SellOrderID");
BuyPending = ibc.IsOrderPending(BuyOrderID);
SellPending = ibc.IsOrderPending(SellOrderID);
IBPosSize = ibc.GetPositionSize( Name() );
BuyStatus = ibc.GetStatus( BuyORderID, True );
SellStatus = ibc.GetStatus( SellORderID, True);
OptimizerSetEngine("trib");
OptimizerSetOption("Runs", 5 );
OptimizerSetOption("MaxEval", 1000 ); // 5000 evaluations max
Buy=Sell=Short=Cover=O;
A_F=Param("P_Factor",1,1,180,0.001);
FT_1 =(Param("FT1",-2,-2,30,0.001));
FT_2 =Param("FT2",-2,-2,30,0.001);
FT_3 =Param("FT3",61.743,-2,30,0.001);
FT_4=Param("P_Factor",29,1,180,0.001);
pi=22/7;
Rtd = 180 / Pi;
Dtr = 1 / Rtd;
x=(O+C+H+L)/4;
FT_1=FT_1*(A_F*DTR);
FT_2=FT_2*(A_F*DTR);
FT_3=FT_3*(A_F*DTR);
y3=FT_1*x*exp(3) + FT_2*x*exp(2) + FT_3*x;
con_1=WMA(x,y3);
for( i = 1 ; i < BarCount-2; i++ )
{
if (con_1[i] <con_1[i-1] && con_1[i] <con_1[i+1]) B_sig[i]=1;
else
B_sig[i] =0;
if (con_1[i] >con_1[i-1] && con_1[i] >con_1[i+1]) S_sig[i]=1;
else
S_sig[i] =0;
}
B_sig =ExRem(B_sig,S_sig);
S_sig =ExRem(S_sig,B_sig);
Buy = B_sig==1;
Sell = S_sig==1;
Sell = S_sig==1;
Cover =B_sig==1;
Buy = ExRem(Buy,Sell);
Short = ExRem(Short,Cover);
Sell = ExRem(Sell,Buy);
Cover = ExRem(Cover,Short);
////////////////////////////// EXECEUTION ENGINE //////////////////////////
if(EnableAutoTrade == "Yes")
{
if( LastValue(Buy ) )
{
if( LastTrade == "Sell" OR LastTrade == "" )
{
BuyOrderID= ibc.ModifyOrder( BuyOrderID, Name(), "Buy", NQty, "MKT", 0, 0, "Day", Transmit);
StaticVarSetText("BuyOrderID",BuyOrderID);
StaticVarSetText("LastTrade", "Buy");
SetChartBkColor( colorBrightGreen ) ;
}
}
if( LastValue(Sell ) )
{
if( LastTrade == "Buy" OR LastTrade == "" )
{
SellORderID = ibc.ModifyOrder( SellORderID , Name(), "Sell", NQty, "MKT", 0, 0, "Day", Transmit);
StaticVarSetText("SellOrderID",SellOrderID);
StaticVarSetText("LastTrade", "Sell");
SetChartBkColor( colorRed ) ;
}
}
else if( Reset )
{
StaticVarSetText("BuyOrderID","");
if( BuyPending ) ibc.CancelOrder( BuyOrderID );
StaticVarSetText("SellOrderID","");
if( SellPending ) ibc.CancelOrder( SellOrderID );
StaticVarSetText("LastTrade", "");
ibc.CloseAllOpenPositions();
}
LastTWSMsg = ibc.getLastError( 0 );
BuyStatus = WriteIf( BuyPending, BuyOrderID+", Status: "+BuyStatus,"");
SellStatus= WriteIf( SellPending, SellOrderID+", Status: "+SellStatus,"");
Title = "\n"+
"Last TWS Error Msg: "+LastTWSMsg+"\n"+
" BuyOrderID: "+BuyOrderID+" "+BuyStatus+"\n"+
" SellOrderID: "+SellOrderID+" "+SellStatus+"\n"+
" Last Trade: "+LastTrade+"\n"+
" TWS Position Size: "+NumToStr(IBPosSize,1.0,False);
Plot(C,"Close",colorBlack,styleBar);
}
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,H,con_1,-45);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBrightGreen,L,con_1,-45);
dist = 1*ATR(60);
for( i = 0; i < BarCount; i++ )
{
{if( Buy[i] ) PlotText( "B $" + C[ i ], i-1, L[ i ]-dist[i], colorbrightGreen,Null,-95 );
if( Short[i] ) PlotText( "S $" + C[ i ], i-1, H[ i ]+dist[i], colorRed,Null,40 );}
}
Moderator comment: The ending (closing) tag for the code section needs to have slash like this [/code]
You have used ending tag the same as opening tag (without slash). I corrected it.