8
8
9
9
In Turtle system theory, a complete trading system must cover several aspects, i.e.:
10
10
- Markets - What to buy or sell
11
- - Position Sizing - How much to buy or sell
12
- - Entries - When to buy or sell
13
- - Stops - When to get out of a losing position
14
- - Exits - When to get out of a winning position
15
- - Tactics - How to buy or sell
11
+ - Position Sizing - How much to buy or sell
12
+ - Entries - When to buy or sell
13
+ - Stops - When to get out of a losing position
14
+ - Exits - When to get out of a winning position
15
+ - Tactics - How to buy or sell
16
16
17
17
This Python module attempts to implement the system on Jesse framework as described in the pdf by Curtis Faith & Perry J. Kaufman.
18
18
@@ -107,7 +107,7 @@ def go_long(self):
107
107
108
108
self .buy = qty , self .price
109
109
self .stop_loss = qty , sl
110
- # print (f"enter long {qty}")
110
+ # self.log (f"enter long {qty}")
111
111
self .current_pyramiding_levels += 1 # Track the pyramiding level
112
112
self .last_opened_price = self .price # Store this value to determine when to add next pyramiding
113
113
@@ -117,7 +117,7 @@ def go_short(self):
117
117
118
118
self .sell = qty , self .price
119
119
self .stop_loss = qty , sl
120
- # print (f"enter short {qty}")
120
+ # self.log (f"enter short {qty}")
121
121
self .current_pyramiding_levels += 1 # Track the pyramiding level
122
122
self .last_opened_price = self .price # Store this value to determine when to add next pyramiding
123
123
@@ -127,12 +127,12 @@ def update_position(self):
127
127
if self .is_long and self .price > self .last_opened_price + (self .vars ["pyramiding_threshold" ] * self .atr ):
128
128
qty = self .unit_qty (self .vars ["unit_risk_percent" ])
129
129
self .buy = qty , self .price
130
- # print (f"atr={self.atr}, last price={self.last_opened_price}, cur price={self.price}, action: increase long position {qty}")
130
+ # self.log (f"atr={self.atr}, last price={self.last_opened_price}, cur price={self.price}, action: increase long position {qty}")
131
131
132
132
if self .is_short and self .price < self .last_opened_price - (self .vars ["pyramiding_threshold" ] * self .atr ):
133
133
qty = self .unit_qty (self .vars ["unit_risk_percent" ])
134
134
self .sell = qty , self .price
135
- # print (f"atr={self.atr}, last price={self.last_opened_price}, cur price={self.price}, action: increase short position {qty}")
135
+ # self.log (f"atr={self.atr}, last price={self.last_opened_price}, cur price={self.price}, action: increase short position {qty}")
136
136
137
137
# "Trades are exited on the fi rst occurrence of
138
138
# a. The stop-loss
@@ -148,14 +148,14 @@ def on_increased_position(self, order):
148
148
# This generally meant that all the stops for the entire position would be placed at 2 N from the most recently added unit." (Faith, 2003)
149
149
if self .is_long :
150
150
self .stop_loss = abs (self .position .qty ), self .price - self .vars ["atr_multiplier" ] * self .atr
151
- # print (f"atr={self.atr}, current position sl: {self.average_stop_loss}")
151
+ # self.log (f"atr={self.atr}, current position sl: {self.average_stop_loss}")
152
152
if self .is_short :
153
153
self .stop_loss = abs (self .position .qty ), self .price + self .vars ["atr_multiplier" ] * self .atr
154
- # print (f"atr={self.atr}, current position sl: {self.average_stop_loss}")
154
+ # self.log (f"atr={self.atr}, current position sl: {self.average_stop_loss}")
155
155
156
156
self .current_pyramiding_levels += 1
157
157
self .last_opened_price = self .price
158
- # print (f"current pyramiding levels: {self.current_pyramiding_levels}")
158
+ # self.log (f"current pyramiding levels: {self.current_pyramiding_levels}")
159
159
160
160
def on_stop_loss (self , order ):
161
161
# Reset tracked pyramiding levels
@@ -174,7 +174,7 @@ def filters(self):
174
174
175
175
def S1_filter (self ):
176
176
if self .vars ["system_type" ] == "S1" and self .last_was_profitable :
177
- # print (f"prev was profitable, do not enter trade")
177
+ # self.log (f"prev was profitable, do not enter trade")
178
178
self .last_was_profitable = False
179
179
return False
180
180
return True
0 commit comments