# More Question (position based management, turns, and triggers)

**URL:** <https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194>\
**Category:** Seetu\
**Created:** [August 28, 2015, 9:04pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194 "2015-08-28T21:04:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![BigReturns](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bigreturns/32/1487_2.png) [@BigReturns](https://forums.collective2.com/u/BigReturns)\
**Post date:** [August 28, 2015, 9:04pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/1 "2015-08-28T21:04:40Z")

</div>

Couple more questions for a newbie to Seetu:

I couldn’t find functions/methods for this in the manual - if it exists, just point me to it.

- Position Based Management:

- How to sell a position after x bars, days, etc…

- How to sell a position after a profit is reached (% or $)

- How do I plot executed trades on the chart?

- Are there TurnUp/TurnDown functions? (maybe I thinking about this wrong - so let me know if this is the case)

- Do you have plans for triggers? This something really cool that I haven’t seen implemented with so I’ve made my crude version of it in wealth-lab. If you guys could implement this, it would leap-frog your platform by make complex logic very manageable. ( **_Let me know if your interested in knowing the details and how it works in other industries_** )

I’m excited for a hosted platform that can run unattended and without hand-holding like I currently have to do with wealth-lab.

---

<div class="post-metadata">

**Author:** ![BigReturns](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bigreturns/32/1487_2.png) [@BigReturns](https://forums.collective2.com/u/BigReturns)\
**Post date:** [August 31, 2015, 5:35pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/2 "2015-08-31T17:35:37Z")

</div>

After reviewing the forums, I found [stop loss example](https://forums.collective2.com/t/is-there-a-way-to-implement-a-stop-loss-via-code/8154) that could possible help with selling at a profit. But still, I would need to know entry price to do this right ???

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [August 31, 2015, 6:21pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/3 "2015-08-31T18:21:33Z")

</div>

Trading prices are in BuyPrice, SellPrice, ShortPrice and CoverPrice

You can find BUY signals entry prices this way:  
YourLongEntryPrice = ValueWhen(Buy,BuyPrice);

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [August 31, 2015, 6:30pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/4 "2015-08-31T18:30:10Z")

</div>

Sell after 5 bars:

Buy = Cross(CalcMACD(), CalcMACDSignal());

Sell = BarsSince(Buy) \>= 5;

Sell = trimExcess(Sell,Buy);

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [August 31, 2015, 6:33pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/5 "2015-08-31T18:33:48Z")

</div>

> [@BigReturns](#):
>
> How do I plot executed trades on the chart?

```
Buy = Cross(CalcMACD(), CalcMACDSignal());
Sell = BarsSince(Buy) >= 5;
Sell = trimExcess(Sell,Buy);

DoPlot(Buy,"Buy",colorGreen,style=styleHistogram);
DoPlot(Sell,"Sell",colorRed,style=styleHistogram);

```

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [August 31, 2015, 6:42pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/6 "2015-08-31T18:42:37Z")

</div>

> [@BigReturns](#):
>
> TurnUp/TurnDown

Can you be more specific? Averaging positions?

> [@BigReturns](#):
>
> Do you have plans for triggers?

Can you be more specific? What do you mean by “triggers”?

---

<div class="post-metadata">

**Author:** ![BigReturns](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bigreturns/32/1487_2.png) [@BigReturns](https://forums.collective2.com/u/BigReturns)\
**Post date:** [August 31, 2015, 9:19pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/7 "2015-08-31T21:19:51Z")

</div>

What I think I’m learning is that seetu is intended to operate at higher level that I’m used to. This is mental shift on my part so thanks for helping out!!

**TurnUp/Down** are when indicators changes change an opposing direction. For example, a moving average is moving down, then turns up, this would be the TurnUp().

```
Buy = TurnUp(CalcMA(Close, 50)); // Buy when the 50 bar moving average turns up

Buy = TurnDown(CalcMA(Close, 50)); // Sell when the 50 bar moving average turns down

```

Sometimes we would like to see momentum in the turn so implementing a hysteresis check would be great.

```
Buy = TurnUp(CalcMA(Close, 5), 3); // Buys when the 5 bar moving average turns up and stays up for 3 consecutive bars.

```

I’m guessing there is way to do this and again, I’m not thinking the “Seetu way” quite yet.

* * *

**Triggers** are a clean and declarative way to implement complex logic and also great for evaluation.

Let me come up with a good example for this. Can you email me at my registered email to discuss this further?

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [September 1, 2015, 3:24pm UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/8 "2015-09-01T15:24:25Z")

</div>

If I undestand well: TurnUp means for example a sequence of values 10 , 5 , 10  
(Values go down and up then.)

I developed this. Hopefully it is what you mean.

```
SetOption("Symbols","MSFT,FB");

maCurrent = CalcMA(Close, 30); // I need MA(30) for MSFT nad FB to generate signals.
maPrev = Ref(maCurrent,-1); // Turning point
maPrevPrev = Ref(maCurrent,-2);

// This the formula:
// Buy = maPrevPrev > maPrev and maPrev < maCurrent; 
// But it needs some cleaning. 
// MA differences can be too small. For example just 0.00001. So try 0.02 differences.

Buy = maPrevPrev - 0.02 > maPrev and maPrev < maCurrent - 0.02; 

Filter = Buy;
AppendColumn(maPrevPrev,"maPrevPrev");
AppendColumn(maPrev,"maPrev(Turn)");
AppendColumn(maCurrent,"maCurrent");

DoPlot(Close,"Close",colorBlack);
DoPlot(maCurrent,"MA",colorBlue);
DoPlot( maPrev * Ref(Buy,1), "Turn",colorRed,style=styleHistogram);
DoPlot(Buy*maCurrent,"Buy",colorGreen,style=styleHistogram);

```

![](https://yyz2.discourse-cdn.com/flex028/uploads/collective2/1558/aced6fb02e44a247.png)

Re: “stays up for 3 consecutive bars” - I am not sure yet.

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [September 4, 2015, 10:06am UTC](https://forums.collective2.com/t/more-question-position-based-management-turns-and-triggers/8194/9 "2015-09-04T10:06:45Z")

</div>

Hello!

> [@BigReturns](#):
>
> Buy = TurnUp(CalcMA(Close, 5), 3); // Buys when the 5 bar moving average turns up and stays up for 3 consecutive bars.

This is a possible solution:

```
SetOption("Symbols","MSFT,FB");

// Bars shifts from the current bar to the history
beforeTurningPoint = -6;
turningPoint = -5;
afterTurningPoint = -4;
afterTurning_day1 = -3;
afterTurning_day2 = -2;
afterTurning_day3 = -1;

// Prepare a moving average (30 bars for this example)
ma = CalcMA(Close, 30); 

// Valuesfor the formula:
maBT = Ref(ma,beforeTurningPoint); // before turning point
maT = Ref(ma,turningPoint); // turning point
maAT = Ref(ma,afterTurningPoint); // after turning point
maD1 = Ref(ma,afterTurning_day1); // day #1 after turn-up
maD2 = Ref(ma,afterTurning_day2); // day #2 after turn-up
maD3 = Ref(ma,afterTurning_day3); // day #3 after turn-up

// This is the formula:
 Buy = maBT > maT and maT < maAT // TurnUp
       and maD1 > maT 
       and maD2 > maT 
       and maD3 > maT;

// Check a data in Exploration
Filter = Buy;
AppendColumn(maBT,"Before TP");
AppendColumn(maT,"TP");
AppendColumn(maAT,"After TP");
AppendColumn(maD1,"Day1");
AppendColumn(maD2,"Day2");
AppendColumn(maD3,"Day3");

// Visualization
DoPlot(Close,"Close",colorBlack);
DoPlot(ma,"MA",colorBlue);
DoPlot(Buy*ma,"Buy",colorGreen,style=styleHistogram);

```

* * *
