Toronto Canada
Posts: 9 since Jan 2018
Thanks Given: 5
Thanks Received: 1
|
I made a mistake the correct code is
________________________________________________________________________________________________
______________________________________________________________________________________________
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;
namespace PowerLanguage.Strategy {
[IOGMode(IOGMode.Disabled)]
public class working_signal : SignalObject {
private IOrderMarket buy_exit;
private IOrderMarket sell_exit;
private function_profit_target value;
private int counter;
public working_signal(object _ctx):base(_ctx)
{
counter = 0;
}
protected override void Create() {
// create variable objects, function objects, order objects etc.
buy_exit = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, EOrderAction.Sell));
sell_exit = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, EOrderAction.BuyToCover));
value = new function_profit_target(this);
}
protected override void StartCalc() {
// assign inputs
}
protected override void CalcBar()
{
if (CurrentPosition.Side == EMarketPositionSide.Long)
{
counter = counter + 1;
if ((Bars.Close[0] - this.EntryPrice(0)) >= (value[counter]))
{
buy_exit.Send();
counter = 0;
}
}
else if (CurrentPosition.Side == EMarketPositionSide.Short)
{
counter = counter + 1;
if ((Bars.Close[0] - this.EntryPrice(0)) <= ((-1) * value[counter])
{
sell_exit.Send();
counter = 0;
}
}
}
}
}
_______________________________________________________________________________________________
_______________________________________________________________________________________________
|