NexusFi: Find Your Edge


Home Menu

 





Rec usaged is not allowed in this context


Discussion in ThinkOrSwim

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




 
Search this Thread

Rec usaged is not allowed in this context

  #1 (permalink)
BombaFett
San Francisco, CA, USA
 
Posts: 2 since Jan 2017
Thanks Given: 0
Thanks Received: 0

Demigods,

I have the following code I use as a trailing stop loss:

 
Code
#ATR Stoploss
input Length = 20;
input ATRFactor = 3;
input AverageType = AverageType.WILDERS;

def HiLo = Min(high - low, 1.5 * Average(high - low, Length));
def HRef = if low <= High[1]
    then high - close[1]
    else (high - close[1]) - 0.5 * (low - high[1]);
def LRef = if high >= low[1]
    then close[1] - low
    else (close[1] - low) - 0.5 * (low[1] - high);

def TrueRange;
    TrueRange = Max(HiLo, Max(HRef, LRef));

def ATR = ATRFactor*MovingAverage(AverageType, TrueRange, Length);

def trail;
    if (close()[1] > trail[1]) {
    trail = Max(trail[1], close - ATR);
    } else {
    trail = Min(trail[1], close - ATR);
    }

plot TrailingStop = trail;
When I build a conditional sell order in the Study Order Condition screen, I set it up as the following:

 
Code
close crosses below ATRTrailingStop_UPTREND_v2()
My problem is, seemingly at random, I'll get an error message stating "rec usage is not allowed in this context". Twice now, I've built this study from scratch, testing to see if the order will pass with each change and it'll work, but then it seems as if it just decides it doesn't want to work anymore.

For example, I set the order up last night and it worked perfectly this morning. When I tied to setup my next order, I get the error message. What am I dong wrong? I'm stumped...HALP

Reply With Quote




Last Updated on January 18, 2017


© 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