NexusFi: Find Your Edge


Home Menu

 





How to know if I'm in a "Buy" at start of chart.


Discussion in ThinkOrSwim

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




 
Search this Thread

How to know if I'm in a "Buy" at start of chart.

  #1 (permalink)
jetsetting
Weston
 
Posts: 3 since Feb 2017
Thanks Given: 0
Thanks Received: 0

I'm setting up a script that buys when the heikin ashi candle is green if the previous is red. And then to sell at the first red candle.

However, at the beginning of let's say a 1 year daily chart that starts with a green candle, I will get a sell when it turns red, but I had no associated buy (because it would have triggered before the chart started). I'm doing some further counting and PL forecasts with the buy and sell.

I can't figure out how to set up a variable that says I'm in a Buy and I would use that on my sell statement as "AND inBuy" or "AND isLong"

Here are the two statements that initiate the buy and sell. I was trying to use switch and set the state as long but I cannot figure it out.

def buy = haOpen[0] < haClose[0] and haOpen[1] > haClose[1] ;

def sell = haOpen[0] > haClose[0] and haClose[1] >= haOpen[1];

Many thanks, Joe

Reply With Quote




Last Updated on October 1, 2018


© 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