hello all, i ve done my entry logic fine but having problem with my exit logic (please see attached) , which is basically a trailing stop of x ticks away. i ve researched the forum already but i couldnt get it to work.. i think i need to do virtualisation too. if anyone could help that would be much appreciated.. kind regards
hasan unsal
Answer by russelltromans-1 · Nov 27, 2020 at 06:18 PM
Below is a stripped back example of creating a trailing stop that only includes the blocks relevant to explaining the logic. In the above example I use the Time & Sales block to feed my trailing stop calculation. As I do not wish to consider any data prior to receiving my first fill I have used a branch block to filter the data until I need to use it. The Branch Block references the Value Extractor labelled 'Active' (Formula: 'TRUE') which turns true after the buy order has achieved it's first fill. The Max and Min blocks are formatted to collect the trade data using a formula of '#tradePrice'.
When the first fill is achieved from the buy order a discrete message will be sent containing the fill information from the fills output. A value Injector is then used to inject the fill price into the Trade Price message field. We do this so that the value can be read by our Max and Min blocks down stream. The message then passes through the Max and Min blocks where they will extract your fill price as the trade price and use this as the basis of your trailing stop calculation. The discrete message then passes to the 'Active' Value Extractor which will output 'True'. The 'Active' Value Extractor will output a 'True' for the remainder of the algo, this is referenced by the branch block which will then allow all future trade data to pass through the Max and Min blocks.
I have used an IF THEN block to decide whether to use the Max or Min based on the trade direction. To achieve this I have formatted a Boolean block with a variable type of 'Order Side'. In this configuration the Boolean will output True for OTA algos initiated on the buy side or False for algos initiated on the sell side.Finally I have enable flip for sell on the subtract block to invert the sign should the trade be initiated on the sell side.
thank you so much russell much appreciated! took me a while to understand the logic but i do now, all thanks to you. kind regards, hasan
Ask questions and share ideas about the TT® and X_TRADER® platforms.
First time here? See our Getting Started Guide and FAQs.
© 2017 Trading Technologies International, Inc. All rights reserved.
Powered by AnswerHub