In my strategy i have few blocks : initialization, looking for sygnal, managing orders
Drawing objects called on OnBarUpdate() method.
The notify() used to visualize the sygnal.
Initialize() method:
protected override void Initialize()
{
// init embedded indicators
InitializeFractals();
InitializeWorkSessions();
InitializeSygnalParabolic();
InitializeParentParabolic();
InitializePatterns();
InitializeMovings();
// create & populate filter list by name to filter of potential sygnal
createFilterList();
this.lastHigh = new AkPoint();
this.lastLow = new AkPoint();
CalculateOnBarClose = false;
//EntriesPerDirection = 1;
//EntryHandling = EntryHandling.AllEntries;
}
protected override void OnBarUpdate()
{
// no positions --> look for sygnal
if (Position.MarketPosition == MarketPosition.Flat)
{
if (FirstTickOfBar)
{
// no sygnals, we start to check every bar as potential sygnal
LookForTradeSygnal();
return;
}
}
// if no orders found and have sygnal & sygnal is not filtered
if (entryOrder == null && entrySygnal != null && !entrySygnal.Filtered)
ManageOrders();
}
private void LookForTradeSygnal()
{
if (CurrentBar < 5 || CurrentBar < BarsRequired)
return;
// force update akForwardPatterns indicator to recalculate basic wave points
BasicPointsCalculation();
//this.parentSar.Update();
// get sygnal type
AkSygnalType type = getSygnalType();
if (type == AkSygnalType.None)
return;
// create sygnal object
entrySygnal = createEntrySygnal(CurrentBar, type);
// process all filters
processAllFilters(filtersList);
// draw sygnal
if (!entrySygnal.Filtered)
[B]notify(entrySygnal); [/B]
}
private void notify(AkSygnal sygnal)
{
Color upBarColor = Color.Lime;
Color downBarColor = Color.Red;
Color upArrowColor = Color.Yellow;
Color downArrowColor = Color.Yellow;
switch (sygnal.Type)
{
case AkSygnalType.Buy:
BarColorSeries[0] = upBarColor;
DrawArrowUp("upArrow" + CurrentBar, false, 0, Low[0], upArrowColor);
DrawLine("breakeven" + CurrentBar.ToString(), false, CurrentBar - lastHigh.Index, sygnal.Breakeven, CurrentBar - sygnal.Index, sygnal.Breakeven, Color.Black, DashStyle.Dash, 1);
DrawLine("stoploss" + CurrentBar.ToString(), false, CurrentBar - lastHigh.Index, sygnal.Stoploss, CurrentBar - sygnal.Index, sygnal.Stoploss, Color.Red, DashStyle.Dash, 1);
DrawFibonacciRetracements("fibo" + CurrentBar, false, CurrentBar - lastHigh.Index, sygnal.Breakeven, CurrentBar - sygnal.Index, sygnal.Stoploss);
break;
case AkSygnalType.Sell:
BarColorSeries[0] = downBarColor;
DrawArrowDown("downArrow" + CurrentBar, false, 0, High[0], downArrowColor);
DrawLine("breakeven" + CurrentBar.ToString(), false, CurrentBar - lastLow.Index, sygnal.Breakeven, CurrentBar - sygnal.Index, sygnal.Breakeven, Color.Black, DashStyle.Dash, 1);
DrawLine("stoploss" + CurrentBar.ToString(), false, CurrentBar - lastLow.Index, sygnal.Stoploss, CurrentBar - sygnal.Index, sygnal.Stoploss, Color.Red, DashStyle.Dash, 1);
DrawFibonacciRetracements("fibo" + CurrentBar, false, CurrentBar - lastLow.Index, sygnal.Breakeven, CurrentBar - sygnal.Index, sygnal.Stoploss);
break;
}
}

Comment