NewTickEvent

NewTickEvent
public event Action<Trade> NewTickEvent;

The NewTickEvent event signals the receipt of another anonymized (non-attributable) trade, which is described in the program by the Trade class. The event handler should accept an instance of this class, and also should not have a return value.

The event is ideal for high-frequency trading algorithms, as it allows robots to process market changes in real time and make instant decisions.

Let's assemble a small high-frequency trading (HFT) style strategy. If the price continuously rises over 10 trades, we buy. We close as soon as the price starts to pull back. We ignore trades with the same price.

In the constructor, we subscribe to the event for receiving a new anonymized trade.

1. Create an int variable to store the count of trades that will be considered a signal to open a position.

2. Create a decimal variable to store the price of the last trade.

3. Create an int variable to store the current count of consecutive price movements without a pullback.

4. If the price of the current trade is higher than the previous one, increment the counter by one.

5. If it's lower, reset the counter.

6. If the counter reaches the signal value and there are no open positions, buy.

7. If there is an open position but the counter has been reset, indicating a signal to exit, close all positions at the market price.

8. Always save the price of the last trade.

If you have any difficulties or questions, please write to the support chat. Link