Protervus

HOW-TO: Build your strategy with Protervus Trading Toolkit

教育
FTX:BTCUSD   ビットコイン/米ドル
Hi Traders! This tutorial will show you how to build your own strategy and link it to Protervus Trading Toolking (PTT).

First of all, let me remind everyone that this content should be considered educational material, and backtesting results are not a guarantee. My goal is not to provide ready-made strategies, signals, or infallible methods, but rather indicators and tools to help you focus on your own research and build a reliable trading plan based on discipline.

So, without further ado let's start building our first strategy!
For this tutorial we'll build a simple EMA Cross strategy and add the Chaining Snippet to link it to PTT.

The first step is to create a new indicator in Pine Editor and add the initial requirements:

//@version=5
indicator("EMA Cross (data chaining)", overlay = true)


Let's now create the inputs where we will be editing EMAs' length:
FastEmaLen = input.int(50, title = "Fast EMA Length")
SlowEmaLen = input.int(200, title = "Fast EMA Length")


At this point we can proceed by calculating the two EMAs:
FastEma = ta.ema(close, FastEmaLen)
SlowEma = ta.ema(close, SlowEmaLen)


We are now ready to script our Entry conditions:
BullishCross = ta.crossover(FastEma, SlowEma)
BearishCross = ta.crossunder(FastEma, SlowEma)


We also wish to see the two EMAs plotted on the chart, so we will add the following code:
plot(FastEma, color = color.new(color.green, 0))
plot(SlowEma, color = color.new(color.red, 0))


At this point, our code should look like this:

Great, we are now ready to add PTT Snippet by pasting all the code at the end of the one we just wrote.
Let's head to the CONDITIONS INPUTS section and replace the placeholder text for EntryCondition_1, giving it a proper name:
EntryCondition_1 = input.bool(true, 'Ema Cross', group = 'Entry Conditions')
We can also add null to the unused inputs to clear the settings panel:

ADDING ENTRY CONDITIONS
We'll now be adding our Long and Short Entry conditions in the ENTRY \ FILTER CONDITIONS section.
In LongEntryCondition_1 we should replace null with BullishCross:
LongEntryCondition_1 = BullishCross

Same for ShortEntryCondition_1 down below:
ShortEntryCondition_1 = BearishCross

Guess what? We're done! We just added our Entry conditions:

We can now compile the script and add our indicator to the chart, along with PTT.
Let's open PTT and select "EMA Cross (data chaining): Chained Data" in the Source Selection drop-down menu - the data will now be forwarded to PTT and we can start tweaking the settings to experiment with our new strategy:

ADDING EXIT CONDITIONS
Let's say we now also want to add an Exit condition for when the price goes above (or below) the fast EMA, signaling a trend reversal: we can do that in no time!
Go back at the top of the code, and right after our EMA calculations, add:
PriceAboveFastEma = ta.crossover(close, FastEma)
PriceBelowFastEma = ta.crossunder(close, FastEma)


Of course, we also need to add the newly created conditions in the snippet code. Let's find the section EXIT CONDITIONS and, just like our Entry conditions, we can replace the null placeholder with our actual conditions:
LongExitCondition_1 = PriceBelowFastEma
...
ShortExitCondition_1 = PriceAboveFastEma

If we also want to use these conditions as Stops, we can add them to the STOP CONDITIONS section:

Note: Exit Conditions will close the trade in profit, while Stop Conditions will close the trade in loss. Still, you should not worry about scripting it yourself: PTT will take care of analyzing the trade and separate Exits from Stops when the signal to close the position is received.


ADDING FILTER CONDITIONS
Besides using our indicator to open and close trades, we can also use it to filter the signal from another, chained indicator.
To keep this tutorial simple, let's use the same EMA Cross script, so we can add it again to the chart and use the first one as Signal, and the second as Filter.

Let's add our Filter conditions in the script:
FastAboveSlow = FastEma > SlowEma
SlowAboveFast = FastEma < SlowEma


Just like we did in the previous steps, we should now add the option in the settings panel and the Filter conditions in the snippet code:

CHAINING INDICATORS
We currently have one EMA Cross indicator working as Signal in the chain, linked to PTT on the chart:

Let's copy-and-paste the EMA Cross indicator (or add it again) to have two of them.
The first one on the chain will act as Filter, so in the settings let's give the two EMAs a longer length (e.g. 250 and 300) in order to verify the trend and discard signals received when it's not favorable. Remember to set output mode as Filter, and tick the Filter box.
The second one will be our Signal: we can choose the length of the two EMAs we will use as Entry \ Exit when a cross happens (e.g. 100 and 200), enabling our Entry and Exit conditions by ticking the boxes. This time, we will tick the "Receive Data" box, and select the Chained source of the Filter:
If before linking the Filter you already had the Signal linked to PTT, you will notice it automatically recalculates the data - and if our Filter works as intended, the improvements will be visible ;)

EXTRAS
If your indicator doesn't plot anything on the chart, we must enable a "Dummy Plot" in order to prevent issues, since we are sending chained data as an invisible plot and it cannot be the only plot in the code.
Just un-comment the line plot(close < 0 ? close : na, title='Dummy Plot') to avoid this problem:

ADDING SIGNALS MARKERS
PTT will show all labels and markers for trades, but if you wish to have them on the indicator or just to debug your signals, you can enable and customize the last lines in the snippet:

CHAINING SCHEMA
|-- Filters (optional, any number of filters - linked one to another)
|---- Signal (mandatory, only one indicator must be set to Signal - in case of multiple Filters, Signal must be linked to the last Filter in the chain)
|------ Protervus Trading Toolkit (linked to Signal)
|-------- PTT Plugins (Strategy Wrapper, Trade Progression, etc - linked to PTT)

NOTES
- When you chain an indicator, its source remains "locked" even if you un-tick the Receive Data box. If you wish to use that source on another indicator you should un-link it first (just select "Close" as source to free the indicator's chain output).
- If you remove indicators in the chain, all other indicators linked AFTER it will be deleted - to prevent this, you should un-link chained indicators before removing them.
- Pine Script is limited to one source input per indicator, so you cannot chain indicators that let you choose another source to calculate data: for example, if you have an RSI indicator with a source selection (input.source) you must remove that input and only use the one for chaining. You can read more on PineScript Reference page.

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。