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
|