[authored originally by Vae Victus 2018.01.22]

Video Tutorial

This video covers a large portion of this written tutorial below. Please watch it in conjunction with reading this document for more of an understanding of how to manipulate ProfitTrailer's many variables to your advantage: Making the Bot Buy - The Big Knobs and Levers

Table of Contents

UNDERSTANDING THE BUY

There are several factors that determine when a bot buys or sells. These are all set in the 3 main configuration files that deal with your buying and selling strategies: Indicators.properties, Pairs.properties, and DCA.properties.

PAIRS BUYING

Pairs settings drive normal, non-DCA buying. These settings are used when the coin doesn’t enter DCA or you are not using DCA.

Possible Buy Log

First, let’s discuss buying. The Possible Buy Log (PBL) is your indicator that your buy strategy is picking up potential candidates to buy. The different settings in the 3 files mentioned above control how the bot evaluates candidates. When you understand how you can tweak those settings, you will understand how to make the bot perform with more profitable behavior. When the PBL has coin pairs listed in it, the bot has found candidates whose pricing, volume, spread, etc are close to your buy strategy settings (within a few % of the price required to buy).

ALL_buy_value

Before digging into the details of each setting, it is worth noting that the main way to get the bot to buy, especially during those early days when you just want to make sure it is working, is to manipulate the ALL_buy_value setting along with your buy_strategy.

For example, if you want a simple buy strategy that is easy to understand, you can use LOWBB. This strategy says “buy a coin when its price meets or is lower than the LOWBB value of the coin, adjust by the ALL_buy_value percentage.” The ALL_buy_value default is 0, meaning buy the coin when the LOWBB value and the price are the same, or the price is lower.

But let’s say the market is hot, and all the coins are seeing strong gains. The price of a coin may rarely reach the LOWBB value, so you will want to increase the ALL_buy_value to move the buy signal higher. You can do that by increasing the ALL_buy_value a few percent at a time until you see the bot starting to buy. If you move the value to 15, you are telling the bot to buy a coin when its price is 15% ABOVE the LOWBB value.

(Remember that an ALL_buy_value = 50 means the middle of the BB bands (50%), and 100 means you would be at the HIGHBB band. So, a typical max that you would use in ALL_buy_value would be 45%. This would be a very aggressive setting and should result in the bot buying many pairs. This is, however, not necessarily a good thing, but it gives you an example to work with. )

Alternatively, if the market is down, and the coins have negative 24 hour averages, you would want to set your ALL_buy_value to a number that is low, even below zero, like -5, -10, -15, -20. This says “do not buy until the price of the coin is 5% (10%, etc) BELOW the LOWBB value.

ALL_trailing_buy

Another important setting is the ALL_trailing_buy setting. This setting allows the bot to “trail” a price downward if it is not yet done dropping, to try and buy the coin at the lowest possible price it can. This action is why you sometimes don’t see the bot buy immediately when a price is below the LOWBB setting by your ALL_buy_value percentage. Sometimes, it buys at a really low price for you, yaaa! But sometimes, if the price turns back up, it might not buy at all if the price jumps above the ALL_buy_value setting. It can be confusing, but it is working in your favor.

(Important note: There are several other settings detailed in the sections below that will cause the bot to filter out certain purchases that might meet the price triggers. These include: having enough volume, having a small enough spread, having too many pairs already bought but not sold beyond your max pairs setting, etc. Be sure to read and understand how these settings affect the buying below)

Understanding this basic concept of how the buy strategy and ALL_buy_value work together, will help you conquer the crypto markets!

DCA BUYING

But wait, there is more! PT has a buying strategy that helps you if your coin purchase begins to drop in value. It is called Dollar Cost Averaging or DCA for short, and will buy more coins for you as the price drops in order to lower the average price that you must meet in order to sell for a profit, or to prevent a loss.

DCA is detailed in the DCA.properties section, but there are a couple of basic concepts to understand here.

ALL_DCA_enabled

The first thing to understand is that you can turn DCA on in the Pairs file with the ALL_DCA_enabled = true setting, or turn it off with “false”. It is probably best to turn it off at first.

When you turn it on, you need to understand that DCA can eat up a lot of your balance in a hurry if you have bought coins at too high a price and they begin to drop in value.

DCA purchases the same amount of coins you have every time it executes, so it literally DOUBLES the amount each time. This can get expensive really quickly, so you need to know how to control it.

Example. If you have bought 0.002 BTC worth of ETH, and you let it DCA, the bot will purchase the following amounts:

Initial Balance is 0.002,
1st DCA = 0.002, Total = 0.004 BTC
2nd DCA = 0.004, Total = 0.008 BTC
3rd DCA = 0.008, Total = 0.016 BTC
4th DCA = 0.016, Total = 0.032 BTC
5th DCA = 0.032, Total = 0.064 BTC
6TH DCA = 0.064, Total = 0.128 BTC

As you can see, within 6 purchases you went from a 0.002 initial buy to a 0.128 holding in a coin that is clearly still down below your purchase price. Be sure to read the DCA.properties wiki entry and use the settings that are there to limit how much DCA can use of your balance (max_cost, max_buy_times).

That said, it is a very effective tool to help you clear out your bags if you set it up properly, so don't be afraid of it, but be very wary!


UNDERSTANDING THE SELL

The sell is more straightforward than the buy, and like the buy, can happen in two places: the Pairs settings, and in the DCA settings. The sell is driven normally by a simple GAIN strategy (though others are available, like HIGHBB).

PAIRS SELLING

ALL_sell_value

Getting the bot to sell is nothing more than the bot seeing the price of a coin exceed the percentage profit from the average bought price if you are using GAIN. The actual setting is the ALL_sell_value in the Pairs.properties file.

ALL_min_profit

If you are not using GAIN but HIGHBB as the sell strategy, the ALL_min_profit value is also utilized, and must be set accordingly to get the bot to sell at the desired profit level. It won’t sell unless the profit is higher than the minimum percentage that you set, even if the price is within the ALL_sell_value above or below the HIGHBB.

ALL_trailing_profit

But, there is a twist! Before executing the sell, the ALL_trailing_profit setting will attempt to allow the bot to work the price upward if it is still going up before it sells. Like the ALL_trailing_buy setting above, the profit setting tries to maximize your gains. You can read a Trailing scenario here in A Trailing Story.

DCA SELLING

Selling in DCA is similar to selling in Pairs. It uses a GAIN or a HIGHBB setting, and has the normal sell parameters already discussed in Pairs, but, remember, they can be set differently than what you have in Pairs, and probably should be different.

Example - when you have a coin that has gone down in value, it is often wise to set the sell_value and/or sell_trigger to a lower value than for a coin that you bought and never went down in price and thus never entered DCA. A coin that has been held at a loss is tying up your balance, and is not making you money. You need to get out of it quickly and at a lower profit margin than a purchase that is skyrocketing.

Remember: Your goal is NOT to make the highest profit on each trade. On the contrary, your goal is to NOT lose money in trading. If you can do that, then you win the game.


TOP

Why is my bot not buying? Why won't it sell? Why are there things in my Possible Buy Log (PBL), but it's not buying? Why is my PBL empty?

The PBL is populated based on several settings in your Pairs.configuration and Indicators.configuration files. One of the main factors in buying is:

Your Balance or your TCV (Total Current Value)

A zero or too low of a balance in your exchange and/or a TCV of zero will keep the bot from adding any coin pairs to your PBL. Additionally, if your balance is lower than your ALL_max_cost setting for the Pairs.properties file, or the max_cost setting in your DCA.properties file, then the bot won't be able to buy.

Other factors that affect the buying activity are broken down by file:


Pairs.configuration file:

Settings in this file that affect buying:

ALL_trading_enabled = true

If this is “false” the bot will not populate the PBL


ALL_sell_only_mode = false

If this is “true” the bot will not populate the PBL


all_max_trading_pairs

If the coin pairs in the Pairs log + the DCA log = ALL_max_trading_pairs, then the PBL will not be populated. If you want more in the PBL, increase this number.


ALL_buy_available_volume_trigger = 150

If there is not enough trading volume in the current order books, it will not be considered in the PBL. This setting is measured in percentage, and says “If the volume available in the order book is above 150% of my desired trade amount, then execute the trade, otherwise, do not.” 


ALL_min_buy_volume = 500

If the volume in the base currency that you are using to trade (e.g. BTC, or USDT) is below the amount you set, the pair will not be included in the PBL. This keeps you from buying coins that are hard to get rid of when the price is fluctuating wildly due to low trading volume. You can't sell a coin if there is no one on the other side to buy it at your desired price. Having very low volume makes that problem more severe. 


ALL_min_buy_price = 0.00000500

If the price of the pair is below this minimum price, the pair will not be included in the PBL.

TOP



How different BUY strategy settings affect the PBL

Buying with LOWBB

ALL_buy_strategy = LOWBB
ALL_buy_value = X

When using LOWBB, the main setting that affects the PBL is ``ALL_buy_value`` (which, remember, is a percentage). For a coin pair to be bought using LOWBB, the current price must be equal to or less than the value of the LOWBB band multiplied by (1 + ALL_buy_value expressed as a percentage). So, in other words,

negative buy_value
Buy Price = LOWBB - ((HIGHBB - LOWBB) * ABS(buy_value)/100)

positive buy value
Buy Price = LOWBB + ((HIGHBB - LOWBB) * ABS(buy_value)/100)

So, for the PT bot to even being to consider a coin pair to be put on the PBL, it needs to be close to the Buy Price. How close the current price needs to be is a closely guarded secret, but it must be reasonably close, say within 10%.

Thus, as an example, if you have no items in the PBL, and your ALL_buy_value is set to 0 (which would make the buy price be exactly the LOWBB value), and you look at your exchange and see that all the current coin pairs are up 10 or 20%, then your Buy Price calculation is not close enough current prices of all the coin pairs and the ALL_buy_value may need to be increased.

What are normal values for ALL_buy_value for LOWBB?
Values normally range between -20 for very, very conservative (things are going down in the market and you want to make sure you don’t buy unless the coin is 20% below its normal LOWBB line), to 0 for somewhat conservative, to 10-15% for somewhat aggressive, to 25-45% for very aggressive.


Buying with HIGHBB

HIGHBB is the opposite of LOWBB. It buys when the price of the coin is ALL_buy_value % above the HIGHBB line if the value is positive, and ALL_buy_value % below the line if the value is negative. See LOWBB above to understand how this works for populating the PBL.



Buying with SMA or EMA strategies (SMA/EMAGAIN, SMA/EMASPREAD, SMA/EMACROSS)

ALL_buy_strategy = SMAGAIN (or SMASPREAD, SMACROSS)
ALL_buy_value = X
ALL_buy_value_limit = Y

Note: SMA and EMA buy strategies are very similar. Simple Moving Average and Exponential Moving Average are calculated somewhat differently, but the strategies trade very similarly, so we will not duplicate the explanations here. Just replace EMA with SMA in your strategy if you wish.

Buying with SMAGAIN

When using SMAGAIN, the main setting that affects the PBL is ``ALL_buy_value`` (which, remember, is a percentage). For a coin pair to be bought using SMAGAIN, the current price must be equal to or less than the value of the lower SMA band multiplied by (1 + ALL_buy_value expressed as a percentage). So, in other words,

Buy Price < = Lower SMA value * (1 + ALL_buy_value/100)

So, for the PT bot to even being to consider a coin pair to be put on the PBL, it needs to be close to the Buy Price. How close the current price needs to be is a closely guarded secret, but it must be reasonably close, say within 10%.

Thus, as an example, if you have no items in the PBL, and your ALL_buy_value is set to 0 (which would make the buy price be exactly the low SMA value), and you look at your exchange and see that all the current coin pairs are up 10 or 20%, then your calculation of Buy Price is not close enough current prices of all the coin pairs and the ALL_buy_value may need to be increased.

What are normal values for ALL_buy_value for SMAGAIN?
Values normally range between -2 for very, very conservative (things are going down in the market and you want to make sure you don’t buy unless the coin is 2% below the low SMA line), to 0 for somewhat conservative, to 1-1.5% for somewhat aggressive, to 2% for very aggressive.

ALL_buy_value_limit in SMAGAIN puts a lower limit on your ALL_buy_value setting so that you will not, for example, go below -X% of the low SMA line. See Buy & Sell Strategies for details on this setting, but it will affect PBL if your coin pair price is below that limit.


Buying with SMASPREAD

This is similar to SMAGAIN, but the ALL_buy_value is a percentage spread between the fast and slow SMA lines. If your coin pairs are not populating the PBL, consider the current spread of the SMA lines, and adjust your ALL_buy_value accordingly.


Buying with SMACROSS

Buying with SMACROSS is similar to SMAGAIN, but the two SMA lines must have crossed within the last SMA_cross_candles (set in Indicators.configuration) value, minus one candle (e.g. if SMA_cross_candles is 5, then the cross must have occurred within the last 4 candles). In addition, the current value of the coin must be below the lower SMA line by ALL_buy_value % (again, similar to SMAGAIN explained above and in Buy & Sell Strategies.

Thus if your PBL is not being populated, adjust both your SMA_cross_candles value (in Indicators.configuration file) and your ALL_buy_value in Pairs.configuration.



Buying with LOSS strategy

Buying with LOSS says that to buy, the current coin pair price must be equal to or below ALL_buy_value loss % of the coin pair within the last 24 hours. Thus, the buy price is calculated:

Buy Price < = Current Coin Price * (1 - ABS[ALL_buy_value/100])

The PBL will not be populated with possibly buys if they are not near the Buy Price calculated above. If you are not getting PBL listings, try adjusting the ALL_buy_value closer to 0, to allow for a smaller loss.

Common Values for ALL_buy_value with LOSS
0 is the lowest possible value. Using 0 says that the coin should be purchased if the current value of the coin is equal to or less than the loss on that coin in the past 24 hours. If that coin is up in price in the past 24 hours, therefore, it will not be considered for the PBL unless that gain is close to zero. Any value greater than 0 is more conservative.

TOP



How INDICATORS.PROPERTIES affect the PBL

The following settings affect the PBL.

BB_period = 300
BB_sma = 20

The longer the BB_period setting, the smoother the BB lines will be. There will be fewer times that the coin pair current price will get near the lower or upper BB lines, and therefore fewer possible buys. However, this is not bad, as often times the longer settings avoid pump and dump volatility.

To populate the PBL, you need to pay attention to the length of your candles. 5 and 15 minute candles are common in bot trading, although longer candle lengths of 30 minutes, 1 hour and 4 hours are not out of the question if you want more conservative trends.

The period length determines the candle size on your chart. 300 (seconds) is 5 minutes. 900 is 15 minutes, 1800 is 30 minutes, etc.

BB_sma is the number of periods to use in calculating the SMA average. The more periods, the smoother the line, and the less reactive the BB lines are to price swings. This may affect the PBL.


SMA_period = 300
SMA_1 = 24
SMA_2 = 12
SMA_cross_candles = 5

The SMA_period, SMA_1, SMA_2 are similar to the BB_period and BB_sma above. The SMA_cross_candles was discussed in the Buying with SMACROSS section above.


EMA_period = 300
EMA_1 = 24
EMA_2 = 12
EMA_cross_candles = 2

The EMA_period, EMA_1, EMA_2 and EMA_cross_candles are similar to their SMA counterparts above.

TOP

  • basic_buy_and_sell_logic1.txt
  • Last modified: 5 months ago
  • by solanthus