Help with this strategy - futures io
futures io futures trading

Help with this strategy

Discussion in MultiCharts

    1. trending_up 1,229 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 1 posts
    2. attach_file 0 attachments

Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

Search this Thread

Help with this strategy

(login for full post details)
  #1 (permalink)
Miami Lakes
Experience: Beginner
Platform: Multicharts
Broker: Interactive Brokers
Trading: Emini ES
Posts: 19 since Oct 2016
Thanks: 2 given, 3 received

Hi everyone,

I am working on this strategy and need help figuring this out please. The strategy begins with opening up a position either long or short doesn't matter. Set a target profit and a stop loss and send the profit and stop orders right away. If target profit is reached, then exit and wait for another position to be opened (manually). If the stop loss is reached, then it should close the initial position, and then open up twice as many contracts in the opposite direction, and this is where I need help. The stop works fine, but I haven't been able to figure out how to send those twice as many contracts. This is what I have so far.

With this line


stoLongToShort is a stop limit order, I am attempting to enter the reverse position, but the order just won't go through. I am sure I am missing something. Please help, thanks in advance.

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

namespace PowerLanguage.Strategy {

public class ProfitTaker : SignalObject
private IOrderMarket bto,sto;
private IOrderPriced stcProfitLong, btcProfitShort;
private IOrderStopLimit stcStopLong, btcStopShort, stoLongToShort, btoShortToLong;
private double takeProfitPrice, takeReversePrice;

int orderSize = 0;
int maxEntriesInPosition = 10;
int maxOrderSize = 1000;

public int ProfitTicks { get; set; }
public int StopTicks { get; set; }

public ProfitTaker(object _ctx) : base(_ctx) { }

private bool bracketSet;

protected override void Create() {

bto = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.UserSpecified, "Buy", EOrderAction.Buy));
sto = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.UserSpecified, "SellShort", EOrderAction.SellShort));

stcProfitLong = OrderCreator.Limit(new SOrderParameters(Contracts.UserSpecified, "TakeProfitLong", EOrderAction.Sell));
stcStopLong = OrderCreator.StopLimit(new SOrderParameters(Contracts.UserSpecified, "StopLong", EOrderAction.Sell));
stoLongToShort = OrderCreator.StopLimit(new SOrderParameters(Contracts.UserSpecified, "LongToShort", EOrderAction.SellShort));

btcProfitShort = OrderCreator.Limit(new SOrderParameters(Contracts.UserSpecified, "TakeProfitShort", EOrderAction.BuyToCover));
btcStopShort = OrderCreator.StopLimit(new SOrderParameters(Contracts.UserSpecified, "StopReverseShort", EOrderAction.BuyToCover));
btoShortToLong = OrderCreator.StopLimit(new SOrderParameters(Contracts.UserSpecified, "ShortToLong", EOrderAction.Buy));

ProfitTicks = 24;
StopTicks = 8;

protected override void StartCalc() {

protected override void CalcBar() {

if (StrategyInfo.MarketPosition == 0 && StrategyInfo.MarketPositionAtBroker != 0) {
ChangeMarketPosition(StrategyInfo.MarketPositionAtBroker - StrategyInfo.MarketPosition, StrategyInfo.AvgEntryPriceAtBroker);
Output.WriteLine("{0} - Sync with broker", Bars.Time[0].ToString("d-M HH:mm"));

if (StrategyInfo.MarketPosition == 0) {
orderSize = 1;
} else {
orderSize = Math.Min(CurrentPosition.OpenLots, maxOrderSize);

if (StrategyInfo.MarketPosition > 0) {

int barsInPosition = Bars.CurrentBar - Positions[0].OpenTrades[0].EntryOrder.BarNumber;
if (barsInPosition == 0) {
takeProfitPrice = Positions[0].OpenTrades[0].EntryOrder.Price + (ProfitTicks * (Bars.Info.MinMove / Bars.Info.PriceScale));
takeReversePrice = Positions[0].OpenTrades[0].EntryOrder.Price - (StopTicks * (Bars.Info.MinMove / Bars.Info.PriceScale));



if (StrategyInfo.MarketPosition < 0) {

int barsInPosition = Bars.CurrentBar - Positions[0].OpenTrades[0].EntryOrder.BarNumber;
if (barsInPosition == 0) {
takeProfitPrice = Positions[0].OpenTrades[0].EntryOrder.Price - (ProfitTicks * (Bars.Info.MinMove / Bars.Info.PriceScale));
takeReversePrice = Positions[0].OpenTrades[0].EntryOrder.Price + (StopTicks * (Bars.Info.MinMove / Bars.Info.PriceScale));




Started this thread Reply With Quote

Journal Challenge February 2021 results (so far):
Competing for $1500 in prizes from Topstep
looks_oneSBtrader82 's Trading Journalby SBtrader82
(153 thanks from 29 posts)
looks_twoJust BEING a Trader: Letting Go!!by iqgod
(111 thanks from 32 posts)
looks_3Wisdom is Emptinessby Mtype
(68 thanks from 25 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(31 thanks from 16 posts)
looks_5Journal for peanuts1956by peanuts1956
(23 thanks from 13 posts)
(login for full post details)
  #2 (permalink)
Posts: 2,230 since Apr 2013
Thanks: 409 given, 1,470 received


you might want to add output statements to check that you send the correct prices etc. for the orders.

What do you intend with "OrderCreator.MarketThisBar"? Seeing that you use IOG, is there a reason for not using "OrderCreator.MarketNextBar"? 4.6.9 Advanced. How The Strategy Backtesting Engine works - MultiCharts

I am not saying you shouldn't use it, but if you do, think about how this affects your code. Especially when you check for something like "barsInPosition == 0".

One thing that I would suggest not to do is sending a stop and an entry order (with twice the size) at the same price. Worst case is that you get filled on both and get an overfill - the reverse orders as you have coded them will exit your position and set you short/long twice the amount. On top of that your exit orders close the open position, too. The result in realtime could be that you are long three times the open short position now (or vice versa).



Follow me on Twitter Reply With Quote

futures io Trading Community Platforms and Indicators MultiCharts > Help with this strategy

Last Updated on November 10, 2016

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


Journal Challenge w/$1500 prizes from Topstep!


Identifying Setups & Targets Using Profile Charts w/Trevor & Tradovate

Feb 25

Battlestations! Show us your trading desk - $1,500 in prizes!


Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts