NexusFi: Find Your Edge


Home Menu

 





Directional AutoTrading


Discussion in TradeStation

Updated
    1. trending_up 1,609 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
AhmedF
north bergen
 
Posts: 13 since Feb 2017
Thanks Given: 3
Thanks Received: 1

I am having issues with writing a code that allows me to trade direction bias. To elaborate i want data2(larger size bars) to dictate the direction while Data1 ( smaller size bar) to dictate entry and exit. I wrote the code and it complies when i run the signal it trades both ways.

variables:
indicator ( 0) ,

var0( 0 ),
var1( 0 ),


data2var1(0),
VVSUP(false), //trending up
VVSDN(false);// trending DN



var1 = SwingIndex ;
indicator = iff (var1 <0 ,1,-1);
indicator = iff (var1 >0 ,1,-1);


//data2var1 = SwingIndex ;
data2var1 = iff (SwingIndex <0 ,1,-1);
data2var1 = iff (SwingIndex >0 ,1,-1);


if data2var1 > 0
then begin
VVSUP = true;
VVSDN = false;
end;
if data2var1 < 0
then begin
VVSUP = false;
VVSDN = true;
end;

if VVSUP then begin
if indicator crosses over 0 then buy next bar at market;
if marketposition = 1 and Indicator crosses under 0 then sell next bar at market;
end;

if VVSDN then begin
if Indicator crosses under 0 then sellshort next bar at market;
if marketposition =-1 and Indicator crosses over 0 then buytocover next bar at market;
end;


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

AhmedF,

as far as I can tell you don't reference Data2 in your code. Depending on what exactly you need, I would suggest looking into how to tie variables and functions to a datastream. For accessing reserved word values on other datastreams, this link should get you going: https://www.multicharts.com/trading-software/index.php/Data

Regards,

ABCTG


Follow me on X Reply With Quote




Last Updated on November 1, 2017


© 2026 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 - Downloads - Top
no new posts