Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 03:12:14 +0000



[Programming Help] - Long Entry and Short Exit | Short Entry and Long Exit

View Count: 359

[2024-06-29 08:33:04]
User471063 - Posts: 7
Hello SC Engineers,

Testing NQTV stocks with spreadsheet Trading system. Reversal:yes, Allow Opposite Entry: yes.

Is there any way dynamically trigger K to M and M to K ? if I isolated each entry into K, L, M, N then Reversal not working correctly.

Validating just Long Entry and Short Exit Signal I can find up arrow for Long and buy triggered correctly but no Arrow for short since it was triggered from Column K buying it again instead of exit.

Can you please guide me to accomplish or do you have any test formula that help my testing more efficiently and appreciate your help.

Example:

Column K: Long Entry and Short Exit Signal

=IF(AND(ID0.SG4@3 > ID0.SG1@3, ID0.SG5@3 > AVERAGE(ID0.SG5@4:ID0.SG5@23) * 1.5, ID4.SG1@3 > AVERAGE(ID4.SG1@4:ID4.SG1@23), ID5.SG1@3 > ID6.SG1@3, K@2 = 0, M@2 = 0), 1, IF(AND(M@2 = 1, ID0.SG4@3 <= ID0.SG1@3 * 0.94), 1, 0))

Column M: Short Entry and Long Exit Signal

=IF(AND(ID0.SG4@3 < ID0.SG1@3, ID0.SG5@3 > AVERAGE(ID0.SG5@4:ID0.SG5@23) * 1.5, ID4.SG1@3 > AVERAGE(ID4.SG1@4:ID4.SG1@23), ID5.SG1@3 < ID6.SG1@3, K@2 = 0, M@2 = 0), 1, IF(AND(K@2 = 1, ID0.SG4@3 >= ID0.SG1@3 * 1.05), 1, 0))

Ref:
ID0   //A DATE TIME
ID0.SG1 //B //OPEN
ID0.SG2 //C HIGH
ID0.SG3 //D LOW
ID0.SG4 // LAST
ID0.SG5 // VOLUME
ID0.SG6 // # OF TRADES

K // LONG ENTRY
M // SHORT ENTRY

STUDY ID:
ID1.SG1 // TRADING SYSTEM BUY ENTRY ARROW UP
ID1.SG3 // TRADING SYSTEM SELL ENTRY ARROW DOWN
ID2.SG1 // ROCP LAST 14
ID4.SG1 // ATR LAST 14
ID5.SG1 // EMA LAST 10
ID6.SG1 // EMA LAST 20


Thanks for help

Abdul
Private File
Attachment Deleted.
[2024-06-29 15:48:25]
Sawtooth - Posts: 4118
if I isolated each entry into K, L, M, N then Reversal not working correctly.
When using Reversals, columns K, M are the Entry and Exit signals.
When using Reversals, you are always in a position, whether long or short.
When using Reversals, columns L, N are not used unless the exit condition is not a reversal entry signal.

Validating just Long Entry and Short Exit Signal I can find up arrow for Long and buy triggered correctly but no Arrow for short since it was triggered from Column K buying it again instead of exit.
I don't understand this.
Is 'Signal Only On Bar Close (K, M) set to No?
Arrows only mark close of bar conditions, and columns K, M only show entry arrows.

What is in K2 and M2?
These are the subgraph name/label cells, and not intended for formulas, unless you want to create a dynamic name.
[2024-07-05 12:10:03]
User471063 - Posts: 7
Thanks for quick response,

don't understand this. Is 'Signal Only On Bar Close (K, M) set to No?

A. currently Signal Only On Bar Close set to No.


What is in K2 and M2? These are the subgraph name/label cells, and not intended for formulas, unless you want to create a dynamic name.

A. It was just placeholder for you to see K@2 my logic trying to trigger signal to M@3 =1.


Correct me if I'm wrong about the basic concept for NQTV stocks.

Example Spreadsheet trading:

1 when the lowest price returns True K = 1 open parent order.

1.1 Price moves above RSI 80 then starts to pull back, triggering Sell Entry (Take profit). M = 1

1.2 Since Sierra set auto Reversal Open Sell Entry automatically.

1.3 Sell entry reaches lowest price returns true and K =1 Triggers Buy Entry to Exit.

1.4 Stock price and Volume dried for the day No auto reversal until price and volume trend again.

1 full cycle trade completed successfully.

Currently, I'm on the latest version of the Sierra package. You can add how many IF, AND OR at the end K=1 means trigger buy entry. Above is my example. Since we already opened a position at the lowest price, then the price moved to overbought, my formula triggers M=1 but Ignores and Buy again at the overbought.

The Sell entry scan M column for the highest price to short sell, it's not going to get in >80 due to volatility or time delay. It will gets at >70, so the RSI moved 10 points. Then the price moved, and the whole trade became a loss.

If we allow K to trigger Sell Entry M = 1 and Sell Entry logic to trigger K =1 that might reduce the time delay.


Currently reversal happens automatically there are many situation we don't need reversal. Is there anyway add logic to check if whether we really need reversal? if logic reruns No no action needed until next Alert.

Thanks for amazing support

Abdul
[2024-07-05 17:26:57]
Sawtooth - Posts: 4118
Is there any way to add logic to check if whether we really need a reversal?
Maybe, if your signals were at bar close.

Columns K-N are the signal columns, and intended to only have a TRUE/1 in individual rows, where the condition is TRUE in that bar, not the entire column of TRUE/1.
Use other Formula Columns, or open cells, for intermediate calculations.

Intrabar signals (Signal Only On Bar Close set to No) are frequently problematic, especially when using Reversals.
IMO, the default settings for these should be Yes.

The reason intrabar signals are frequently problematic is because a spreadsheet study cannot capture/retain/make persistent an intrabar signal.
Additionally, no intrabar signals are marked, only signals that occurred at close of bar, so you cannot tell what happened inside that bar with historical arrows.

Also, best practice is to not use row 2 for anything other than the label.
Row 1 in Formula Columns is open; use it instead. All of column H is also open.
[2024-07-06 00:55:31]
User471063 - Posts: 7
Sorry,

A. currently Signal Only On Bar Close set to Yes. spreadsheet default was No.

Can you please help me basic proof of concept some working template below conditions if need to store data an additional sheet etc. I truly understand your limitations on handouts but educational purpose this will be an amazing starting with experts direction and We might reduce random support tickets.

Example Spreadsheet trading: K and M used.

1 when the lowest price returns True K = 1 open parent order.

1.1 Price moves above RSI 80 then starts to pull back, triggering Sell Entry (Take profit). M = 1

1.2 Since Sierra set auto Reversal Open Sell Entry automatically.

1.3 Sell entry reaches lowest price returns true and K =1 Triggers Buy Entry to Exit.

1.4 Stock price and Volume dried for the day No auto reversal until price and volume trend again.

1 full cycle trade completed successfully.


Is there any ways OCO attached profit taker and stop loss adjust price dynamically? that cold help some positive and profitable trades.

The reason I was using spreadsheet system so I can see back testing winning and loosing data that help me analyze specific trades . If I use Based on Alert condition trading I can see Trade activity, Messages, Alerts, trade service but not detail information like spreadsheet. Statistics Tab works if I trading with Brokers account but Sim1 not working either I missing any default settings?

Thanks for help

Abdul
[2024-07-06 04:35:39]
Sawtooth - Posts: 4118
I'll ask again: what formula is in K2 and M2?
And why don't use use K1 and M1 as I suggest?

You have not shared enough pertinent information for me to properly resolve this for you.

Also, you don't need to use the IF function unless you are returning a value:
This...:
=IF(AND(ID0.SG4@3 > ID0.SG1@3, ID0.SG5@3 > AVERAGE(ID0.SG5@4:ID0.SG5@23) * 1.5, ID4.SG1@3 > AVERAGE(ID4.SG1@4:ID4.SG1@23), ID5.SG1@3 > ID6.SG1@3, K@2 = 0, M@2 = 0), 1, IF(AND(M@2 = 1, ID0.SG4@3 <= ID0.SG1@3 * 0.94), 1, 0))
...can be written as:
=OR(AND(E3 > B3, F3 > AVERAGE(F4:F23) * 1.5, ID4.SG1@3 > AVERAGE(ID4.SG1@4:ID4.SG1@23), ID5.SG1@3 > ID6.SG1@3, K2 = 0, M2 = 0), AND(M2 = 1, E3 <= B3 * 0.94))

This...:
=IF(AND(ID0.SG4@3 < ID0.SG1@3, ID0.SG5@3 > AVERAGE(ID0.SG5@4:ID0.SG5@23) * 1.5, ID4.SG1@3 > AVERAGE(ID4.SG1@4:ID4.SG1@23), ID5.SG1@3 < ID6.SG1@3, K@2 = 0, M@2 = 0), 1, IF(AND(K@2 = 1, ID0.SG4@3 >= ID0.SG1@3 * 1.05), 1, 0))
...can be written as:
=OR(AND(E3 < B3, F3 > AVERAGE(F4:F23) * 1.5, ID4.SG1@3 > AVERAGE(ID4.SG1@4:ID4.SG1@23), ID5.SG1@3 < ID6.SG1@3, K2 = 0, M2 = 0), AND(K2 = 1, E3 >= B3 * 1.05))

Is there any ways OCO attached profit taker and stop loss adjust price dynamically?
You can use the Trade Management by Study study, referencing a Formula Column's subgraph that has a formula that returns a dynamic price.
Attached Orders: Study Controlled Targets and Stops
Date Time Of Last Edit: 2024-07-06 21:02:10
[2024-07-08 07:35:26]
User471063 - Posts: 7
I modified K1 and M1 i don't see any changes.

Test / debug each conditions below add to H and all of them working 1,0 correctly.

There are few adjustments for ATR average and Volume average I added study ATR 20 ID7.SG1@3, ID8.SG4@3 Relative volume to simplify our testcase.


H10 for buy H20 for Sell returns 1,0 is there any way mirror these values to K and M as actual trigger or just use K3 =IF(H10 =1,1,0) and M3 =IF(H10 =1,1,0)?


Answer to your previous question K1=0 and M1=0 to prevent immediate reversal.

Concept:
=OR(
AND(
E3 > B3, // Condition 1: Close price greater than open price
F3 > AVERAGE(F4:F23) * 1.5, // Condition 2: Volume greater than 1.5 times the average volume of previous 20 periods
ID4.SG1@3 > AVERAGE(ID4.SG1@4:ID4.SG1@23), // Condition 3: Average True Range (ATR) at the current point greater than the average ATR over previous 20 periods
ID5.SG1@3 > ID6.SG1@3, // Condition 4: Short-term EMA (Exponential Moving Average) greater than long-term EMA
K1 = 0, // Condition 5: Long entry signal (K) is 0 (indicating no active long entry)
M1 = 0 // Condition 6: Short entry signal (M) is 0 (indicating no active short entry)
),
AND(
M1 = 1, // Alternative Condition 1: Short entry signal (M) is 1 (indicating an active short entry)
E3 <= B3 * 0.94 // Alternative Condition 2: Close price less than or equal to 94% of the open price
)
)

Test: buy
=OR(
AND(
E3 > B3,
F3 > ID8.SG4@3 * 1.5,
ID4.SG1@3 > ID7.SG1@3,
ID5.SG1@3 > ID6.SG1@3,
K1 = 0,
M1 = 0
),
AND(
M1 = 1,
E3 <= B3 * 0.94
)
)

Sell

=OR(
AND(
E3 < B3, // Condition 1: Close price less than open price
F3 > AVERAGE(F4:F23) * 1.5, // Condition 2: Volume greater than 1.5 times the average volume of previous 20 periods
ID4.SG1@3 > AVERAGE(ID4.SG1@4:ID4.SG1@23), // Condition 3: Average True Range (ATR) at the current point greater than the average ATR over previous 20 periods
ID5.SG1@3 < ID6.SG1@3, // Condition 4: Short-term EMA (Exponential Moving Average) less than long-term EMA
K1 = 0, // Condition 5: Long entry signal (K) is 0 (indicating no active long entry)
M1 = 0 // Condition 6: Short entry signal (M) is 0 (indicating no active short entry)
),
AND(
K1 = 1, // Alternative Condition 1: Long entry signal (K) is 1 (indicating an active long entry)
E3 >= B3 * 1.05 // Alternative Condition 2: Close price greater than or equal to 105% of the open price
)
)


=OR(
AND(
E3 < B3,
F3 > ID8.SG4@3 * 1.5,
ID4.SG1@3 > ID7.SG1@3,
ID5.SG1@3 < ID6.SG1@3,
K1 = 0,
M1 = 0
),
AND(
K1 = 1,
E3 >= B3 * 1.05
)
)

is it possible create multiple studies in the H column either one study case will return signal for Buy or Sell it depending on the market conditions or do you want me to use separate sheet for switch cases?

Thanks

Abdul
[2024-07-08 14:34:05]
Sawtooth - Posts: 4118
Answer to your previous question K1=0 and M1=0 to prevent immediate reversal.
Are 1 or 0 entered manually?

is it possible create multiple studies in the H column either one study case will return signal for Buy or Sell it depending on the market conditions or do you want me to use separate sheet for switch cases?
Use the H column.
Each chart has its own sheet, and you cannot trade the same symbol on two charts. (your broker will assume you are trading from a single chart.)

is there any way mirror these values to K and M as actual trigger or just use K3 =IF(H10 =1,1,0) and M3 =IF(H10 =1,1,0)?
You don't need the IF function if you are only returning 1 or 0.
When referencing open cells in Formula Columns, they must be absolute references:
$H$10=1
$K$1=1
$M$1=1
Date Time Of Last Edit: 2024-07-09 12:52:16
[2024-07-09 08:05:54]
User471063 - Posts: 7
Isolated formulas into small sets in the H and mirror values to K and M working correctly.

Reversal:
Are 1 or 0 entered manually? No, I'm trying to delaying from the formula but it didn't work.

In concept set values in the formula like K1 = 0, M1 = 0 delaying to buy or sell signals until next true conditions, but I was wrong.Reversal working outside the formula correct?

Reversal settings:
Reversal:Yes. Allow Opposite Entry: yes, And Signal Only on Bar Close K and M: Yes, and Cancel all orders on reversal: yes

Back testing result:

Out of 100 trades 43 trades found auto reversing at worst places.

Example test case for NQTV stock. Stop loss was removed to analyze system and logic.

1 parent order: formula triggered correctly at lowest price Long entry at 4.50 RSI < 30.
1.1 Price reached to 7.50 RSI > 70 formula exits successfully.
---
2 Auto reversal was triggered to short entry price dropped 7.20 then price moved to 12.50
2.1 RSI still >70 so formula calculate avg and confirm to exit at 12.50 to take lose.
2.2 Auto reversal kicks again for Long entry at 12.50 (out of formulas control or formula signal was ignored)
2.3 Price dropping to 10.50 take lose
2.4 Auto reversal kicks again to buy entry but price dropping to 8.50 take a lose
2.5 reversal kicks again...

If we have some kind of control to prevent auto reversal or auto correction reversal based on the price volume could be very efficient.

Reality we could get in short entry at 12.40 and take profit at 8.50 and reduce numbers of trades as well.


Is there any settings we can set formula to confirm reversal ? or how to handle these type of situations. I've tried to add more study, add filters, limit profits, stop loss but this need to be done correctly. Do i missed anything?

Thanks for amazing support and help

Abdul

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account