+1 888 340 6572 GET STARTED
MultiCharts Project Management
previous_open_issue.png
Go to the previous open issue
previous_issue.png
Go to the previous issue (open or closed)
star_faded.png
Please log in to bookmark issues
bug_report_small.png
Open Bug report MC-2509

flip-flop strategy on 1 minute ES bars - even though I use just 1 contract (none specified) per side, orders quantity = 2 in Orders of Position Tracker

action_vote_minus_faded.png
1
Votes
action_vote_plus_faded.png
next_issue.png
Go to the next issue (open or closed)
next_open_issue.png
Go to the next open issue
Description

Each new 1 minute bar, we should swap from long to short and from short to long, as per attached strategy code.
For some reason, we see Sell Quantity = 2 or Buy Quantity = 2 in the Order & Position Tracker.

See the attached avi for details.

Steps to reproduce this issue

Strategy:

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;

namespace PowerLanguage.Strategy {
public class FlipFlop : SignalObject {
public FlipFlop(object _ctx):base(_ctx){}

    private IOrderMarket buy_order, short_order;    
    private int lastSignal;

    protected override void Create() {
        // create variable objects, function objects, order objects etc.
        buy_order = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.Buy));
        short_order = OrderCreator.MarketNextBar(new SOrderParameters(Contracts.Default, EOrderAction.SellShort));
        lastSignal = 0;
    }
    protected override void StartCalc() {
        // assign inputs 
    }
    protected override void CalcBar(){
        // strategy logic
        if(lastSignal != 1){
            Output.WriteLine("Sending Long Entry.");
            buy_order.Send();
            lastSignal = 1;
        } else if(lastSignal != -1)
        {
            Output.WriteLine("Sending Short Entry.");
            short_order.Send();
            lastSignal = -1;
        }
    }
}

}

Attached the avi file showing the issue.

Comments (2)
#1
user-offline.png  andb (andb)
Sep 24, 2018 - 13:25
A file was uploaded. FlipFlop.7zicon_open_new.png
#2
user-offline.png  MultiCharts Support (MultiCharts)
Oct 02, 2018 - 20:33
Buy+SellShort is a reverse strategy. The reverse is done with a single order that both closes the existing position and opens the new one for the specified number of contracts: https://www.multicharts.com/trading-software/index.php/How_Scripts_Work
Changes:
  •   icon_status.pngStatus changed: Under Review => Not a bug
History
Issue basics
  • Type of issue
    Bug report
  • Category
    Not determined
  • Targeted for
    Not determined
  • Status
    Not a bug
  • Priority
    Not determined
User pain
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
Affected by this issue (0)
There are no items
People involved
Times and dates
  • Posted at
  • Last updated
Issue details
  • Reproducability
    Not determined
Attachments (1)
Commits (0)
There are no code checkins for this issue
Duplicate issues (0)
This issue does not have any duplicates