Pairs trading - futures io
futures io futures trading



Pairs trading


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one asieretxebe with 5 posts (1 thanks)
    2. looks_two SMCJB with 2 posts (1 thanks)
    3. looks_3 drm7 with 1 posts (1 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,335 views
    2. thumb_up 3 thanks given
    3. group 3 followers
    1. forum 7 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Pairs trading

(login for full post details)
  #1 (permalink)
Bilbao , Spain
 
 
Posts: 4 since Mar 2017
Thanks: 2 given, 1 received

Happy new year to all traders!
I´ve been trading for a while now but I´m quite new still to automated trading and even if I read a hundred posts and manuals I can´t find the solution. A bit of help would be very much appreciated.

Goal:
backtest an arbitrage strategy that trades 2 instruments at the exact same time

Strategy core : if %change tickerA +% change ticker B < -1 then buy. exit when >0

Issues:
-even if there are 2 data sources in a chart just data 1 is traded
-If I open 2 charts ( to combine the 2 performance reports manually afterwards) with tickerA as data 1 and tickerB as data2 in one of them, and tickerB as data 1 , tickerA as data2 in the other one , the resulting operations are different. ( if A +B = x; then B+A should be X as well, but it´s not)
-maybe tradestation does not plot prices if there are no trades, and there´s a false signal because ticker A does not have price and B does??(I have no clue)
I have tried using portfolio maestro with all possible combinations (using 2 separate strategies for each data, combining everything…) and same problem, entries and exits don´t match in booth instruments.


Possible solutions that I don´t know how to code:
-Strategy that enters / exits positions in ticker B just when the same happens in ticker A ( For live trading I can use macros , but I have no idea for normal backtest or portfolio maestro)
-Something that gets the exact time of positions in A and then replicates in B...

Code till now:

inputs: variable1 (100000) , variable2 (-1) , variable3 (0);

Value1 = ((open-CloseD(1))/CloseD(1)) ;
Value2 = ((open data2-(CloseD(1) data2))/CloseD(1) data2) ;
value3 = ((value1 +value2)*100);
value4 = (Round(((variable1)/closeD(1)),0));

Condition1 = marketposition = 0 and Value3<variable2 ;
Condition2 = MarketPosition = 1 and value3>variable3 or ( Time >2150);

If condition1 then buy (value4) shares next bar at market;
If condition2 then sell all shares next bar at market;

Sorry for the long post, and thank you so much in advance for any help or ideas!!!
[][]

Reply With Quote

Can you help answer these questions
from other members on futures io?
Automating strategies on multiple charts with same symbol
TradeStation
NT8 indicator to simulate a Funding Evaluation where to …
NinjaTrader
Reading A set of Trading Signals
EasyLanguage Programming
ZigZag with Depth and Backstep
EasyLanguage Programming
SimplerOptions
Trading Reviews and Vendors
 
 
(login for full post details)
  #3 (permalink)
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little GE, GC, SI & Bitcoin
 
Posts: 3,975 since Dec 2013
Thanks: 3,281 given, 7,793 received


Try using 2 workspaces each with 3 data sources.
First workspace your data sources are Ticker A, Ticker A (again) and Ticker B.
Second workspace your data sources are Ticker B, Ticker A and Ticker B (again).

Make all your calculations/decisions based upon data feeds 2 and 3, which are the same on both workspaces. So same code for both except when you buy on 1/A you sell on 2/B. This has worked for me in previously.

Reply With Quote
The following user says Thank You to SMCJB for this post:
 
(login for full post details)
  #4 (permalink)
Virginia
 
 
Posts: 42 since Oct 2010
Thanks: 164 given, 41 received

I am not familiar with the Tradestation platform, but can you create a synthetic security with the pair, then trade it using a mean-reverting technical indicator to make it more straightforward? (e.g. stochastics, RSI, bollinger bands, etc.)

Security A = Ticker1 - Ticker 2

Buy when RSI(14) of Security A = 25, sell @ 75

You would have to balance the dollar amounts of the securities according to their relative notional value and volatility as well.

Reply With Quote
The following user says Thank You to drm7 for this post:
 
(login for full post details)
  #5 (permalink)
Legendary Market Wizard
Houston, TX
 
Experience: Advanced
Platform: Trading Technologies
Broker: Primary Advantage Futures. Also ED&F and Tradestation
Trading: Primarily Energy but also a little GE, GC, SI & Bitcoin
 
Posts: 3,975 since Dec 2013
Thanks: 3,281 given, 7,793 received


drm7 View Post
I am not familiar with the Tradestation platform, but can you create a synthetic security

You can create an indicator that would display your synthetic security but can't trade it. In tradestation a workspace will only trade the instrument displayed in data1 and it has to be a single real security.

Reply With Quote
 
(login for full post details)
  #6 (permalink)
Bilbao , Spain
 
 
Posts: 4 since Mar 2017
Thanks: 2 given, 1 received


SMCJB View Post
Try using 2 workspaces each with 3 data sources.
First workspace your data sources are Ticker A, Ticker A (again) and Ticker B.
Second workspace your data sources are Ticker B, Ticker A and Ticker B (again).

Make all your calculations/decisions based upon data feeds 2 and 3, which are the same on both workspaces. So same code for both except when you buy on 1/A you sell on 2/B. This has worked for me in previously.

Good idea that could solve the problem. Thanks! I will test it on monday and update

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Bilbao , Spain
 
 
Posts: 4 since Mar 2017
Thanks: 2 given, 1 received


SMCJB View Post
Try using 2 workspaces each with 3 data sources.
First workspace your data sources are Ticker A, Ticker A (again) and Ticker B.
Second workspace your data sources are Ticker B, Ticker A and Ticker B (again).

Make all your calculations/decisions based upon data feeds 2 and 3, which are the same on both workspaces. So same code for both except when you buy on 1/A you sell on 2/B. This has worked for me in previously.


drm7 View Post
I am not familiar with the Tradestation platform, but can you create a synthetic security with the pair, then trade it using a mean-reverting technical indicator to make it more straightforward? (e.g. stochastics, RSI, bollinger bands, etc.)

Security A = Ticker1 - Ticker 2

Buy when RSI(14) of Security A = 25, sell @ 75

You would have to balance the dollar amounts of the securities according to their relative notional value and volatility as well.

Yes I could build sinthetic data but I keep having the same. Problem. When comparing ticker A to sinthetic data X and ticker B to sinthetic data X

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Bilbao , Spain
 
 
Posts: 4 since Mar 2017
Thanks: 2 given, 1 received


SMCJB View Post
Try using 2 workspaces each with 3 data sources.
First workspace your data sources are Ticker A, Ticker A (again) and Ticker B.
Second workspace your data sources are Ticker B, Ticker A and Ticker B (again).

Make all your calculations/decisions based upon data feeds 2 and 3, which are the same on both workspaces. So same code for both except when you buy on 1/A you sell on 2/B. This has worked for me in previously.

I tried adding the 3 datas and it works even for portfolio maestro. Thank you so much !!

Reply With Quote
The following user says Thank You to asieretxebe for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Pairs trading


Last Updated on January 7, 2019


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts