Login Page - Create Account

Support Board


Date/Time: Fri, 03 May 2024 16:39:36 +0000



[User Discussion] - Stop trading after a lost

View Count: 1397

[2017-10-19 12:37:14]
User29926 - Posts: 92
I remember seeing a post some time ago with code to stop trading after a lost.
Then start trading after a number of bars had passed.

But I cant find it anymore thru the search feature.

I wanted to try and convert that code to stop trading until a indicator value changes, then allow trading again.

Does anyone have any sample code they could supply or just point me to the post regarding how to stop trading after a lost and I will attempt to modify that to what I need.

This is my current code attempt at stopping trading until an indicator value changes.
It stops trading with a "1", but I cant figure out how to get it to switch back and stay at "0" to allow trading again.

=IF( AND( $H$90 =0,$J$44 <0, $H$56 = ID17.SG8@8) ,1,IF( OR( $H$90= 1,$H$56 <> ID17.SG8@8), 0 , IF(ISBLANK($H$98),0 ,$H$98) ))

Thanks
Date Time Of Last Edit: 2017-10-19 13:12:56
[2017-10-21 00:49:07]
User29926 - Posts: 92
I guess no one has ever wanted to stop trading after a lost and start back after a condition is met.

Interesting.
Date Time Of Last Edit: 2017-10-21 00:49:30
[2017-10-21 01:19:15]
Sawtooth - Posts: 3992
You could use this example as a starting point:
http://www.sawtoothtrade.com/example-1.html

Edit the last part of the cell P3 example formula with your resetting condition.
[2017-10-21 22:50:43]
User29926 - Posts: 92
Thanks tomgilb for the code block.

I`m still trying to get it modified correctly to work..

O cell code:
=IF(QO3>QO4,TRUE,IF(OR(QQ3>QQ4,INT(A3)>INT(A4)),FALSE,O4))

P cell code:
=IF(AND(O3,O4=FALSE),1,IF(AND(QO3,QO3>QO4),P4+1,IF($H$90= 1,0,P4)))

$H$90= 1 is the switch that should set it zero

Currently the P cell is stuck on True even while the O cell is still False

$J$28 cell code:
=IF($J35=0, 0 ,IF ($P$3 = 1, 1,0) )
Date Time Of Last Edit: 2017-10-21 23:02:06
[2017-10-24 02:17:52]
User29926 - Posts: 92
Update:
I thought I had it working correctly, but started having issues with it flipping back to True thus turning off the trading even after the indicator value reset it.

Current O3 cell code:
=IF(OY3>OY4,TRUE,IF(OR(PA3>PA4,$H$90= 1),FALSE,O4))

Current P3 Cell code:
=IF(AND(O3,O4=FALSE),1,IF(AND(O3,OY3>OY4),P4+1,IF(AND(O3,O4),P4,0)))

Current J28 code:
=$P$3

tomgilb any idea why the $P$3 keeps going back to True after the indicator value resets it?

Causing no more trading after the 1 lost is posted?
$H$90 is normally False, until multiple indicators value sets it to True.

When that happens I need P3 to reset to false "0" and allow trading again.
$H$90 will go back to False "0" when the multiple indicators values are back in alignment again.
But I need the P3 to stay False when $H$90 goes back to False, so trading can continue until another lost happens.
Date Time Of Last Edit: 2017-10-24 04:30:49
[2017-10-26 00:57:34]
User29926 - Posts: 92
This must be a hard formula to get working correctly.
Over a 114 views, but no one has been capable of solving it yet.
Date Time Of Last Edit: 2017-10-26 00:59:31
[2017-10-26 01:49:15]
Sawtooth - Posts: 3992
It's not that the formula would be difficult.
It's that it's not possible to discern from the info you've provided.
There could be no straight-forward answer; it looks to be more complex than can be quickly solved.

I would not use a lock TRUE in H90. Instead, I'd use a Formula Column to set a persistent TRUE with one set of conditions that would release with another set of conditions.
As I've said, using a lock TRUE is only needed in rare occasions, and is often tricky to configure.
Date Time Of Last Edit: 2017-10-26 05:45:31
[2017-10-26 02:59:17]
User29926 - Posts: 92
Ok, I will try to be more concise about what is needed and why I use a locking/persistant cell.

(1) When there is a losing trade, I need to disable auto trading J28 with a "1".
(2) When the $H$90 cell value changes from a "0" to a "1" , I need to re-enable auto trading J28 with a "0".
(3) When the $H$90 cell value switches back to a "0". I need the J28 to stay a "0" even tho there is still a losing trade on the board.

I wouldn't say the $H$90 cell is a locking cell, its more of a persistent value.
Since the locking cell ability only allows one parameter to unlock it.

I use the cell $H$90, to condense about 8 different chart indicators, cell values and various price conditions.
I reference the chart indicators directly ie: ID17.SG8@3, instead of a direct cell reference.
This way I can add or remove indicators without having to worry about cell changes.

When all the conditions are true the $H$90 cell is set to "0".
The $H$90 cell is reset by a change in anyone of the conditions that set it.

The $H$90 cell (Long trades)and another cell $H$91 (Short trades)controls 96% of the decisions to enter a trade or not.
By using the two cells, my K3 and M3 cell are very clean and only reference 3 other cells and has no long complicated formulas in it.
Date Time Of Last Edit: 2017-10-26 03:09:11
[2017-10-27 15:08:46]
User29926 - Posts: 92
Update:

I believe I have achieved what I was trying to accomplish.

So far the formula is holding up thru a 60 day replay test.

=IF(AND($J$44 < 0, ID22.SG1@3 > ID22.SG1@4),1, IF( $H$90 ,0 ,IF(ISBLANK($J$28),0 ,$J$28) ))

Thanks tomgilb for the link to the code on your website that informed me that there was a losing trades study in SC.

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

Login

Login Page - Create Account