- ago
Can someone help me build out by own Custom Indicator?

Ready to pay for it
0
167
Solved
13 Answers

Reply

Bookmark

Sort
Cone7
- ago
#1
Just let us know what you've got in mind. If it's not too complex (FFTs or something like that), we can probably whip it up for you right here.
0
- ago
#2
You're willing to pay while on free trial? Appreciate your trust in our product.
0
- ago
#3
You can define a C# function (i.e. method) either as part of your MyStrategy class or in a class by itself (utility class?) within the MyStrategy namespace. And then call that function as if it were an indicator. I typically do that first to debug the prospective indicator code before making it a fully functional WL indicator.

The only disadvantage to the above approach is that it won't function with drag-and-drop as a fully functional WL indicator would. And it won't have the internal attributes (like plot color or companion bands) like a fully functional indicator would. But your embedded function will work like any other function returning a TimeSeries when you inherit from TimeSeriesBase.

If you're totally new to C#, I can understand your reluctance to defining an indicator. I struggled initially too. But start by defining your algorithm as a function that returns a TimeSeries. That works much like other oops languages (C++, Java, etc). And that step isn't too hard. And you do not need to use Visual Studio to do that.
0
- ago
#4
@Cone - I am looking to Buy when VWAP cross over MVWAP, and looking to sell when MWAP cross below VWAP

avlen = input(50)
mvwap = ema(vwap,avlen)

---------------------------------------------------

@Eugend Yes I am looking forward to subscribe to your App/Service as soon as possible, but I am looking for an indication of how much support I can expect
0
Cone7
- ago
#5
Why do you feel the need for this to be a custom indicator? I ask, because in a C# strategy, this is just one line of code -
CODE:
IndicatorBase _ema = new EMA(new VWAP(bars),50);

Maybe so that you can use it directly in block strategies?
0
- ago
#6
More so with Blocks strategies, MVWAP can be simply modeled using the SmoothInd from TransformerIndicators group. Take VWAP as the indicator and choose EMA as the smoother. No need to code. Voila.

I renamed the topic title to reflect the gist (as always), also not seeing the immediate need in a custom indicator.
1
Best Answer
- ago
#7
Right. One doesn't need a custom indicator for this trading strategy. One can just use the existing VWAP and EMA indicators instead.

By the way, the VWAP indicator is not working on WL8 Build 12. Someone may want to look at that. The VWAP indicator will not work on Daily bars. It requires intraday bars to work instead. The code below has been fixed.

In the solution below, I substituted the SMA for the VWAP (which isn't working at the moment). My point with the solution below is that this isn't that difficult. So if you're not a programmer at all, I would seek out a local "partner" that is a programmer and is willing to help with that part of it. That would be the most fun approach. And your programmer should have experience with either C#, C++, or Java since these languages are somewhat similar. If he has experience with Visual Studio, that's even better (but not required). I didn't use Visual Studio on the solution below.

I would have your programmer take sample strategies--which already work--and modify them under your direction. That would get him going the fastest. He can learn the particulars of C# over time. Happy computing.

CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; namespace WealthScript2 { public class VwapDivergence : UserStrategyBase {       public VwapDivergence()       {          AddParameter("EMA period", ParameterType.Int32, 50, 10, 100, 5);       }       //create indicators and other objects here, this is executed prior to the main trading loop       public override void Initialize(BarHistory bars)       {          int emaPeriod = Parameters[0].AsInt;          vwap = new VWAP(bars); // for Daily bars, substitute: new SMA(bars.Close, emaPeriod);          mvwap = new EMA(vwap, emaPeriod);          PlotIndicator(vwap,WLColor.Olive);          PlotIndicator(mvwap,WLColor.Crimson);       }       //execute the strategy rules here, this is executed once for each bar in the backtest history       public override void Execute(BarHistory bars, int idx)       {          if (HasOpenPosition(bars, PositionType.Long))          {             //code your sell conditions here             if (vwap.CrossesUnder(mvwap, idx)) //was: (mvwap.CrossesUnder(vwap, idx))                PlaceTrade(bars, TransactionType.Sell, OrderType.Market, 0.0, "VWAP sell");          }          else          {             //code your buy conditions here             if (vwap.CrossesOver(mvwap, idx))                PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0.0, "VWAP buy");          }       }       //declare private variables below       IndicatorBase vwap,mvwap; } }
0
- ago
#8
Did you try to see if it is working on Intraday Charts?

It will not work on Daily Charts

Please let us know
0
Cone7
- ago
#9
vwap is an intraday indicator only, so sure it works on intraday charts.
0
- ago
#10
Here it is on a 5 minute chart. You can use the built-in AlphaVantage provider to get some (limited) intraday data. Don't create large DataSets based on it though, because it has throttling limitations in place.

0
- ago
#11
QUOTE:
Did you try to see if it is working on intraday Charts?
It will not work on Daily Charts

I forgot about that limitation. Works with 10-minute bars fairly well. It would be good to include that limitation in the VWAP documentation for this indicator. I'm sure others would be making this same mistake.

CODE:
   vwap = new VWAP(bars); // for Daily bars, substitute: new SMA(bars.Close, emaPeriod);


What about the line ...
CODE:
if (vwap.CrossesUnder(mvwap, idx)) //was: (mvwap.CrossesUnder(vwap, idx))
Can you get this working the other (was) way? The "was way" was how I read the Reply# 4 post.
0
- ago
#12
Look on Answer #6,

Why do we need code if we can do it with a build-in indicator?
0
- ago
#13
QUOTE:
Why do we need code if we can do it with a built-in indicator?

If the trading strategy is simple (This one is.), you can do it with a "block strategy" (Reply# 6). If the strategy is more complex, a "coded strategy" (Reply# 7) is the better approach. But use the approach that you're most comfortable with.

Whether you're using blocks or code, nothing in this problem requires building a custom indicator because the indicators you need (VWAP and EMA) are already available (built-in).
1

Reply

Bookmark

Sort