♥ 0 |
I’ve had some good luck poking around in here but am having trouble adapting my strategy code. Some background of a similar dummy strategy: Entry Conditions (if ANY of the following is valid): Daily 50SMA crossed above 200SMA OR Daily 50SMA > Daily 200MA. Exit Conditions (if ANY of the following is valid): Exit After 16 Daily Candles passed. Basically, I want to get long after the cross and pretty much stay long as long as the shorter MA > longer MA. Existing Script: input price = close; input length1 = 50; input length2 = 200; input averageType = AverageType.SIMPLE; def Avg50 = MovingAverage(averageType, price, length1); def Avg200 = MovingAverage(averageType, price, length2); def crossabove = Avg50 crosses above Avg200; def greaterthan = Avg50 is greater than Avg200; def LongEntry = crossabove or greaterthan; input barexit = 16; def LongExt= LongEntry from barexit bars ago; AddOrder(OrderType.BUY_TO_OPEN, LongEntry,close[0], tickcolor = GetColor(2), arrowcolor = GetColor(2), name = “ENTRY”); AddOrder(OrderType.SELL_TO_CLOSE, LongExt,close[0], tickcolor = GetColor(1), arrowcolor = GetColor(1), name = “EXIT”); When I take out the ‘greaterthan’ variable in the logical ‘OR’ argument where ‘LongEntry’ is defined, this strategy seems to paint entries/exits correctly on the chart. So what is happening to this script here when that gets introduced? I have more I want to add to this strategy (stop loss, take profit, etc.), but can’t seem to get the basic function of it working first.
Marked as spam
|
Please log in to post questions.