03282022 $54 Profit TradeStation Automated Trading

Bullish today, TQQQ opened at $56.92 closed at $59.52; SOXL opened at $41.20 closed at $42.71! Got out with $54 profit, please find below the trades for the day (only the last few are shown):

03282022 $54 Profit TradeStation Automated Trading

Traded TQQQ and SOXL with 3 sec bars/candles applying MACD Histogram logic. We had a previous position with 131 stocks in PNW from long before and it was closed in market hours, such a relief 🙂 TQQQ is using the same logic as before.

For SOXL there is a slight change on identifying the uptrend. We don’t try to close position until MACDDiff[1] < MACDDiff is one of the conditions. Please find the source code of sell logic:

[IntrabarOrderGeneration = true]

inputs:
	SellSetProfitTargetTrue( 0 ) [DisplayName = "SetSetProfitTargetTrue", ToolTip = 
	 "Enter SetPercentTrailing for selling setting."],
	AvgentrypriceTrue( 1 ) [DisplayName = "AvgentrypriceTrue", ToolTip = 
	 "Enter Avgentryprice = 1 else Close."],
	ProfitPercent( 0.002 ) [DisplayName = "ProfitPercent", ToolTip = 
	 "Enter Profit Percent."],
	ProfitCents ( 0 ) [DisplayName = "ProfitCents", ToolTip = 
	 "Enter Profit per share."],
	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 ),
	Dummy( 0 );

MyMACD = MACD( Close, FastLength, SlowLength );
MACDAvg = XAverage( MyMACD, MACDLength );
MACDDiff = MyMACD - MACDAvg;

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 SellSetProfitTargetTrue = 1 Then Begin
		if ProfitCents > 0 Then Begin
			SetStopShare;
			Setprofittarget(ProfitCents);
		end
		Else Begin
			SetStopShare;
			Setprofittarget(Avgentryprice * ProfitPercent);
		End;
	End
	Else Begin
		//If C >= O Then
		If MACDDiff[1] < MACDDiff Then
			Dummy = C
		Else Begin
			if AvgentrypriceTrue <> 1 Then
				//Sell all shares next bar at Close Limit
				Sell all shares next bar at (Close + (Close * ProfitPercent)) Limit
				//Sell all shares next bar at Market
			Else Begin
				if ProfitCents > 0 Then
					Sell all shares next bar at (Avgentryprice + ProfitCents) Limit
				Else
					Sell all shares next bar at (Avgentryprice + (Avgentryprice * ProfitPercent)) Limit;
			End;
		End;
	End;
End;

Leave a Comment