Bearish day, TQQQ opened at $54.56 and closed at $53.55! Racked in $64 profit, please find below the trades for the day (only the last few are shown):
Traded TQQQ with 3 sec bars/candles applying MACD Histogram logic. There was a position with 88 stocks in TQQQ by end of the day. Hope this clears out before start of tomorrow’s trading session! Please find the source code of logic I have been using for buying selling:
[IntrabarOrderGeneration = false]
inputs:
BuySetProfitTargetTrue( 1 ) [DisplayName = "BuySetProfitTargetTrue", ToolTip =
"Enter SetPercentTrailing when buying setting."],
SetSetProfitTargetTrue( 1 ) [DisplayName = "SetSetProfitTargetTrue", ToolTip =
"Enter SetPercentTrailing for selling setting."],
AvgentrypriceTrue( 1 ) [DisplayName = "AvgentrypriceTrue", ToolTip =
"Enter Avgentryprice = 1 else Close."],
SharesToBuy( 1 ) [DisplayName = "SharesToBuy", ToolTip =
"Enter SharesToBuy for a single trade."],
ProfitPercent( 0.0003 ) [DisplayName = "ProfitPercent", ToolTip =
"Enter Profit Percent."],
BuyTimeCondition( Time > 0929 and Time <= 1549 ) [DisplayName = "BuyTimeCondition", ToolTip =
"Enter buying time condition if day trading."],
SellTimeCondition( Time > 0929 and Time <= 1600 ) [DisplayName = "SellTimeCondition", ToolTip =
"Enter selling time condition if day trading."],
FastLength( 12 ) [DisplayName = "FastLength", ToolTip =
"Enter number of bars to use in calculation of shorter length moving average."],
SlowLength( 26 ) [DisplayName = "SlowLength", ToolTip =
"Enter number of bars to use in calculation of longer length moving average."],
MACDLength( 9 ) [DisplayName = "MACDLength", ToolTip =
"Moving Average Convergence Divergence Length. Enter the number of bars to use in smoothing the MACD value."];
variables:
MyMACD( 0 ),
MACDAvg( 0 ),
MACDDiff( 0 );
MyMACD = MACD( Close, FastLength, SlowLength );
MACDAvg = XAverage( MyMACD, MACDLength );
MACDDiff = MyMACD - MACDAvg;
//RSIValue = RSI( Close, 14 );
{ CB > 2 check used to avoid spurious cross confirmation at CB = 2 (at CB = 1, MyMACD and MACDAvg will be the same) }
if CurrentBar > 2
and MACDDiff < 0 and MACDDiff[1] < MACDDiff and MACDDiff[1] < MACDDiff[2] then Begin
if Marketposition = 0 and BuyTimeCondition Then Begin
Buy ( !( "H" ) ) SharesToBuy shares next bar at Close Limit;
Print("BUY Symbol: ", Symbol, " Time: ", Time, " NetProfit: ", NetProfit, " GrossProfit: ", GrossProfit, " GrossLoss: ", GrossLoss, " OpenPositionProfit: ", OpenPositionProfit, " Avgentryprice: ", Avgentryprice, " Currentcontracts: ", Currentcontracts);
End
Else Begin
//NumPositions = GetNumPositions(GetAccountID);
//By using SellTimeCondition we are making sure that the sell gets triggered till EOD regular trading hours
//Buy only when Close is lower then last Entryprice
If SellTimeCondition {and Close < Entryprice} Then Begin
//For every 50 stocks increment the ratio of buying by 1 eg from 51 to 100 postiions buy 3 times
If Currentcontracts < 51 Then
Buy ( !( "Hn1" ) ) (SharesToBuy * 2) shares next bar at Close Limit;
If Currentcontracts > 50 and Currentcontracts < 101 Then
Buy ( !( "Hn2" ) ) (SharesToBuy * 3) shares next bar at Close Limit;
If Currentcontracts > 100 and Currentcontracts < 151 Then
Buy ( !( "Hn3" ) ) (SharesToBuy * 4) shares next bar at Close Limit;
If Currentcontracts > 150 and Currentcontracts < 201 Then
Buy ( !( "Hn4" ) ) (SharesToBuy * 5) shares next bar at Close Limit;
If Currentcontracts > 200 and Currentcontracts < 251 Then
Buy ( !( "Hn5" ) ) (SharesToBuy * 6) shares next bar at Close Limit;
If Currentcontracts > 250 and Currentcontracts < 301 Then
Buy ( !( "Hn6" ) ) (SharesToBuy * 7) shares next bar at Close Limit;
If Currentcontracts > 300 and Currentcontracts < 351 Then
Buy ( !( "Hn7" ) ) (SharesToBuy * 8) shares next bar at Close Limit;
If Currentcontracts > 350 and Currentcontracts < 401 Then
Buy ( !( "Hn8" ) ) (SharesToBuy * 9) shares next bar at Close Limit;
If Currentcontracts > 400 and Currentcontracts < 451 Then
Buy ( !( "Hn9" ) ) (SharesToBuy * 10) shares next bar at Close Limit;
If Currentcontracts > 450 and Currentcontracts < 501 Then
Buy ( !( "Hn10" ) ) (SharesToBuy * 11) shares next bar at Close Limit;
If Currentcontracts > 500 and Currentcontracts < 551 Then
Buy ( !( "Hn11" ) ) (SharesToBuy * 12) shares next bar at Close Limit;
End;
Print("BUY Symbol: ", Symbol, " Time: ", Time, " NetProfit: ", NetProfit, " GrossProfit: ", GrossProfit, " GrossLoss: ", GrossLoss, " OpenPositionProfit: ", OpenPositionProfit, " Avgentryprice: ", Avgentryprice, " Currentcontracts: ", Currentcontracts);
End;
if Marketposition > 0 and BuySetProfitTargetTrue = 1 {and Currentcontracts > 1} Then Begin
SetStopShare;
Setprofittarget(Avgentryprice * ProfitPercent);
End;
End;
if Marketposition > 0 and Avgentryprice < Close and SellTimeCondition {and Currentcontracts > 1} then Begin
Print("SELL Symbol: ", Symbol, " Time: ", Time, " NetProfit: ", NetProfit, " GrossProfit: ", GrossProfit, " GrossLoss: ", GrossLoss, " OpenPositionProfit: ", OpenPositionProfit, " Avgentryprice: ", Avgentryprice, " Currentcontracts: ", Currentcontracts);
if SetSetProfitTargetTrue = 1 Then Begin
SetStopShare;
Setprofittarget(Avgentryprice * ProfitPercent);
End;
if SetSetProfitTargetTrue <> 1 Then Begin
if AvgentrypriceTrue <> 1 Then
Sell all shares next bar at (Close + (Close * ProfitPercent)) Limit
Else
Sell all shares next bar at (Avgentryprice + (Avgentryprice * ProfitPercent)) Limit;
End;
End;