I don't understand why...
Code: Select all
Condition1 = close > close[1];
Thanks!
Code: Select all
Condition1 = close > close[1];
Because that sloppy PowerLanguage code is like this (redundant lines removed for brevity):I don't understand why...when 'true' means 'order to buy is generated'.Code: Select all
Condition1 = close > close[1];
Code: Select all
Condition1 = close > close[1];
If Condition1 = true then begin
Buy next bar at close limit;
end;
..because when `Condition1` would be false, the limit order would not be submitted.when 'true' means 'order to buy is generated'Code: Select all
Condition1 = close > close[1];
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;
using PowerLanguage.TradeManager;
namespace PowerLanguage.Strategy
{
public class Snippet_Strategy : SignalObject
{
public Snippet_Strategy(object _ctx) : base(_ctx) { }
private IOrderMarket enterLong, exitLong;
protected override void StartCalc()
{
Output.Clear();
}
protected override void Create()
{
enterLong = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.UserSpecified, EOrderAction.Buy));
exitLong = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.UserSpecified, EOrderAction.Sell));
}
protected override void CalcBar()
{
bool longCondition = Bars.Close[0] > Bars.Close[1];
bool shortCondition = Bars.Close[0] < Bars.Close[1];
if (longCondition == true)
{
enterLong.Send(1);
}
else if (shortCondition == true)
{
exitLong.Send(1);
}
// Debug to the PowerLanguage .NET Editor Output Window
Output.WriteLine("{0} - #{1} | MP: {2}, MP at broker: {3}, longCondition = {4}, shortCondition = {5}",
Bars.Time[0].ToString("d-M-yy HH:mm:ss"),
Bars.CurrentBar,
StrategyInfo.MarketPosition,
StrategyInfo.MarketPositionAtBroker,
longCondition,
shortCondition
);
}
}
}
Code: Select all
29-12-14 10:11:00 - #369 | MP: 1, MP at broker: 0, longCondition = True, shortCondition = False
29-12-14 10:16:00 - #370 | MP: 2, MP at broker: 0, longCondition = False, shortCondition = True
29-12-14 10:21:00 - #371 | MP: 0, MP at broker: 0, longCondition = True, shortCondition = False
29-12-14 10:26:00 - #372 | MP: 1, MP at broker: 0, longCondition = True, shortCondition = False
29-12-14 10:31:00 - #373 | MP: 2, MP at broker: 0, longCondition = False, shortCondition = True
29-12-14 10:36:00 - #374 | MP: 0, MP at broker: 0, longCondition = True, shortCondition = False
29-12-14 10:41:00 - #375 | MP: 1, MP at broker: 0, longCondition = True, shortCondition = False
29-12-14 10:46:00 - #376 | MP: 2, MP at broker: 0, longCondition = False, shortCondition = True