Hi guys,
I need some help on the Intraday (1-minute timeframe) code below.
my rules:
buy/short at 9:35 every morning
sell/cover
-
when getting 50% profit(i used applystop)
-
sell at 3:55(force close).
However, my below code always had problem:
1.buy/sell/short/cover prices always are daily close price.
- applystop never works. it always sell at 16:00
i'm very confused that this is a Intraday strategy and my data are 1 minutes from iqfeed.
Thanks!
// starting equity
SetOption("InitialEquity", 10000 );
// commission setting
SetOption( "CommissionMode", 3 ); /* set commissions AND costs as $ per trade*/
SetOption( "CommissionAmount", 0.0035 ); /* commissions AND cost */
//SetOption("AllowSameBarExit",true);
// setting both position size and maximum number of open positions so equity is spread equally among trades:
PosQTY = 5; // You can define here how many open positions you want
SetOption("MaxOpenPositions", PosQTY );
PositionSize = -100/PosQTY; // invest 100% of portfolio equity divided by max. position count
// trading price setting
BuyPrice=C;//(O+C+H+L)/4;
SellPrice=C;//(O+C+H+L)/4;
ShortPrice=O;//(O+C+H+L)/4;
CoverPrice=C;//(O+C+H+L)/4;
SetTradeDelays(0,0,0,0);
Buy = mycondition1;
Sell = TimeNum() > 155000;
Short =mycondition2;
Cover= TimeNum() > 155000;
//ApplyStop( stopTypeNBar, stopModeBars, 380 );
ApplyStop(stopTypeProfit, stopModePercent, 0.5);
PlotShapes(IIf(Buy,shapeDigit1, Null),colorGreen);
PlotShapes(IIf(Sell,shapeDigit2, Null),colorAqua);
PlotShapes(IIf(Short,shapeDigit3, Null),colorPink);
PlotShapes(IIf(Cover,shapeDigit4, Null),colorAqua);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
Short = ExRem(Short, Cover);
Cover = ExRem(Cover, Short);
Filter = Buy OR Sell OR Short OR Cover;
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( Short, "Short", 1 );
AddColumn( Cover, "Cover" ,1);
AddColumn(C,"Close");
AddColumn(O,"Open");
AddColumn(SD,"SD");