Hello All,
I have a problem with exit trade at EOD end of trading session 11:00 PM. I am trying the following code.
tim=Param("Square off time ",230000,09000,240000);
StopLevel = Param( "Stop Loss (%)", 0.06, 0.01, 10, 0.01 );
TgtLevel = Param( "Profit target (%)", 0.25, 0.01, 10, 0.01 );
ApplyStop( stopTypeLoss, stopModePercent, StopLevel, True );
ApplyStop( stopTypeProfit, stopModePercent, TgtLevel, True );
Equity( 1, 0 );
sellcond2=Sell==2; covercond2=Cover==2;
sellcond3=Sell==3; covercond3=Cover==3;
Sell=ExRem(Sell,Cover);
Cover=ExRem(Cover,Sell);
sellcond3=TimeNum()>tim=Sell==4; covercond=TimeNum()>tim=Cover==4;
if ( LastValue(Ref(covercond2,-1) ==True ) OR LastValue(Ref(covercond3,-1) ==True) OR LastValue(Cover)==True)
{
AT_QUANTITY = Param("Order quantity (lot size)", 1, 0, 300000, 10);
placeOrderAdvancedNew(AT_EXCHANGE, AT_INSTRUMENT, Name(), "BUY", AT_PRODUCT_TYPE, AT_ORDER_TYPE, AT_QUANTITY, 0, defaultTriggerPrice(), defaultDisclosedQuantity(), AT_OPTION_TYPE, AT_STRIKE_PRICE, AT_EXPIRY, defaultClientId(), defaultValidity(), defaultTraderType(), defaultMarketProtectionPct(), defaultStrategyId(), defaultComments(),
"regular", 0, 0, 0);
}
if ( LastValue(Ref(sellcond2,-1) ==True ) OR LastValue(Ref(sellcond3,-1) ==True) OR LastValue(Sell)==True )
{ AT_QUANTITY = Param("Order quantity (lot size)", 1, 0, 300000, 10);
placeOrderAdvancedNew(AT_EXCHANGE, AT_INSTRUMENT, Name(), "SELL", AT_PRODUCT_TYPE, AT_ORDER_TYPE, AT_QUANTITY,0, defaultTriggerPrice(), defaultDisclosedQuantity(), AT_OPTION_TYPE, AT_STRIKE_PRICE, AT_EXPIRY, defaultClientId(), defaultValidity(), defaultTraderType(), defaultMarketProtectionPct(), defaultStrategyId(), defaultComments(),
"regular", 0, 0, 0);
}
//PlotShapes(IIf(sellcond1,shapeSmallDownTriangle,shapeNone),colorOrange,0,H,-25);
PlotShapes(IIf(sellcond3,shapeHollowDownArrow,shapeNone),colorOrange,0,H,-15);
PlotShapes(IIf(sellcond2,shapeStar,shapeNone),colorOrange,0,H,-15);
//PlotShapes(IIf(exit,shapeStar,shapeNone),colorOrange,0,H,-15);
///PlotShapes(IIf(covercond1,shapeSmallUpTriangle,shapeNone),colorLime,0,L,-25);
PlotShapes(IIf(covercond3,shapeHollowUpArrow,shapeNone),colorAqua,0,L,-25);
PlotShapes(IIf(covercond2,shapeStar,shapeNone),colorAqua,0,L,-25);
//PlotShapes(IIf(exit,shapeStar,shapeNone),colorAqua,0,L,-25);
WriteIf( Sell == 1, "EOD exit",WriteIf( Sell == 3, "Profit Tgt",WriteIf( Sell == 2, "Max stop", "" ) ));
WriteIf( Cover == 1, "EOD exit",WriteIf( Cover == 3, "Profit Tgt",WriteIf( Cover == 2, "Max stop", "" ) ));
Getting false exit orders. Please have a look on screen shot.
I have a problem with exit trade at EOD end of trading session 11:00 PM. I am trying the following code.
tim=Param("Square off time ",230000,09000,240000);
StopLevel = Param( "Stop Loss (%)", 0.06, 0.01, 10, 0.01 );
TgtLevel = Param( "Profit target (%)", 0.25, 0.01, 10, 0.01 );
ApplyStop( stopTypeLoss, stopModePercent, StopLevel, True );
ApplyStop( stopTypeProfit, stopModePercent, TgtLevel, True );
Equity( 1, 0 );
sellcond2=Sell==2; covercond2=Cover==2;
sellcond3=Sell==3; covercond3=Cover==3;
Sell=ExRem(Sell,Cover);
Cover=ExRem(Cover,Sell);
sellcond3=TimeNum()>tim=Sell==4; covercond=TimeNum()>tim=Cover==4;
if ( LastValue(Ref(covercond2,-1) ==True ) OR LastValue(Ref(covercond3,-1) ==True) OR LastValue(Cover)==True)
{
AT_QUANTITY = Param("Order quantity (lot size)", 1, 0, 300000, 10);
placeOrderAdvancedNew(AT_EXCHANGE, AT_INSTRUMENT, Name(), "BUY", AT_PRODUCT_TYPE, AT_ORDER_TYPE, AT_QUANTITY, 0, defaultTriggerPrice(), defaultDisclosedQuantity(), AT_OPTION_TYPE, AT_STRIKE_PRICE, AT_EXPIRY, defaultClientId(), defaultValidity(), defaultTraderType(), defaultMarketProtectionPct(), defaultStrategyId(), defaultComments(),
"regular", 0, 0, 0);
}
if ( LastValue(Ref(sellcond2,-1) ==True ) OR LastValue(Ref(sellcond3,-1) ==True) OR LastValue(Sell)==True )
{ AT_QUANTITY = Param("Order quantity (lot size)", 1, 0, 300000, 10);
placeOrderAdvancedNew(AT_EXCHANGE, AT_INSTRUMENT, Name(), "SELL", AT_PRODUCT_TYPE, AT_ORDER_TYPE, AT_QUANTITY,0, defaultTriggerPrice(), defaultDisclosedQuantity(), AT_OPTION_TYPE, AT_STRIKE_PRICE, AT_EXPIRY, defaultClientId(), defaultValidity(), defaultTraderType(), defaultMarketProtectionPct(), defaultStrategyId(), defaultComments(),
"regular", 0, 0, 0);
}
//PlotShapes(IIf(sellcond1,shapeSmallDownTriangle,shapeNone),colorOrange,0,H,-25);
PlotShapes(IIf(sellcond3,shapeHollowDownArrow,shapeNone),colorOrange,0,H,-15);
PlotShapes(IIf(sellcond2,shapeStar,shapeNone),colorOrange,0,H,-15);
//PlotShapes(IIf(exit,shapeStar,shapeNone),colorOrange,0,H,-15);
///PlotShapes(IIf(covercond1,shapeSmallUpTriangle,shapeNone),colorLime,0,L,-25);
PlotShapes(IIf(covercond3,shapeHollowUpArrow,shapeNone),colorAqua,0,L,-25);
PlotShapes(IIf(covercond2,shapeStar,shapeNone),colorAqua,0,L,-25);
//PlotShapes(IIf(exit,shapeStar,shapeNone),colorAqua,0,L,-25);
WriteIf( Sell == 1, "EOD exit",WriteIf( Sell == 3, "Profit Tgt",WriteIf( Sell == 2, "Max stop", "" ) ));
WriteIf( Cover == 1, "EOD exit",WriteIf( Cover == 3, "Profit Tgt",WriteIf( Cover == 2, "Max stop", "" ) ));
Getting false exit orders. Please have a look on screen shot.
Attachments
-
85.8 KB Views: 108