NexusFi: Find Your Edge


Home Menu

 





Data2 for automated trading


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Orjan with 3 posts (0 thanks)
    2. looks_two dtrade88 with 2 posts (1 thanks)
    3. looks_3 RM99 with 2 posts (0 thanks)
    4. looks_4 EladLevi with 1 posts (0 thanks)
    1. trending_up 12,539 views
    2. thumb_up 3 thanks given
    3. group 6 followers
    1. forum 11 posts
    2. attach_file 0 attachments




 
Search this Thread

Data2 for automated trading

  #1 (permalink)
Orjan
Stockholm Sweden
 
Posts: 20 since Apr 2012
Thanks Given: 12
Thanks Received: 2

I the same Tradestation chart I have 1 minute (Data1) and 120 minute (Data2). I have put the strategy in Data1. One of my conditions is to buy when MACD of Data2 is below 0 and is rising. But when I test the strategy it neglects that condition (Condition1 in the code) and takes entries even when MACD is above 0. Greatful for input how to solve this. The strategy is verified.

My code:

Inputs: Price(Close of Data2),
Length1(12),
Length2(15);

Vars: ExpAv1(0),
ExpAv2(0),
MACD(0);

ExpAv1 = XAverage(Price, Length1) of Data2;
ExpAv2 = XAverage(Price, Length2) of Data2;

MACD = ExpAv1 - ExpAv2;

Condition1 = MACD < 0 AND MACD > MACD[1];
Condition2 = High of Data2 > High[1] of Data2;
Condition3 = High of Data1 > High[1] of Data1;

If Condition1 AND Condition2 AND Condition3 Then Buy This Bar;

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
What broker to use for trading palladium futures
Commodities
Better Renko Gaps
The Elite Circle
 
  #3 (permalink)
dtrade88
San Francisco, California
 
Posts: 28 since Mar 2010
Thanks Given: 1
Thanks Received: 11


Hi,

I recommend you do the following:

1. Add Condition1(0), Condition2(0), Condition3(0) to Variables
2. Modify the "Conditions" part as follows:

Condition1 =0;
Condition2 =0;
Condition3 =0;

If (MACD < 0 AND MACD > MACD[1]) then Condition1=1;
If (High of Data2 > High[1] of Data2) then Condition2=1;
If (High of Data1 > High[1] of Data1) then Condition3=1;

If (Condition1=1 AND Condition2=1 AND Condition3=1) Then Buy This Bar;

Reply With Quote
Thanked by:
  #4 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704

I don't think you can do this unless you insert a chart into another chart and the only way you can do that is if the charts are the same interval.

This is one of my chief complaints about TS's limitations for multi-time frame trading.

The current options are to use either Global Variables, Global Dictionary, or ADE.

I have a general sender/receiver for the global dictionary, but again, that has limitations as well, it won't backtest and depending on your applications, there are time stamp issues as TS only stamps data down to the 1 minute level.

If you want backtesting capability, then you'll have to go with ADE which makes the exercise beyond most moderate programming capabilities (you'd need a 3rd party code consultant).

If you can figure this out, I'd be very interested, but I've spoken with TS developers actually on the phone and they were supposed to be working on a temporary refinement of the GD sender and receiver to make it simpler to use.

I'm willing to bet that you're getting null values on your data2.

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
  #5 (permalink)
Orjan
Stockholm Sweden
 
Posts: 20 since Apr 2012
Thanks Given: 12
Thanks Received: 2

dtrade88,

Thanks, but it did not solve the problem.

Reply With Quote
  #6 (permalink)
Bimi
London
 
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58

use next bar instead of this bar


 
Code
buy next bar market;

Reply With Quote
  #7 (permalink)
 RM99 
Austin, TX
 
Experience: Advanced
Platform: TradeStation
Trading: Futures
Posts: 839 since Mar 2011
Thanks Given: 124
Thanks Received: 704

Disregard my post.....I was confusing time based charts with "advanced" charts. TS will not allow you to insert another chart for advanced types of different intervals.

For those of us who don't use time based charts, it's just another obstacle and limitation of range, renko, kase, kagi, tick charts, etc.

"A dumb man never learns. A smart man learns from his own failure and success. But a wise man learns from the failure and success of others."
Reply With Quote
  #8 (permalink)
dtrade88
San Francisco, California
 
Posts: 28 since Mar 2010
Thanks Given: 1
Thanks Received: 11

Given that your Data1 is 1min and your Data2 is 120min and you want TS to take into account BOTH, you probably need to setup a time condition that would perform Condition1, Condition2, Condition3 calculations only at pre-determined times when BOTH, Data1 and Data2, are available.

Reply With Quote
  #9 (permalink)
 
ValutaTrader's Avatar
 ValutaTrader 
Oslo,Norway
 
Experience: Intermediate
Platform: NinjaTrader
Trading: EUR/USD
Posts: 66 since Apr 2011
Thanks Given: 4
Thanks Received: 52


Orjan View Post
I

ExpAv1 = XAverage(Price, Length1) of Data2;
ExpAv2 = XAverage(Price, Length2) of Data2;

MACD = ExpAv1 - ExpAv2;

Ørjan,

Put the code above into a separate function MACD_calc and you may get a different result.
MACD=MACD_calc(Price, Length1, Length2) of Data2

Function
MACD_calc

input :
Price(numericseries),
Length1( numericsimple ),
Length1( numericsimple ) ;

variables: ExpAv1(0), ExpAv2(0);

ExpAv1 = XAverage(Price, Length1) ;;
ExpAv2 = XAverage(Price, Length2) ;

MACD_calc = ExpAv1 - ExpAv2;

Follow me on Twitter Reply With Quote
Thanked by:
  #10 (permalink)
Orjan
Stockholm Sweden
 
Posts: 20 since Apr 2012
Thanks Given: 12
Thanks Received: 2


Thank you ValutaTrader,

I have solved the problem.

Reply With Quote




Last Updated on January 7, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts