I have an indicator created by myself. That indicator will provide me the trading signal, for example buy/sell and the sl and tp price.
I am doing something like this in my strategy class now:
void OnBarUpdate() { if (condition okay for Long) { MyIndicator(parameters, ... ).GetLongInfo(ref TP, ref SL); SetProfitTarget(..., TP, ...); SetStopLoss(..., SL, ...); EnterLong(...); } }
if (State == State.DataLoaded) { myTrader = new MyTestingTrader(); myTrader.Init(TPSetting, SLSetting, IndicatorSetting); } void OnBarUpdate() { if (condition okay for Long) { myTrader.DoLong(); } }
namespace NinjaTrader.NinjaScript.Indicators { class MyTestingTrader { } void DoLong() { MyIndicator(parameters, ... ).GetLongInfo(ref TP, ref SL); SetProfitTarget(..., TP, ...); SetStopLoss(..., SL, ...); EnterLong(...); } }
I would like to ask if there is a way to do this ?
Thank you very much.
Comment